Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TMainMenu in WIN and OSX


This question is answered.


Permlink Replies: 5 - Last Post: Jul 20, 2017 10:35 PM Last Post By: Douglas Rudd
Nicolò Blunda

Posts: 23
Registered: 7/20/10
TMainMenu in WIN and OSX  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 27, 2015 1:25 AM
Hello.
This is an old question, but I don't find valid solution.
How it is possible to HIDE TMainMenu in WIN application and show it only in OSX (in System Menu Bar)?
None property Visible is exposed and menu is always shown in Windows application (like top bar).
I don't want to duplicare project (that is perfectly compilable in both WIN and OSX) for this issue...
Ronald Klitsche

Posts: 326
Registered: 8/26/01
Re: TMainMenu in WIN and OSX  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 27, 2015 3:26 AM   in response to: Nicolò Blunda in response to: Nicolò Blunda
How it is possible to HIDE TMainMenu in WIN application and show it only in
OSX (in System Menu Bar)?
None property Visible is exposed and menu is always shown in Windows
application (like top bar).
I don't want to duplicare project (that is perfectly compilable in both WIN
and OSX) for this issue...

Place the TMainMenu on a TForm which is only created on MacOS platform?
Or make different inherited main TForm for Win and MacOS, where TMainMenu in
only on the Mac TForm.

Ronald
Lajos Juhasz

Posts: 801
Registered: 3/14/14
Re: TMainMenu in WIN and OSX
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 27, 2015 10:36 AM   in response to: Nicolò Blunda in response to: Nicolò Blunda
Nicolò Blunda wrote:

Hello.
This is an old question, but I don't find valid solution.
How it is possible to HIDE TMainMenu in WIN application and show it
only in OSX (in System Menu Bar)? None property Visible is exposed
and menu is always shown in Windows application (like top bar). I
don't want to duplicare project (that is perfectly compilable in both
WIN and OSX) for this issue...

An ugly solution could be to destroy the main menu at formcreate:

  {$ifdef mswindows}
    MainMenu1.Destroy;
  {$endif}
Nicolò Blunda

Posts: 23
Registered: 7/20/10
Re: TMainMenu in WIN and OSX  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 28, 2015 12:14 AM   in response to: Lajos Juhasz in response to: Lajos Juhasz
Lajos Juhasz wrote:
Nicolò Blunda wrote:

Hello.
This is an old question, but I don't find valid solution.
How it is possible to HIDE TMainMenu in WIN application and show it
only in OSX (in System Menu Bar)? None property Visible is exposed
and menu is always shown in Windows application (like top bar). I
don't want to duplicare project (that is perfectly compilable in both
WIN and OSX) for this issue...

An ugly solution could be to destroy the main menu at formcreate:

  {$ifdef mswindows}
    MainMenu1.Destroy;
  {$endif}

Thank you for answer.
But, with this code, WIN menu still remains (and works!!).
This is a very strange behavior...
Nicolò Blunda

Posts: 23
Registered: 7/20/10
Re: TMainMenu in WIN and OSX  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 22, 2016 9:51 PM   in response to: Nicolò Blunda in response to: Nicolò Blunda
Nicolò Blunda wrote:
Lajos Juhasz wrote:
Nicolò Blunda wrote:

Hello.
This is an old question, but I don't find valid solution.
How it is possible to HIDE TMainMenu in WIN application and show it
only in OSX (in System Menu Bar)? None property Visible is exposed
and menu is always shown in Windows application (like top bar). I
don't want to duplicare project (that is perfectly compilable in both
WIN and OSX) for this issue...

An ugly solution could be to destroy the main menu at formcreate:

  {$ifdef mswindows}
    MainMenu1.Destroy;
  {$endif}

Thank you for answer.
But, with this code, WIN menu still remains (and works!!).
This is a very strange behavior...

I found solution (partially...). Behavior is consequence of some huge graphics style (for example Diamond.style). Together with light model, solution purposed works fine.
Douglas Rudd

Posts: 314
Registered: 5/16/97
Re: TMainMenu in WIN and OSX  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 20, 2017 10:29 PM   in response to: Nicolò Blunda in response to: Nicolò Blunda
You are correct that when using some styles if you call MainMenu1.Destroy the mainmenu still doesn't go away. And with some styles it does.

I worked around this for the problem styles by not having the stylebook property set when starting and setting it after you destroy MainMenu in code.

procedure TMainForm.FormCreate(Sender: TObject);
begin
{$IFDEF MSWINDOWS}
  MainMenu1.Destroy;
  StyleBook := WindowsStyleBook;
{$ENDIF}
{$IFDEF MACOS}
  StyleBook := MACStyleBook;
{$ENDIF}
end;
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02