Link to home
Start Free TrialLog in
Avatar of ginsonic
ginsonicFlag for Romania

asked on

Limit the menu length

Normaly the menu have the length = with form width. I wish, for example to limit the menu with to Form1.Width-30. I wish to add a label in this 30 pixels.

How to do ?
ASKER CERTIFIED SOLUTION
Avatar of mocarts
mocarts

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ginsonic

ASKER

I use D6, so is OK. But how to do that?
I wish to use MyMenu because I customised it. Is derived from the standard TMainMenu.
Avatar of mocarts
mocarts

you can't port easily, except, if you have an Actions used to build menu functionality.
Sorry but I'm new to this topic (Actions).

My menu look alike:

unit MyMenu;

interface

uses
  Windows, Messages, SysUtils, Classes, Menus,Graphics;

type  
  TMyMenu = class(TMainMenu)
  protected
    function  GetHandle: HMENU; override;
  public
    {}
  published
     {}
    end;

procedure Register;

implementation


function TMyMenu.GetHandle: HMENU;
var
  XMenuInfo: TMenuInfo;
  i: integer;
  Brush:TBrush;
begin
  Result := inherited GetHandle;
  XMenuInfo.cbSize := SizeOf(TMenuInfo);
  XMenuInfo.fMask := MIM_BACKGROUND;
  Brush:=TBrush.Create;
  Brush.Color:=$00413730;
  XMenuInfo.hbrBack := Brush.Handle;
  SetMenuInfo(Result, XMenuInfo);
  for i := 0 to Items.Count - 1 do
    SetMenuInfo(Items[i].Handle, XMenuInfo);
end;

procedure Register;
begin
  RegisterComponents('Nick''s', [TMyMenu]);
end;

end.
if found simple but powerful TMenuBar component in net - try it:
http://www.akzhan.midi.ru/devcorner/samples/menubar/menubar.html
this component is descendant of TPanel - so you can resize and place anywhere you want on form and costumize bar color too..
..and enable/disable with no problems by using only one property - Enabled ;)
wbr, mo.
sorr, not TPanel descendant (that's from other sources mixed me :), but TToolbar - anyway it's doesn't make sense :)
mo.