Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


MDI form scrollbars

Posted on 1997-03-16
Medium Priority
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.
Question by:riaukamo
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

ozzy earned 200 total points
ID: 1334769
Line 2389 in Forms.pas:

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;

  Forms, Messages, Windows;

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


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

// Globals, for faster access
  StyleFixupHook : INTEGER;

// The hook procedure
function StyleFixup (nCode : INTEGER; wParam : WORD; lParam : INTEGER) : INTEGER; stdcall;
  pcwr  : PCWPRetStruct;
  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.
        GetWindowLong (StyleFixupWindow, GWL_STYLE) and not StylesToRemove
  if nCode=HC_ACTION then Result := 0 else Result := CallNextHookEx(StyleFixupHook, nCode, wParam, lParam);

function InstallHook (AForm : TForm) : BOOLEAN;
// 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;

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

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


Author Comment

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

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

618 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