Board index » delphi » Toggling Caption and Menu Bar ON/OFF

Toggling Caption and Menu Bar ON/OFF

Sometimes last  year there was a thread on this topic:
How to toggle on/off Caption and Menu bar as is
done  by the Clock accessory.

Does anyone have a Borland Pascal solution?

Thanks for your help

Jean D. Ichbiah

 

Re:Toggling Caption and Menu Bar ON/OFF


In <ichbiah.368.30617...@jdi.tiac.net> ichb...@jdi.tiac.net (Jean D. Ichbiah) writes:

Quote
>Sometimes last  year there was a thread on this topic:
>How to toggle on/off Caption and Menu bar as is
>done  by the Clock accessory.
>Does anyone have a Borland Pascal solution?
>Thanks for your help
>Jean D. Ichbiah

I do this:

procedure TMyWindow.Resize;
var
  Msg  : TMessage;
  Rect : TRect;
begin
  GetClientRect (HWindow, Rect);
  Msg.WParam   := 0;
  Msg.LParamLo := Rect.Right  - Rect.Left;
  Msg.LParamHi := Rect.Bottom - Rect.Top;
  SendMessage(HWindow, WM_SIZE, Msg.WParam, Msg.LParam);
end;

procedure TMyWindow.ShowMenu(Visible : boolean);
begin
  if Attr.Menu <> 0 then
  begin
    if Visible then
      SetMenu (HWindow, Attr.Menu)
    else
      SetMenu (Hwindow, 0);
    Resize;
  end;
end;

procedure TMyWindow.ShowCaption (Visible : boolean);
var
  WinStyle : longint;
begin
  WinStyle := GetWindowLong (HWindow, gwl_Style);
  if Visible then
    WinStyle := WinStyle or ws_Caption or ws_SysMenu
  else
    WinStyle := WinStyle and not ws_Caption and not ws_SysMenu;
  SetWindowLong(HWindow, gwl_Style, WinStyle);
  SetWindowPos(HWindow, 0, 0, 0, 0, 0, swp_noZOrder or swp_noMove or swp_NoSize or swp_DrawFrame);
  Resize;
end;

Where TMyWindow descend from TWindow.

Hope this helps.

--
 Hallvard Vassbotn  | Falcon AS (a Reuters company) | Without programmers,
 hallv...@falcon.no | Stranden 1, 0250 OSLO, Norway | the world would stop!

Other Threads