Articles   Members Online: 3
-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 Disable form movement when the screen resolution exceeds 800x600 pixel 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
129
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

How to disable form movement when the screen resolution exceeds 800x600 pixel

Answer:

Handle the WM_NCHittest and change the HTCaption to HTNowhere. An example, which 
doesn't allow a form to be moved if the screen resolution is larger than 800x600 
pixel:

1   unit Unit1;
2   
3   interface
4   
5   uses
6     SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
7     Forms, Dialogs, StdCtrls, Menus;
8   
9   type
10    TForm1 = class(TForm)
11      procedure Exit1Click(Sender: TObject);
12      procedure FormShow(Sender: TObject);
13    private
14      { Private declarations }
15    public
16      { Public declarations }
17      procedure DontMove(var Msg: TMessage); message WM_NCHITTEST;
18      procedure DeleteItemsFromSysMenu;
19    end;
20  
21  var
22    Form1: TForm1;
23  
24  implementation
25  
26  {$R *.DFM}
27  
28  procedure TForm1.DeleteItemsFromSysMenu;
29  var
30    SysMenuHwnd: THandle;
31    i: integer;
32  begin
33    SysMenuHwnd := GetSystemMenu(Form1.Handle, False);
34    {Have to be done in reverse order because if not the numbering would be 
35  	different each time the function is called}
36    for i := 6 downto 0 do
37      DeleteMenu(SysMenuHwnd, i, MF_BYPOSITION);
38  end;
39  
40  procedure TForm1.DontMove(var Msg: TMessage);
41  var
42    bAllowMove: Boolean;
43  begin
44    bAllowMove := (Screen.Width >= 800);
45    inherited;
46    if (Msg.Result <> htReduce) and (Msg.Result <> htClose) and (Msg.Result <> 
47  htSysMenu)
48      then
49      if (Msg.Result = htCaption) and (not bAllowMove) then
50        Msg.Result := htNowhere;
51  end;
52  
53  procedure TForm1.Exit1Click(Sender: TObject);
54  begin
55    Close;
56  end;
57  
58  procedure TForm1.FormShow(Sender: TObject);
59  begin
60    DeleteItemsFromSysMenu;
61  end;
62  
63  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