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 roll up and restore a TForm when clicking on the title 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
28-Oct-02
Category
VCL-Forms
Language
Delphi 2.x
Views
132
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

How to roll up and restore a TForm when clicking on the title bar

Answer:

The standard behaviour for double clicking a title bar is to maximize/ restore the 
form. The following class changes the double click action to add a new effect which 
is RollUp/ Restore. Copy the following unit and place it in a directory which is 
recognised by Delphi's search path.

1   unit OrckaForm;
2   
3   interface
4   
5   {$B-}
6   
7   uses
8     Messages, Forms, Classes;
9   
10  type
11    TOrckaForm = class(TForm)
12    private
13      FOldHeight: Longint;
14      FRollUp, FRolledUp: Boolean;
15    protected
16      procedure WMNCLDblClick(var Msg: TMessage); message WM_NCLBUTTONDBLCLK;
17      procedure WMGetMinMaxInfo(var Msg: TMessage); message WM_GETMINMAXINFO;
18    public
19      constructor Create(AOwner: TComponent); override;
20      property RollUp: Boolean read FRollUp write FRollUp;
21    end;
22  
23  implementation
24  
25  uses
26    Windows;
27  
28  procedure TOrckaForm.WMNCLDblClick(var Msg: TMessage);
29  begin
30    if (Msg.wParam = HTCAPTION) and (FRollUp) then
31    begin
32      if FRolledUp then
33      begin
34        FRolledUp := False;
35        Height := FOldHeight;
36      end
37      else
38      begin
39        FRolledUp := True;
40        FOldHeight := Height;
41        Height := 0
42      end;
43    end
44    else
45      inherited;
46  end;
47  
48  constructor TOrckaForm.Create(AOwner: TComponent);
49  begin
50    inherited Create(AOwner);
51    FOldHeight := Height;
52    FRollUp := True;
53    FRolledUp := False;
54  end;
55  
56  procedure TOrckaForm.WMGetMinMaxInfo(var Msg: TMessage);
57  begin
58    inherited;
59    if FRolledUp then
60      pMinMaxInfo(Msg.lParam)^.ptMaxTrackSize.y := Height;
61  end;
62  
63  end.
64  
65  //To use the form create a new form which will look something like..
66  
67  unit Unit3;
68  
69  interface
70  
71  uses
72    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
73  
74  type
75    TForm3 = class(TForm)
76    private
77      { Private declarations }
78  
79  //Add OrckaForm to the uses clause and change the following line
80  
81  TForm3 = class(TForm)
82  
83  //to
84  
85  TForm3 = class(TOrckaForm)


Run your project, whenever you double click the title the form will roll up/ restore.

			
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