Mega Code Archive

 
Categories / Delphi / VCL
 

Create caption for TWinControl components

Title: Create caption for TWinControl components Question: 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: procedure TCaptionListBox.CreateParams(Params : TCreateParams); begin inherited CreateParams(Params); Params.Caption:= Caption; //We give the text that will displayed Params.Style := Style or WS_CAPTION; end; //End of the procedure 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... :) Please feel free to comment Ido Kanner