Solved

MDI form scrollbars

Posted on 1997-03-16
2
647 Views
Last Modified: 2012-05-04
 I want to make MDI main form scrollbars to be invisible
even in that case when one or more child windows come out
from the main form border.
  But setting up to .FALSE. of main form properties HorzScrollBar.Visible and VertyScrollBar.Visible give'nt effect. Then I try to redefine Style of the main form Style:=Style and not WS_HSROLL (WS_VSCROLL) by overriding the TForm.CreateParams metod, but with the same result.
  The only exit from this situation I find is to rewrite
TForm.AlignControls directly in forms.pas. (I made the scrollbars positions out from form border and then they are invisible though present physicaly.
  Unfortunately after this I have'nt a possibility to rebuild VCL and to use some modules (such as VBX tc.) because not all modules that are referencing to forms are present in source code.
   This Is my problem and I'd like to know, is there any way
to disable at all these scrollbars without coming into VCL
source code?
  Any help will be grateful.
0
Comment
Question by:riaukamo
2 Comments
 
LVL 1

Accepted Solution

by:
ozzy earned 100 total points
ID: 1334769
Line 2389 in Forms.pas:
            WS_CLIPCHILDREN or WS_HSCROLL or WS_VSCROLL or

Here's the problem... Commenting out the scroll styles will make things work as you wanted, but then, you got the version problem when installing other components....


Here's a unit fixing it.

Have your mainform call InstallHook(Self) sometime AFTER OnShow but before OnShow of any MDI CHild. I called it in the procedure creating a new MDI child.

Remember to call RemoveHook when the app terminates.

What happens is:
Everytime a MDI child is moved out of the MDI parent's window, a undocumented?? message, value $3F, is sent to the MDICLIENT window. The defaulthandler for this message obviously resets the window style to the one specified when creating the window. Unfortunately, I could not hook this message, therefore I just located an appropriate message to hook, and set the styles I want in the hook proc.




----------------------
unit ScrollFix;

interface
uses
  Forms, Messages, Windows;

function InstallHook (AForm : TForm) : BOOLEAN;
function RemoveHook : BOOLEAN;

implementation


// These styles will be removed from the window
const
  StylesToRemove = WS_VSCROLL or WS_HSCROLL;


// Globals, for faster access
var
  StyleFixupWindow,
  StyleFixupHook : INTEGER;


// The hook procedure
function StyleFixup (nCode : INTEGER; wParam : WORD; lParam : INTEGER) : INTEGER; stdcall;
var
  pcwr  : PCWPRetStruct;
begin
  pcwr := POINTER(lParam);

// WM_WINDOWPOSCHANGING seems to work. Tried a lot, but as far
// as I find, this one's stable.
  if (pcwr^.hwnd = StyleFixupWindow)
  and (pcwr^.message = WM_WINDOWPOSCHANGING) then begin

// Modify the window style.
    SetWindowLong
      (
        StyleFixupWindow,
        GWL_STYLE,
        GetWindowLong (StyleFixupWindow, GWL_STYLE) and not StylesToRemove
      );
  end;
  if nCode=HC_ACTION then Result := 0 else Result := CallNextHookEx(StyleFixupHook, nCode, wParam, lParam);
end;

function InstallHook (AForm : TForm) : BOOLEAN;
begin
// Installs the hook if not already installed.
  Result := StyleFixupWindow=0;
  if not Result then exit;
  StyleFixupHook := SetWindowsHookEx(WH_CALLWNDPROCRET, @StyleFixup, hInstance, 0);
  Result := StyleFixupHook<>0;
  if Result then StyleFixupWindow := AForm.CLientHandle;
end;

function RemoveHook : BOOLEAN;
begin
// Removes the hook if installed
  Result := StyleFixupWindow<>0;
  if Result then Result := UnhookWindowsHookEx (StyleFixupHook);
  if Result then StyleFixupWindow := 0;
  Application.ProcessMessages;
end;

initialization
// Better keep this, the compiler is a bit buggy and doesn't always
// initialize globals.
  StyleFixupWindow := 0;
end.
----------------------

0
 

Author Comment

by:riaukamo
ID: 1334770
Please answer if it's possible what I need to make your unit
to work under Delphi 1.0?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now