我想禁止窗體被移動,又想保留窗體標題欄. 請高手指教!!!!!

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TForm1 = class(TForm)
        procedure FormCreate(Sender: TObject);
        procedure FormDestroy(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}
    var
      OldWindowProc : Pointer;function NewWindowProc(WindowHandle : THandle;
                           TheMessage   : LongInt;
                           ParamW       : LongInt;
                           ParamL       : LongInt) : LongInt{$IFDEF WIN32} stdcall; {$ELSE} ; export; {$ENDIF}
    begin
    { Process the message of your choice here }
      if TheMessage = WM_NCLBUTTONDOWN then
      begin
        if paramW=HTCAPTION then    exit;  end;{ Exit here and return zero if you want     }
    { to stop further processing of the message }{ Call the old Window procedure to }
    { allow processing of the message. }
      NewWindowProc := CallWindowProc(OldWindowProc,
                                      WindowHandle,
                                      TheMessage,
                                      ParamW,
                                      ParamL);
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
    OldWindowProc := Pointer(SetWindowLong(Handle,GWL_WNDPROC,LongInt(@NewWindowProc)));
    end;procedure TForm1.FormDestroy(Sender: TObject);
    begin
    SetWindowLong(Handle,GWL_WNDPROC,LongInt(OldWindowProc));
    end;end.
      

  2.   

    type
      TForm1 = class(TForm)
      private
       procedure wmnchittest(var msg:twmnchittest);message wm_nchittest;
        { Private declarations }
       ...procedure TForm1.wmnchittest(var msg:twmnchittest);
    begin
    inherited;
    if (htcaption = msg.result) then msg.result:=htclient;
    end;
      

  3.   

    謝謝各位, 我已經自己解決了.
    代碼類似於 lincanwen(Too Two To) 的代碼
    再再將次感謝.  想給各位加分, 可不知道如何操作. 哈..........
      

  4.   

    在你移动form的title时,其实是由系统向你的程序发送消息,然后你的程序再根据这个消息,来知道该把窗体画在哪里,所以截获这个消息,不让它再发出去,或者更改消息中的参数,就可以防止窗体被移动了。
      

  5.   

    給你機會, 解決另一個問.   呵呵.......^l^如何用代碼將一個已經設計好的菜單中的items添加到另一個主菜單中去