如何去掉MDI父窗体的滚动条?在MDI主窗体实现如下代码是可以实现
Function ClientWindowProc( wnd: HWND; msg: Cardinal; wparam, lparam: Integer ): Integer; stdcall;
Var
pUserdata: Pointer;
Begin
pUserdata:= 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(pUserdata, wnd, msg, wparam, lparam );
end;procedure TMainForm.FormCreate(Sender: TObject);
begin
// ShowScrollBar(mainform.clienthandle, SB_BOTH, false );
If ClientHandle <> 0 Then Begin
If GetWindowLong( ClientHandle, GWL_USERDATA ) <> 0 Then Exit; // 加上回调句柄
SetWindowLong( ClientHandle, GWL_USERDATA, SetWindowLong( ClientHandle, GWL_WNDPROC, integer( @ClientWindowProc)));
End;
end;
但是我想要的是另外一种办法,是在MDI子窗体的Form的消息处理中来实现,现在找不到眉目?
在这里请教大家了,谢谢
Function ClientWindowProc( wnd: HWND; msg: Cardinal; wparam, lparam: Integer ): Integer; stdcall;
Var
pUserdata: Pointer;
Begin
pUserdata:= 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(pUserdata, wnd, msg, wparam, lparam );
end;procedure TMainForm.FormCreate(Sender: TObject);
begin
// ShowScrollBar(mainform.clienthandle, SB_BOTH, false );
If ClientHandle <> 0 Then Begin
If GetWindowLong( ClientHandle, GWL_USERDATA ) <> 0 Then Exit; // 加上回调句柄
SetWindowLong( ClientHandle, GWL_USERDATA, SetWindowLong( ClientHandle, GWL_WNDPROC, integer( @ClientWindowProc)));
End;
end;
但是我想要的是另外一种办法,是在MDI子窗体的Form的消息处理中来实现,现在找不到眉目?
在这里请教大家了,谢谢
ShowScrollBar(Handle, SB_VERT, False);去掉垂直滚动条
begin
if not msg=$003F then
Result := CallWindowProc(pUserdata, wnd, msg, wparam, lparam );
end;过滤掉消息$003F即可。
var
frmChild: TfrmChild;
DefaultClientWndProc :Pointer;
function ClientWndProc(wndHandle :HWND;Msg :LongInt;
wParam,lParam :LongInt) :LongInt;stdcall;implementationuses Main;{$R *.dfm}function ClientWndProc(wndHandle :HWND;Msg :LongInt;
wParam,lParam :LongInt) :LongInt;
begin
if Msg<>$003F then
Result := CallWindowProc(DefaultClientWndProc,frmMain.ClientHandle,Msg,WParam,LParam);
end;{Main.Pas}implementationuses Child;{$R *.dfm}
procedure TfrmMain.FormCreate(Sender: TObject);
begin
DefaultClientWndProc :=Pointer(SetWindowLong(ClientHandle,GWL_WNDPROC,
LongInt(@ClientWndProc)));
end;放什么地方很清楚了吧?你想在MDI子窗口里处理,这样就可以。$003F消息做什么用?去VCL的Forms看看去,如果ShowScrollBar(Handle, SB_HORZ, False);去掉水平滚动条
ShowScrollBar(Handle, SB_VERT, False);去掉垂直滚动条是毫无效果的,因为$003F消息会再使窗口带上滚动条。
DefaultClientWndProc :=Pointer(SetWindowLong(ClientHandle,GWL_WNDPROC,
LongInt(@ClientWndProc))); 实际上,你完全可以放在在子窗体中。procedure TfrmChild.FormCreate(Sender: TObject);
begin
if DefaultClientWndProc = nil then
DefaultClientWndProc :=Pointer(SetWindowLong(frmMain.ClientHandle,GWL_WNDPROC,
LongInt(@ClientWndProc)));
end; 楼主不知是基础太差还是太不愿意动脑子了?