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 a Form with custom caption bar 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
30-Jun-03
Category
VCL-Forms
Language
Delphi 2.x
Views
270
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Dmitri Papichev

How to remove system caption bar (title bar) or replace it by my own?

Answer:

Below you can find the source code of a unit that performs the task (note that it 
is not a form). All you need is to inherit your form from TDPCCForm instead of 
TForm. Property CaptionControl is accessible at run time and defines the control 
(TGraphicControl) which acts as a caption bar. Usually you assign CaptionControl 
once in OnCreate event handler of you form, but nothing prevents you from further 
changes of CaptionControl at run time. If you leave CaptionControl unassigned, the 
form will have no caption functionality at all. 

1   unit DPCCForms;
2   
3   interface
4   
5   uses
6     Windows, Messages, Classes, Controls, Forms;
7   
8   type
9     TDPCCForm = class(TForm)
10    private
11      { Private declarations }
12      FCaptionControl: TGraphicControl;
13      procedure WMNCHitTest(var AMessage: TWMNCHitTest); message WM_NCHITTEST;
14    protected
15      procedure CreateParams(var Params: TCreateParams); override;
16    public
17      { Public declarations }
18      property CaptionControl: TGraphicControl
19        read FCaptionControl write FCaptionControl default nil;
20    end;
21  
22    {===============================================================}
23  implementation
24  
25  {---------------------------------------------------------------}
26  
27  procedure TDPCCForm.CreateParams(var Params: TCreateParams);
28  begin
29    inherited CreateParams(Params);
30    with Params do
31    begin
32      Style := (Style or WS_POPUP) and (not WS_DLGFRAME);
33    end; {with}
34  end {--TDPCCForm.CreateParams--};
35  
36  {---------------------------------------------------------------}
37  
38  procedure TDPCCForm.WMNCHitTest(var AMessage: TWMNCHitTest);
39  begin
40    inherited;
41    if ((AMessage.Result = HTCLIENT) and
42      Assigned(CaptionControl) and
43      PtInRect(CaptionControl.BoundsRect,
44      ScreenToClient(Point(AMessage.XPos,
45      AMessage.YPos)))) then
46    begin
47      AMessage.Result := HTCAPTION;
48    end; {if}
49  end; {--TDPCCForm.WMNCHitTest--}
50  
51  end.


			
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