BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TListView problems?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using
View previous topic :: View next topic  
Author Message
Rob .
Guest





PostPosted: Fri Nov 28, 2003 9:56 am    Post subject: TListView problems? Reply with quote



hello my friends,

in my last question in this forum, i've received some valuable
comments about my problems.

i want to add a combo-box to a TListView component, so i used
the following code that is posted by Peter Below and i changed
some parts of it.

procedure TForm1.AttachComboBox(Index: Integer);
var
r: TRect;
begin
FillChar(r, SizeOf(r), 0);
ListView_GetSubItemRect(ListView1.Handle, Index, 2, LVIR_BOUNDS, @r);
ComboBox1.Parent := ListView1;
ComboBox1.BoundsRect := r;
ComboBox1.Visible := (r.Top > FListViewHeaderHeight);
end;

procedure TForm1.ListViewWndProc(var Message: TMessage);
begin
FOldListViewWndProc(Message);
case Message.Msg of
WM_VSCROLL, WM_HSCROLL:
if Message.WParamLo <> SB_ENDSCROLL then
AttachComboBox(ListView1.Selected.Index);
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
HeaderHWND: HWND;
r: TRect;
begin
HeaderHWND := GetWindow(ListView1.Handle, GW_CHILD);
GetWindowRect(HeaderHWND, r);
FListViewHeaderHeight := r.Bottom - r.Top;

FOldListViewWndProc := ListView1.WindowProc;
ListView1.WindowProc := ListViewWndProc;
end;


now these are my questions

1. if the listview has xp style headers, the FListViewHeaderHeight
won't have the valid value, so it never shows the combo box
for the first visible line.

2. the listview column height is not similar to the height of
the combobox. so it has a strange appearance. how to set the
height of listview to a bigger value (actually as same as the
height of the combo box), also its current line height
produces annoying appearance on Win98!

thanks for any reply,
Rob


Back to top
Rob .
Guest





PostPosted: Sat Nov 29, 2003 5:48 am    Post subject: Re: TListView problems? Reply with quote



is my question too hard even for masters of these n.g. (teamb)?

i'm currently working on my questions but w/out any results! so
i need your help;)

Quote:
hello my friends,

in my last question in this forum, i've received some valuable
comments about my problems.

i want to add a combo-box to a TListView component, so i used
the following code that is posted by Peter Below and i changed
some parts of it.

procedure TForm1.AttachComboBox(Index: Integer);
var
r: TRect;
begin
FillChar(r, SizeOf(r), 0);
ListView_GetSubItemRect(ListView1.Handle, Index, 2, LVIR_BOUNDS, @r);
ComboBox1.Parent := ListView1;
ComboBox1.BoundsRect := r;
ComboBox1.Visible := (r.Top > FListViewHeaderHeight);
end;

procedure TForm1.ListViewWndProc(var Message: TMessage);
begin
FOldListViewWndProc(Message);
case Message.Msg of
WM_VSCROLL, WM_HSCROLL:
if Message.WParamLo <> SB_ENDSCROLL then
AttachComboBox(ListView1.Selected.Index);
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
HeaderHWND: HWND;
r: TRect;
begin
HeaderHWND := GetWindow(ListView1.Handle, GW_CHILD);
GetWindowRect(HeaderHWND, r);
FListViewHeaderHeight := r.Bottom - r.Top;

FOldListViewWndProc := ListView1.WindowProc;
ListView1.WindowProc := ListViewWndProc;
end;


now these are my questions

1. if the listview has xp style headers, the FListViewHeaderHeight
won't have the valid value, so it never shows the combo box
for the first visible line.

2. the listview column height is not similar to the height of
the combobox. so it has a strange appearance. how to set the
height of listview to a bigger value (actually as same as the
height of the combo box), also its current line height
produces annoying appearance on Win98!

thanks for any reply,
Rob




Back to top
Peter Below (TeamB)
Guest





PostPosted: Sat Nov 29, 2003 10:26 am    Post subject: Re: TListView problems? Reply with quote



In article <3fc8412d$1 (AT) newsgroups (DOT) borland.com>, wrote:
Quote:
is my question too hard even for masters of these n.g. (teamb)?

Your question has "XP" in it, so i pass <g>.

The line height in a report-style listview is not configurable directly,
it somehow figures out the line height from the font used and (if used)
the size of the images in the controls imagelist.

You may want to use a TStringgrid instead, it offers you much more ways to
control it. Examples for putting controls like comboboxes into a
stringgrid have been posted in the past. I have some in my snippets
collection as well, which you can get from CodeCentral:

http://codecentral.borland.com/codecentral/ccweb.exe/finder
19374: Peter Belows 2002 Snippets collection


--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be



Back to top
Rob .
Guest





PostPosted: Sat Nov 29, 2003 11:37 am    Post subject: Re: TListView problems? Reply with quote


"Peter Below (TeamB)" <100113.1101 (AT) compuXXserve (DOT) com> wrote:
Quote:
Your question has "XP" in it, so i pass <g>.

