【发布时间】:2020-07-29 13:29:36
【问题描述】:
在主要包含MDI parent form 的桌面应用程序上工作,其中模块显示为MDI Child form。
在将子窗体移动到客户端限制之外时,我想摆脱滚动条。我已经将AutoScroll 属性设置为False 并尝试了以下解决方案:
procedure TForm1.FormCreate(Sender: TObject);
begin
if ClientHandle <> 0 then
begin
if (not (GetWindowLong(ClientHandle, GWL_USERDATA) <> 0)) then
begin
SetWindowLong(ClientHandle, GWL_USERDATA,
SetWindowLong(ClientHandle, GWL_WNDPROC,
Integer(@ClientWindowProc)));
end;
end;
end;
function ClientWindowProc(wnd: HWND; Msg: Cardinal; wParam, lParam: Integer): Integer; stdcall;
var
f: Pointer;
begin
f := Pointer(GetWindowLong(wnd, GWL_USERDATA));
case Msg of
WM_NCCALCSIZE: begin
if (GetWindowLong(wnd, GWL_STYLE) and (WS_HSCROLL or WS_VSCROLL)) <> 0 then
SetWindowLong(wnd, GWL_STYLE, GetWindowLong(wnd, GWL_STYLE) and not (WS_HSCROLL or WS_VSCROLL));
end;
end;
Result := CallWindowProc(f, wnd, Msg, wparam, lparam);
end;
如果没有启用 VCL 样式,它就像一个魅力。否则,我无法捕捉到WM_NCCALCSIZE 消息。
我正在使用 Delphi Rio 10.3.3 和 VCL Styles。
【问题讨论】:
-
你为什么要这样钩住客户端 WndProc?在主窗体中覆盖
ClientWndProc不是更容易吗?
标签: delphi scrollbar vcl delphi-10.3-rio vcl-styles