procedure CreateParams(var Params: TCreateParams); override; procedure TFormMain.CreateParams(var Params: TCreateParams); //change the form style //2003.02.13 begin inherited CreateParams(Params); with Params do begin Style:=(Style or WS_POPUP) xor (ws_dlgframe); ExStyle:=ws_ex_clientedge; end; end;
protected procedure CreateParams(var Params: TCreateParams); override;procedure TfrmMain.CreateParams(var Params: TCreateParams); begin inherited; Params.Style := WS_POPUP or WS_BORDER or WS_SIZEBOX; end;
procedure TForm.HitTest(var Msg: TWmNcHitTest); var pt: TPoint; begin pt := Point(Msg.xPos, Msg.yPos); pt := ScreenToClient(pt); if (pt.x < 5) and (pt.y < 5) then Msg.Result := htTopLeft else if (pt.x > Width - 5) and (pt.y < 5) then Msg.Result := htTopRight else if (pt.x > Width - 5) and (pt.y > Height - 5) then Msg.Result := htBottomRight else if (pt.x < 5) and (pt.y > Height - 5) then Msg.Result := htBottomLeft else if (pt.x < 5) then Msg.Result := htLeft else if (pt.y < 5) then Msg.Result := htTop else if (pt.x > Width - 5) then Msg.Result := htRight else if (pt.y > Height - 5) then Msg.Result := htBottom else inherited; end;
详见WinApi帮助-WM_NCHITTESTunit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure WMNCHITTEST(var msg: TMessage); message WM_NCHITTEST;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
Close;
end;procedure TForm1.WMNCHITTEST(var msg: TMessage);
begin
msg.Result := HTBOTTOM;
end;end.
begin
判断鼠标的位置
ReleaseCapture;
PreForm(WM_SYSCOMMAND, Para, 0);
end;Para = $F001..$F008
自己试试看吧
begin
判断鼠标的位置
ReleaseCapture;
PreForm(WM_SYSCOMMAND, Para, 0);
end;Para = $F001..$F008
自己试试看吧
在onmousedown中写如下代码
begin
判断鼠标的位置
ReleaseCapture;
PreForm(WM_SYSCOMMAND, Para, 0);
end;Para = $F001..$F008
自己试试看吧
procedure TFormMain.CreateParams(var Params: TCreateParams);
//change the form style
//2003.02.13
begin
inherited CreateParams(Params);
with Params do
begin
Style:=(Style or WS_POPUP) xor (ws_dlgframe);
ExStyle:=ws_ex_clientedge;
end;
end;
procedure CreateParams(var Params: TCreateParams); override;procedure TfrmMain.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.Style := WS_POPUP or WS_BORDER or WS_SIZEBOX;
end;
var
pt: TPoint;
begin
pt := Point(Msg.xPos, Msg.yPos);
pt := ScreenToClient(pt);
if (pt.x < 5) and (pt.y < 5) then
Msg.Result := htTopLeft
else if (pt.x > Width - 5) and (pt.y < 5) then
Msg.Result := htTopRight
else if (pt.x > Width - 5) and (pt.y > Height - 5) then
Msg.Result := htBottomRight
else if (pt.x < 5) and (pt.y > Height - 5) then
Msg.Result := htBottomLeft
else if (pt.x < 5) then
Msg.Result := htLeft
else if (pt.y < 5) then
Msg.Result := htTop
else if (pt.x > Width - 5) then
Msg.Result := htRight
else if (pt.y > Height - 5) then
Msg.Result := htBottom
else
inherited;
end;