怎样改变BorderStyle设为bsNone的窗体的大小?(100分)

H

huifi

Unregistered / Unconfirmed
GUEST, unregistred user!
Form的BorderStyle设为bsNone
在其上放有一Panel,Align设为alClient,窗体的大小怎样改变?
 
private
procedure WmNcHitTest (var Msg: TWmNcHitTest);
message wm_NcHitTest;

procedure TForm1.WmNcHitTest(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;
 
虽然在Delphi中把窗口的属性BorderStyle设为bsNone可以让标题栏消失,但同时窗口却不能
缩放了,下面这段代码可以使你鱼和熊掌兼得,BorderStyle设为BsSizeable。

procedure TForm1.FormCreate(Sender:TObject);
begin
SetWindowLong(Handle,GWL_STYLE,GetWindowLong
(Handle,GWL_STYLE) AND NOT WS_CAPTION);
ClientHeight:=Height;
end;
 
还有的方法就是继承CreateParam过程,设置Style以及StyleEx。
 
用QuickSilver的方法比较好
 
to wwolf:
当在其上放有一Panel,Align设为alClient时WmNcHitTest过程将不发生,即接收不到
鼠标消息,不知有什么函数或方法将其上的Panel的所有鼠标消息转发到Form上?
 
多人接受答案了。
 
把FORM的borderwidth设为2或3即可
 

Similar threads

S
回复
0
查看
986
SUNSTONE的Delphi笔记
S
S
回复
0
查看
804
SUNSTONE的Delphi笔记
S
D
回复
0
查看
757
DelphiTeacher的专栏
D
D
回复
0
查看
737
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
顶部