2005. március 11., péntek
Create caption for TWinControl components
Problem/Question/Abstract:
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:
unit ListboxTest;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TListboxTest = class(TListbox)
private
{ Private declarations }
protected
procedure CreateParams(var Params: TCreateParams); override;
public
{ Public declarations }
published
{ Published declarations }
property Caption stored True;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TListboxTest]);
end;
procedure TListboxTest.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
with Params do
begin
Style := Style or WS_CAPTION;
end;
end;
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... :)
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése