Author: Jonas Bilinkevicius How to disable the functionality of a TForm to move Answer: Solve 1: 1 unit FreezeForm; 2 3 interface 4 5 uses 6 Windows, Messages, Classes, Graphics, Forms, Controls, Buttons, 7 StdCtrls, ExtCtrls; 8 9 type 10 TFrmFreeze = class(TForm) 11 BtnValidate: TBitBtn; 12 BtnSave: TBitBtn; 13 BtnPreview: TBitBtn; 14 BtnPrint: TBitBtn; 15 BtnExit: TBitBtn; 16 BtnHelp: TBitBtn; 17 procedure BtnExitClick(Sender: TObject); 18 private 19 FOldWindowProc: TWndMethod; {Old WindowProc} 20 {Window subclassing methods} 21 procedure HookForm; 22 procedure UnhookForm; 23 procedure WndProcForm(var AMsg: TMessage); 24 protected 25 procedure CreateWnd; override; 26 public 27 destructor Destroy; override; 28 end; 29 30 var 31 FrmFreeze: TFrmFreeze; 32 33 implementation 34 35 {$R *.DFM} 36 37 procedure TFrmFreeze.CreateWnd; 38 begin 39 inherited; 40 if csDesigning in ComponentState then 41 Exit; {Don't need to hook when designing} 42 if Enabled then 43 begin 44 HookForm; {Hook the main form's Window} 45 end; 46 end; 47 48 procedure TFrmFreeze.HookForm; 49 begin 50 if csDesigning in ComponentState then 51 Exit; 52 FOldWindowProc := WindowProc; 53 WindowProc := WndProcForm; 54 end; 55 56 procedure TFrmFreeze.UnhookForm; 57 begin 58 if csDesigning in ComponentState then 59 Exit; 60 {If we are "hooked" then undo what Hookform did} 61 if Assigned(FOldWindowProc) then 62 begin 63 if HandleAllocated then 64 begin 65 WindowProc := FOldWindowProc; 66 end; 67 FOldWindowProc := nil; 68 end; 69 end; 70 71 {WndProcForm is our replacement for our WindowProc. We grab any Windows messages 72 that we need here} 73 74 procedure TFrmFreeze.WndProcForm(var AMsg: TMessage); 75 var 76 cmdType: Word; 77 begin 78 if Enabled then 79 begin 80 case AMsg.Msg of 81 WM_SYSCOMMAND: 82 begin 83 cmdType := AMsg.WParam and $FFF0; 84 case cmdType of 85 SC_MINIMIZE, SC_MAXIMIZE, SC_MOVE, SC_SIZE: 86 Exit; 87 end; 88 end; 89 WM_GETMINMAXINFO: 90 Exit; 91 end; 92 end; 93 {Call the default windows procedure} 94 FOldWindowProc(AMsg); 95 end; 96 97 destructor TFrmFreeze.Destroy; 98 begin 99 if not (csDesigning in ComponentState) then 100 UnhookForm; {Stop interfering ...} 101 inherited Destroy; 102 end; 103 104 procedure TFrmFreeze.BtnExitClick(Sender: TObject); 105 begin 106 Close; 107 end; 108 109 end. Solve 2: 110 111 procedure TCoolHint2KForm.WMNCHitTest(var message: TWMNCHitTest); 112 begin 113 inherited; 114 if message.Result = htCaption then 115 message.Result := htNowhere; 116 end;