- 我创建了一个无标题窗口。
- 我手动(或以编程方式)调整其大小,使其高度为 30 像素或更小。
- 当我捕获底部边框以垂直调整其大小时,它的行为如下 如果我拖动顶部边框。事实上,在调试程序时,WM_SIZING 参数包含 WMSZ_TOP 而不是 WMSZ_BOTTOM。
我的程序是用 Delphi 编写的,基本上问题可以通过以下 FormCreate 的主窗体重现:
procedure TForm2.FormCreate(Sender: TObject);
var oldStyle : LongInt;
var newStyle : LongInt;
begin
// Adapt windows style.
oldStyle := WINDOWS.GetWindowLong (
handle,
GWL_STYLE);
newStyle := oldStyle and
(not WS_CAPTION) and
(not WS_MAXIMIZEBOX);
WINDOWS.SetWindowLong(
handle,
GWL_STYLE,
newStyle);
// SetWindowPos with SWP_FRAMECHANGED needs to be called at that point
// in order for the style change to be taken immediately into account.
WINDOWS.SetWindowPos(
handle,
0,
0,
0,
0,
0,
SWP_NOZORDER or
SWP_NOMOVE or
SWP_NOSIZE or
SWP_FRAMECHANGED or
SWP_NOACTIVATE);
end;
最佳答案
在我看来,这像是操作系统的一个错误。在您的测试用例的条件下, HitTest 处理是错误的,默认窗口过程在应该返回HTBOTTOM
时返回HTTOP
。您可以覆盖 HitTest 处理作为解决方法:
procedure TForm1.WMNCHitTest(var Message: TWMNCHitTest);
begin
inherited;
if (Message.Result = HTTOP) and
(Message.Pos.Y > Top + Height - GetSystemMetrics(SM_CYSIZEFRAME)) then
Message.Result := HTBOTTOM;
end;
关于delphi - 对于高度非常小的窗口,WM_SIZING 中的辅助信息错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20312184/