i know why most of programmers hate XP:-)

Quote:
I have some in my snippets collection as well, which you can
get from CodeCentral:

hmm, i always get an error message whenever i want to download
something from codecentral! iac, i've solved the problem just
a few minutes ago, and i'm already using TListView component.
(but i never forget that string grid is an incredi-vcl, i
really like it:)

but i have two other questions about TListView:

1. i want to display the attached combo box whenever the user
clicks on the related field (in this case, index = 2) not
the row. iow, how can i call the AttachComboBox when the
third column is clicked? i tried to handle OnColumnClick,
but it only raised when the header is clicked.
is it impossible again?! (if so why should we use TListView?
<g>)

2. you've substituted the window proc handler of the list view
to reattach the combo box when the list is scrolled, but
unfortunately it doesn't respond to mouse wheel, should we
handle another window message?
hope to be able to do so, otherwise i dunno what should i
say about this component.

if there is no way to solve the above problems, can you please
help me to download your codes from code central.

thanks,
Rob



Back to top
Rob .
Guest





PostPosted: Sun Nov 30, 2003 8:47 am    Post subject: Re: TListView problems? Reply with quote


"Rob" . wrote:
Quote:

"Peter Below (TeamB)" <100113.1101 (AT) compuXXserve (DOT) com> wrote:
Your question has "XP" in it, so i pass <g>.

i know why most of programmers hate XP:-)

This time i didn't talk about XP, so why there is no replies to
my questions?!?!?!?!

Quote:
I have some in my snippets collection as well, which you can
get from CodeCentral:

hmm, i always get an error message whenever i want to download
something from codecentral! iac, i've solved the problem just
a few minutes ago, and i'm already using TListView component.
(but i never forget that string grid is an incredi-vcl, i
really like it:)

but i have two other questions about TListView:

1. i want to display the attached combo box whenever the user
clicks on the related field (in this case, index = 2) not
the row. iow, how can i call the AttachComboBox when the
third column is clicked? i tried to handle OnColumnClick,
but it only raised when the header is clicked.
is it impossible again?! (if so why should we use TListView?
g>)

2. you've substituted the window proc handler of the list view
to reattach the combo box when the list is scrolled, but
unfortunately it doesn't respond to mouse wheel, should we
handle another window message?
hope to be able to do so, otherwise i dunno what should i
say about this component.

if there is no way to solve the above problems, can you please
help me to download your codes from code central.

thanks,
Rob




Back to top
JD
Guest





PostPosted: Sun Nov 30, 2003 10:21 am    Post subject: Re: TListView problems? Reply with quote

"Rob" . wrote:
Quote:
[...] how can i call the AttachComboBox when the third
column is clicked?

Standard Windows behavior is if the user clicks a control and
moves the mouse off the control before releasing the mouse,
the click is not acted on. To achieve this behavior, you need
to use it's onMouseDown and OnMouseUp events.

In the OnMouseDown event, you need to record the X,Y click point.

In the OnMouseUp event, you need to GetItemAt() for the click
point and the release point. if they're the same, then you
have the TListItem that was clicked so act on it.

Quote:
[...] but unfortunately it doesn't respond to mouse wheel,
should we handle another window message?

Yes. Just add an else statement to look for WM_MOUSEWHEEL.
The details can be found in the win32.hlp file.

~ JD

BTW : GetItemAt() will only work for subcolumns when the
RowSelect property is set to true. If that's unacceptable for
you, try using the GetHitTestInfoAt and GetNearestItem methods.


Back to top
Peter Below (TeamB)
Guest





PostPosted: Sun Nov 30, 2003 1:49 pm    Post subject: Re: TListView problems? Reply with quote

In article <3fc9bca1$1 (AT) newsgroups (DOT) borland.com>, wrote:
Quote:
This time i didn't talk about XP, so why there is no replies to
my questions?!?!?!?!

Because you are way too impatient. It's a weekend, for Christs sake,
and many of us only browse the groups once per day.

Quote:
1. i want to display the attached combo box whenever the user
clicks on the related field (in this case, index = 2) not
the row. iow, how can i call the AttachComboBox when the
third column is clicked? i tried to handle OnColumnClick,
but it only raised when the header is clicked.
is it impossible again?! (if so why should we use TListView?
g>)

Do it in OnClick:

Uses COmmCtrl;

procedure TForm1.ListView1Click(Sender: TObject);
var
pt: TPoint;
item : TLIstItem;
hittestinfo: TLVHitTestInfo;
begin
pt:= listview1.ScreenToClient( mouse.cursorpos );
item := listview1.GetItemAt( pt.x, pt.y );
If assigned( item ) then
memo1.Lines.add('Hit on item '+item.Caption )
else begin
FillChar( hittestinfo, sizeof( hittestinfo ), 0 );
hittestinfo.pt := pt;
If -1 <> listview1.perform( LVM_SUBITEMHITTEST, 0,
lparam(@hittestinfo))
Then Begin
memo1.lines.add( format(
'Item: %d (%s), subitem: %d (%s)',
[hittestinfo.iItem, listview1.items[hittestinfo.iItem].caption,
hittestinfo.iSubItem,
listview1.items[hittestinfo.iItem].Subitems[
hittestinfo.iSubItem-1 ]] ));

