Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to Create caption for TWinControl components Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
16-Jul-03
Category
VCL-General
Language
Delphi 2.x
Views
120
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			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   interface
4   
5   uses
6     Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7     StdCtrls;
8   
9   type
10    TListboxTest = class(TListbox)
11    private
12      { Private declarations }
13    protected
14      procedure CreateParams(var Params: TCreateParams); override;
15    public
16      { Public declarations }
17    published
18      { Published declarations }
19      property Caption stored True;
20    end;
21  
22  procedure register;
23  
24  implementation
25  
26  procedure register;
27  begin
28    RegisterComponents('Samples', [TListboxTest]);
29  end;
30  
31  procedure TListboxTest.CreateParams(var Params: TCreateParams);
32  begin
33    inherited CreateParams(Params);
34    with Params do
35    begin
36      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... :) 

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC