Author: Jonas Bilinkevicius
Is there a way of hiding a TMainMenu?
Answer:
Yes, do not hide it. What you do is leave it visible (as well as caption bar and
border) and then just size the whole window so that only the client area is
visible, all the nonclient area, including the menu bar, simply lies outside the
visible screen. The alternative is to use a toolbar menu instead of a standard menu
bar.
1 { ... }2 private{in form declaration}3 4 procedure WMGetMinMaxInfo(var msg: TWMGetMinMaxInfo); message WM_GETMINMAXINFO;
5 { ... }6 7 procedure TForm1.WMGetMinMaxInfo(var msg: TWMGetMinMaxInfo);
8 begin9 inherited;
10 with msg.MinMaxInfo^.ptMaxTrackSize do11 begin12 X := GetDeviceCaps(Canvas.handle, HORZRES) + (Width - ClientWidth);
13 Y := GetDeviceCaps(Canvas.handle, VERTRES) + (Height - ClientHeight);
14 end;
15 end;
16 17 procedure TForm1.Button2Click(Sender: TObject);
18 const19 Rect: TRect = (Left: 0; Top: 0; Right: 0; Bottom: 0);
20 FullScreen: Boolean = False;
21 begin22 FullScreen := not FullScreen;
23 if FullScreen then24 begin25 Rect := BoundsRect;
26 SetBounds(Left - ClientOrigin.X, Top - ClientOrigin.Y,
27 GetDeviceCaps(Canvas.handle, HORZRES) + (Width - ClientWidth),
28 GetDeviceCaps(Canvas.handle, VERTRES) + (Height - ClientHeight));
29 { Label2.caption := IntToStr(GetDeviceCaps(Canvas.handle, VERTRES)); }30 end31 else32 BoundsRect := Rect;
33 end;