Am trying to make my program menu and skin resize when I disable the MainMenu VCL I have attached a image of a program that uses same idea when menu is enabled there is too buttons hidden but once the menu is disabled the pager and options buttons and rest of the skin is visible I been trying to recreate this with out any luck can any one help ?

Thanks alot f7d0d05b451a50953ebde55bdaa34474

Recommended Answers

All 3 Replies

The easiest way is:
a) Add a TPanel to your form. Let's say you call it HiddenPanel.
b) Set the Align property of the HiddenPanel to alTop and delete the panel's caption.
c) Set the height of HiddenPanel to be the menu height. Do this in code in case the user changes their settings. Add this line to the form's onCreate event handler:

  HiddenPanel.Height := GetSystemMetrics(SM_CYMENU);

d) Set the initial visibility state of the panel based on whether the menu is visible. So add this code to the form's onCreate event handler:

HiddenPanel.Visible := (Menu = nil);

d) Put the Pager and Options buttons on HiddenPanel.
e) To hide the menu and reveal the buttons your code would be:

  LockWindowUpdate(Self.Handle);
  try
    Menu := nil;
    HiddenPanel.Visible := TRUE;
  finally
    LockWindowUpdate(0);
  end;

(The LockWindowUpdate calls are there to prevent flickering).
f) To Re-display the menu in place of the buttons your code would be (if your menu is called MainMenu1):

  LockWindowUpdate(Self.Handle);
  try
    Menu := MainMenu1;
    HiddenPanel.Visible := FALSE;
  finally
    LockWindowUpdate(0);
  end;

You may also want to disable keyboard-based operation of the Pager and Options buttons.

Yes that hides the buttons when menu is disabled but it dont cover the top of the theme image so you can still see were the buttons should be if you look at the image when the menu is enabled the buttons and the top of the theme is invisiable I been trying to work this out with out any luck

If the buttons are shown as an image you need to split the image into 2 parts and put one part onto HiddenPanel. This should be done programmatically when you set the height of the hidden panel to match the height of the menu.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.