Recent

Author Topic: [Solved] Help me, insert item menu in system menu Program  (Read 3593 times)

laguna

  • Sr. Member
  • ****
  • Posts: 323
[Solved] Help me, insert item menu in system menu Program
« on: March 17, 2018, 09:54:31 am »
Please help me, how insert item menu in menu system program!

Thanks


This solved:
 
Code: Pascal  [Select][+][-]
  1.  
  2. //First, you'll need to add something like this to your main form's declaration:
  3.  
  4. {$IFDEF DARWIN}
  5.   AppMenu     : TMenuItem;
  6.   AppAboutCmd : TMenuItem;
  7.   AppSep1Cmd  : TMenuItem;
  8.   AppPrefCmd  : TMenuItem;
  9. {$ENDIF}
  10.  
  11. //Now add this in the main form's FormCreate handler or some other startup code:
  12.  
  13. {$IFDEF DARWIN}
  14.   AppMenu := TMenuItem.Create(Self);  {Application menu}
  15.   AppMenu.Caption := #$EF#$A3#$BF;  {Unicode Apple logo char}
  16.   MainMenu.Items.Insert(0, AppMenu);
  17.  
  18.   AppAboutCmd := TMenuItem.Create(Self);
  19.   AppAboutCmd.Caption := 'About ' + BundleName;  //<== BundleName set elsewhere
  20.   AppAboutCmd.OnClick := AboutCmdClick;
  21.   AppMenu.Add(AppAboutCmd);  {Add About as item in application menu}
  22.  
  23.   AppSep1Cmd := TMenuItem.Create(Self);
  24.   AppSep1Cmd.Caption := '-';
  25.   AppMenu.Add(AppSep1Cmd);
  26.  
  27.   AppPrefCmd := TMenuItem.Create(Self);
  28.   AppPrefCmd.Caption := 'Preferences...';
  29.   AppPrefCmd.Shortcut := ShortCut(VK_OEM_COMMA, [ssMeta]);
  30.   AppPrefCmd.OnClick := OptionsCmdClick;  //<== "Options" on other platforms
  31.   AppMenu.Add(AppPrefCmd);
  32. {$ENDIF}
  33.  
« Last Edit: March 18, 2018, 09:08:42 am by laguna »

WooBean

  • Full Member
  • ***
  • Posts: 229
Re: Help me, insert item menu in system menu Program
« Reply #1 on: March 17, 2018, 10:24:00 am »
Hi,
a first shot from uncle Google says this https://stackoverflow.com/questions/4615940/how-can-i-customize-the-system-menu-of-a-windows-form

It is not in Pascal but I'm sure you can do it by yourself.

WooBean
« Last Edit: March 17, 2018, 10:26:21 am by WooBean »
Platforms: Win7/64, Linux Mint Ulyssa/64

laguna

  • Sr. Member
  • ****
  • Posts: 323
Re: Help me, insert item menu in system menu Program
« Reply #2 on: March 17, 2018, 10:30:14 am »
In Mac OSX, how in this photo.

« Last Edit: March 17, 2018, 10:47:33 am by laguna »

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Help me, insert item menu in system menu Program
« Reply #3 on: March 17, 2018, 04:31:39 pm »
In Mac OSX, how in this photo.

Use Lazarus Cross-Platform Project here to create new projects:

https://macpgmr.github.io

That will conditionally add appropriate menu items for you per platform conventions.

laguna

  • Sr. Member
  • ****
  • Posts: 323
Re: Help me, insert item menu in system menu Program
« Reply #4 on: March 18, 2018, 09:06:49 am »
Is ok.
Thanks for All.

This code working.

 First, you'll need to add something like this to your main form's declaration:

{$IFDEF DARWIN}
  AppMenu     : TMenuItem;
  AppAboutCmd : TMenuItem;
  AppSep1Cmd  : TMenuItem;
  AppPrefCmd  : TMenuItem;
{$ENDIF}

Now add this in the main form's FormCreate handler or some other startup code:

{$IFDEF DARWIN}
  AppMenu := TMenuItem.Create(Self);  {Application menu}
  AppMenu.Caption := #$EF#$A3#$BF;  {Unicode Apple logo char}
  MainMenu.Items.Insert(0, AppMenu);

  AppAboutCmd := TMenuItem.Create(Self);
  AppAboutCmd.Caption := 'About ' + BundleName;  //<== BundleName set elsewhere
  AppAboutCmd.OnClick := AboutCmdClick;
  AppMenu.Add(AppAboutCmd);  {Add About as item in application menu}
 
  AppSep1Cmd := TMenuItem.Create(Self);
  AppSep1Cmd.Caption := '-';
  AppMenu.Add(AppSep1Cmd);

  AppPrefCmd := TMenuItem.Create(Self);
  AppPrefCmd.Caption := 'Preferences...';
  AppPrefCmd.Shortcut := ShortCut(VK_OEM_COMMA, [ssMeta]);
  AppPrefCmd.OnClick := OptionsCmdClick;  //<== "Options" on other platforms
  AppMenu.Add(AppPrefCmd);
{$ENDIF}



 

TinyPortal © 2005-2018