如何拖动窗体而使其不闪动?(50分)

  • 主题发起人 主题发起人 Hunter_Fisher
  • 开始时间 开始时间
H

Hunter_Fisher

Unregistered / Unconfirmed
GUEST, unregistred user!
当点击窗体任何一地方时,拖动它,如何解决?(要使它不闪动)
 
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
SendMessage(Handle, WM_SYSCOMMAND, $F012, 0);
end;
 
private
{ Private declarations }
procedure WMNCHITTEST(VAR Msg: TWMNCHITTEST); message wm_nchittest;

implementation

{$R *.DFM}

procedure TForm1.WMNCHITTEST(var Msg:TWMNCHITTEST);
begin
inherited;
if Msg.Result = htClient then
Msg.Result :=htCaption;
end;
 
在private部分加入下列代码:
procedure wmnchittest(var msg:twmnchittest);
message wm_nchittest;
在程序部分加入以下代码:
procedure TForm1.wmnchittest(var msg:twmnchittest);
begin
inherited;
if (htclient=msg.result) then msg.result:=htcaption;
end;
 
给段代码给你,一试即成…………
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, jpeg;

type
TForm1 = class(TForm)
Image1: TImage;
Bevel1: TBevel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure wmnchittest(var msg:twmnchittest);
message wm_nchittest;

public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
//SetWindowLong(application,Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
end;
procedure TForm1.wmnchittest(var msg:twmnchittest);
begin
inherited;
if (htclient=msg.result) then msg.result:=htcaption;
end;

end.
 
procedure TForm1.Form1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if ssleft in shift then releasecapture;
form1.Perform (WM_NCLBUTTONDOWN ,htCaption,0);
//self.perform(WM_SYSCOMMAND,$F012,0);//这样也行
end;
 

Similar threads

回复
0
查看
689
不得闲
回复
0
查看
863
不得闲
回复
0
查看
804
不得闲
后退
顶部