我正在尝试调整非无边界表单(bsNone 边框样式)的大小。可以使用以下代码完成,但仅在应用程序未启用 VCL 样式时才有效。
protected
procedure WMNCHitTest(var message: TWMNCHitTest); message WM_NCHITTEST;
....
procedure TForm1.WMNCHitTest(var message: TWMNCHitTest);
const
EDGEDETECT = 7;
var
deltaRect: TRect;
begin
inherited;
if BorderStyle = bsNone then
with Message, deltaRect do
begin
Left := XPos - BoundsRect.Left;
Right := BoundsRect.Right - XPos;
Top := YPos - BoundsRect.Top;
Bottom := BoundsRect.Bottom - YPos;
if (Top < EDGEDETECT) and (Left < EDGEDETECT) then
Result := HTTOPLEFT
else if (Top < EDGEDETECT) and (Right < EDGEDETECT) then
Result := HTTOPRIGHT
else if (Bottom < EDGEDETECT) and (Left < EDGEDETECT) then
Result := HTBOTTOMLEFT
else if (Bottom < EDGEDETECT) and (Right < EDGEDETECT) then
Result := HTBOTTOMRIGHT
else if (Top < EDGEDETECT) then
Result := HTTOP
else if (Left < EDGEDETECT) then
Result := HTLEFT
else if (Bottom < EDGEDETECT) then
Result := HTBOTTOM
else if (Right < EDGEDETECT) then
Result := HTRIGHT
end;
我也试过做这样的事情,结果是一样的。那么在启用 VCL 样式时如何使其可调整大小?
非常感谢你。
procedure CreateParams(var params: TCreateParams); override;
...
procedure TForm1.CreateParams(var params: TCreateParams);
begin
BorderStyle := bsNone;
inherited;
params.ExStyle := params.ExStyle or WS_EX_STATICEDGE;
params.Style := params.Style or WS_SIZEBOX;
end;