End
Else
memo1.lines.add( 'Not on item or subitem');
end;
end;

Quote:
2. you've substituted the window proc handler of the list view
to reattach the combo box when the list is scrolled, but
unfortunately it doesn't respond to mouse wheel, should we
handle another window message?

If the listview control was properly written it would send scroll
messages to itself when getting mouse wheel messages, but no, they had
to take shortcuts again at MS... Add a case for WM_MOUSEWHEEL.

Quote:
if there is no way to solve the above problems, can you please
help me to download your codes from code central.

I have no control whatsoever over the CodeCentral site. Perhaps you can
still download the 2001 version from
http://www.dpassmore.com/links/Delphistuff.asp



--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be



Back to top
Rob .
Guest





PostPosted: Sun Nov 30, 2003 9:01 pm    Post subject: Re: TListView problems? Reply with quote


"Peter Below (TeamB)" <100113.1101 (AT) compuXXserve (DOT) com> wrote:
Quote:
Because you are way too impatient. It's a weekend, for Christs sake,
and many of us only browse the groups once per day.

sorry, i forgot that:D

thanks for your useful reply, both of my questions have been
solved. but now i have another question about TListView that
is not related to the attached combo box.

i've written my project with D7 on WinXP (without xp-manifest).
the appearance of the list view is completely ok on WinXP.
but when i execute the executable file on Win98, the grid lines
and the selection box are not matched together. iow, the top of
the highlighted box is lesser than the top of the grid line:
(RowSelect is true)

..-----------------------------------------. <-- selection top
Quote:
_________________________________________| <-- grid line
The Selected Item |
'-----------------------------------------' <-- selection bottom

_________________________________________ <-- grid line
The Second Item
...

also please note that FListViewHeaderHeight is 17 on WinXP, but
on Win98 it returns 0! imho it may be the reason of the above
problem.

// i also used ListView_GetHeader, but the result was similar
HeaderHWND := GetWindow(ListView1.Handle, GW_CHILD);
GetWindowRect(HeaderHWND, r);
FListViewHeaderHeight := r.Bottom - r.Top;

do you have any comments about it?

thanks,
Rob



Back to top
Brian Cook
Guest





PostPosted: Mon Dec 01, 2003 6:46 am    Post subject: Re: TListView problems? Reply with quote

Quote:
This time i didn't talk about XP, so why there is no replies to
my questions?!?!?!?!

Because you are way too impatient. It's a weekend, for Christs sake,
and many of us only browse the groups once per day.

Not just a weekend but, for those of us who call the United States our
home, Thanksgiving Weekend.

So, "Rob", please try to be a bit more patient.

- Brian

Back to top
JD
Guest





PostPosted: Mon Dec 01, 2003 10:46 am    Post subject: Re: TListView problems? Reply with quote


"Rob" . wrote:
Quote:
[...] do you have any comments about it?

If you read this post closely:

http://tinyurl.com/x65b

you'll notice that the TeamB member indicates that you need IE3+
Perhaps that's the problem.

~ JD


Back to top
Rob .
Guest





PostPosted: Mon Dec 01, 2003 8:12 pm    Post subject: Re: TListView problems? Reply with quote

"JD" <nospam (AT) nospam (DOT) com> wrote:
Quote:
If you read this post closely:

http://tinyurl.com/x65b

you'll notice that the TeamB member indicates that you need IE3+
Perhaps that's the problem.

thanks, but it is not related to my question. if you read my
previous post, you will see the problem with the appearance of
the list view on Win98. i'm really confused that why it has a
good appearance on WinXP but not on Win98. the only problem is
that the grid lines are not placed in a desired position!

i've installed Win98 just for testing my projects and no parts
of it is upgraded. so IE4 is installed by default. can you plz
test it yourself, do you have the same problem? a TListView
with RowSelect and a 18x18 imagelist that is linked to it?

plz note that i've created my project on WinXP (w/out manifest)
with D7.

any comments?
Rob



Back to top
Rob .
Guest





PostPosted: Wed Dec 03, 2003 7:42 pm    Post subject: Re: TListView problems? Reply with quote


i didn't get any replies?!?!?!

"Rob" . wrote:
Quote:
if you read my previous post, you will see the problem with
the appearance of the list view on Win98. i'm really confused
that why it has a good appearance on WinXP but not on Win98.
the only problem is that the grid lines are not placed in a
desired position!

i've installed Win98 just for testing my projects and no parts
of it is upgraded. so IE4 is installed by default. can you plz
test it yourself, do you have the same problem? a TListView
with RowSelect and a 18x18 imagelist that is linked to it?

plz note that i've created my project on WinXP (w/out manifest)
with D7.

any comments?
Rob




Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.