Author: Rafael Cotta
I've been trying to create a MDI form without those annoying scrollbars when a
child form is moved outside main form area and I couldn't find an easy way. Setting
the scrollbars to visible := false won't work!
So, I found an example on a newsgroup... yeah! Here I show how to do it.
Answer:
It's a two step proccess.
Step one : put the code below inside the OnCreate event of the main form.
1 if ClientHandle <> 0 then
2 begin
3 if (not (GetWindowLong(ClientHandle, GWL_USERDATA) <> 0)) then
4 begin
5 SetWindowLong(
6 ClientHandle,
7 GWL_USERDATA,
8 SetWindowLong(ClientHandle, GWL_WNDPROC, integer
9 (@ClientWindowProc))
10 );
11 end;
12 end;
Step two: Put this standalone function inside the unit that contains the main form,
before the OnCreate event (once OnCreate references to this function).
13
14 function ClientWindowProc(wnd: HWND; msg: Cardinal; wparam, lparam: Integer):
15 Integer;
16 stdcall;
17 var
18 f: Pointer;
19 begin
20 f := Pointer(GetWindowLong(wnd, GWL_USERDATA));
21 case msg of
22 WM_NCCALCSIZE:
23 begin
24 if (
25 GetWindowLong(wnd, GWL_STYLE) and
26 (WS_HSCROLL or WS_VSCROLL)) <> 0 then
27 SetWindowLong(
28 wnd,
29 GWL_STYLE,
30 GetWindowLong(wnd, GWL_STYLE) and not
31 (WS_HSCROLL or WS_VSCROLL)
32 );
33 end;
34 end;
35 Result := CallWindowProc(f, wnd, msg, wparam, lparam);
36 end;
That's it!!!
The code was originally posted by Peter Below in a newsgroup (borland.public.delphi.objectpascal). I've made some little changes.
|