delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
498 Users Online NOW
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi



Loremo - the 1.5 liter car coming in 2009




Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (2)


MDI application without annoying ScrollBarsFormat this article printer-friendly!Bookmark function is only available for registered users!
How to create a MDI app without scrollbars (like MS-Word)
Product:
Delphi all versions
Category:
N/A
Skill Level:
Scoring:
Last Update:
02/07/2002
Search Keys:
delphi delphi3000 article borland vcl code-snippet mdi application scrollbar word style SetWindowLong GetWindowLong
Times Scored:
5
Visits:
3434
Uploader: Rafael Cotta
Company:
Reference: N/A
 
Question/Problem/Abstract:
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.







Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
problems
    fedra goodman (Nov 13 2006 12:46PM)

The above code looks nice but will bring you only problems. I stoped using it!

It is a nightmare at debugging. Every time I
run my program step by step, it jumps to this function to process that message.
I also think here I may loose some CPU in this
code.

Also my program crash alot when it close (I have 5 TForms) after adding the above code.

I am still looking for a better solution.
Respond

This code did not work for me
    Jay Mohan (Aug 12 2006 3:58PM)

Hi Rafael Cotta

Thanks for posting this code here. It will work only for client windows going out of the main area as mentioned by you. To remove the scrollbars that will appear when the main window is resized, we still need to make the AutoScroll propert to "False".

Thanks once again for the nice piece of code.

Best Regards
Jay


Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
D. Wischnewski
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)