Post by unknownthanks for your replies, but i'm completely unfamiliar with
writing VCLs. i will be so glad if i could find a component
actually as same as TValueListEditor but with 3 columns and
a drop-down combobox as the value editor (as i described well
in my first post).
Maybe this helps?
============================================
From: "Peter Below (TeamB)"
Subject: Re: TListView Question : Embedding a TCombobox?
Post by unknownHas anyone figured out how to have a TCombobox embedded in one or more of
the TListview's SubItems?
Attach a combobox to a listview subitem column and scoll them with
the listview.
You have to trap scroll messages to the listview and update the
comboboxes position. See example below. The listview has three columns,
width set to -1 for all three.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, stdctrls, ComCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
ListView1: TListView;
ComboBox1: TComboBox;
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
FOldListviewWindowProc: TWndMethod;
FListviewHeaderHeight: Integer;
Procedure ListviewWindowproc(var Message: TMessage);
procedure AttachCombobox;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses commctrl;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
i: integer;
r: TRect;
ListviewHeader: HWND;
begin
for i:= 1 to 10 do
with listview1.Items.add do begin
caption := format('Item %d',[i]);
subitems.add( format('SubItem %d.1',[i]) );
subitems.add( format('SubItem %d.2',[i]) );
end;
ListviewHeader := GetWindow( listview1.Handle, GW_CHILD );
GetWIndowrect( ListviewHeader, r );
FListviewHeaderHeight := r.Bottom - r.top;
FOldListviewWindowProc:= listview1.WindowProc;
listview1.WindowProc := ListviewWindowproc;
AttachCombobox;
end;
procedure TForm1.AttachCombobox;
var
r: TRect;
wnd: HWND;
begin
fillchar( r, sizeof(r), 0 );
ListView_GetSubItemRect( listview1.Handle, 4, 1, LVIR_BOUNDS, @r );
combobox1.Parent := listview1;
combobox1.BoundsRect := r;
combobox1.Visible := r.Top >= FListviewHeaderHeight;
end;
procedure TForm1.ListviewWindowproc(var Message: TMessage);
begin
FOldListviewWindowProc( Message );
Case Message.Msg Of
WM_VSCROLL, WM_HSCROLL:
If Message.WParamLo <> SB_ENDSCROLL Then
AttachCombobox;
End;
end;
end.
--
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