MDI without scrollbar

Source: Internet
Author: User

Etienne,

This has no effect since the scrollbars do not belong to the MDI frame
Window itself, they belong to the client window, which is not a Delphi
Form. Which means one has to attack the problem on the API level.
Since this question has come up so frequently in recent days I have
Modified a sample based on the stock MDI project to include this
Feature. The salient parts are quoted below.

Open the main forms unit in the IDE.
If you don't have a handler for the oncreate event, add one. In
Handler you do this:

If clienthandle <> 0 then begin
If getwindowlong (clienthandle, gwl_userdata) <> 0 then
Exit; // cannot subclass client window, userdata already in use
Setwindowlong (clienthandle, gwl_userdata,
Setwindowlong (clienthandle, gwl_wndproc,
INTEGER (@ clientwindowproc )));
End;

Add a new standalone function to the Unit, it has to go abve
Formcreate method since it is referenced in the statement above.

Function clientwindowproc (WND: hwnd; MSG: Cardinal; wparam,
Lparam: integer): integer; stdcall;
VaR
F: pointer;
Begin
F: = pointer (getwindowlong (WND, gwl_userdata ));
Case MSG
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;

I clipped this code from a larger project, so lets hope I did not
Create errors in the process. What this Code does is to subclass
Client window the API way. It stores the old window function into
Gwl_userdata field of the window structure since it is needed in
Replacement window function, all messages need to be passed on to
Old window function. There is only one message of interest in this case
(The use of a case results from the larger project, which handles more
Than this message): wm_nccalcsize. The window gets this message when
Windows tries to hide or show the scrollbars, among other cases. And it
Arrives * Before * there is any painting of the scrollbar. So we can
Check if the window is going to sprout scrollbars and simply remove
Scrollbar styles again.

For the purists: there is no need to undo the subclassing before
Form is destroyed since the client window is destroyed before the form
Object.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.