Mega Code Archive

 
Categories / Delphi / Examples
 

MDI application without annoying ScrollBars

Title: MDI application without annoying ScrollBars Question: 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. //-------------------------------- 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; //-------------------------------- Step two: Put this standalone function inside the unit that contains the main form, before the OnCreate event (once OnCreate references to this function). //-------------------------------- 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; //-------------------------------- That's it!!! The code was originally posted by Peter Below in a newsgroup (borland.public.delphi.objectpascal). I've made some little changes.