Author: Ido Kanner
In microsoft access I can see the Listbox there contains a window caption. how can
I create my own components win a caption ?
Answer:
We must not forget that this code will work only in a TWinControl components.
Well, first of all we must declear the procedure of CreateParams in the public
section...
Then we go to work !!!
Now you must add this line in the publised area if you wish to add some text to the
caption:
property Caption;
Now for the code part:
1 unit ListboxTest;
2 3 interface4 5 uses6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 StdCtrls;
8 9 type10 TListboxTest = class(TListbox)
11 private12 { Private declarations }13 protected14 procedure CreateParams(var Params: TCreateParams); override;
15 public16 { Public declarations }17 published18 { Published declarations }19 property Caption stored True;
20 end;
21 22 procedureregister;
23 24 implementation25 26 procedureregister;
27 begin28 RegisterComponents('Samples', [TListboxTest]);
29 end;
30 31 procedure TListboxTest.CreateParams(var Params: TCreateParams);
32 begin33 inherited CreateParams(Params);
34 with Params do35 begin36 Style := Style or WS_CAPTION;
37 end;
38 end;
39 40 end.
Now we have a caption for our ListBox... And the funny part is that i read while back that VB users payied mony for this kind of OCX component... :)