Link to home
Start Free TrialLog in
Avatar of duke_n
duke_n

asked on

multilevel system menu

How can I add a multilevel menu to my app system menu?
I feel this should be done somehow with appendmenu(), but how?
Avatar of inthe
inthe

i found this one on the net a while back ,hope you can understand it ok:

 PURPOSE:     Demo program.  Shows how to add items to system menu of form and application.  The system menus are           different because the Application effectively puts a             wrapper around the forms.

  CAVEATS:     The IDs for new menu items must be multiples of 16 (or in hex, have the form $XXX0).  This is because Windows           uses the lower 4 bits of WParam in the WM_SYSCOMMAND               message for internal purposes, so you have to mask them
out if you trap this message and check WParam for your
ID. To check if a menu ID already exists, use         GetMenuState( hMenu, ItemID, MY_BYCOMMAND);
 This returns -1 if an item with the passed ID does NOT
   already exist. }

unit Sysmenu1;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    Procedure AppMessage( var msg:TMsg; var Handled : Boolean);
  public
  end;

var
  Form1: TForm1;

implementation

{ Add an item to the system menu and the form menu. }
procedure TForm1.FormCreate(Sender: TObject);
var
  FormSysMenu, AppSysMenu : THandle;
begin
  AppSysMenu := GetSystemMenu(Application.Handle,False);
  AppendMenu(AppSysMenu,mf_Separator,0,'');
  AppendMenu(AppSysMenu,mf_Enabled,$E010,'App Menu Item');

  FormSysMenu := GetSystemMenu(Form1.Handle,False);
  AppendMenu(FormSysMenu,mf_Separator,0,'');
  AppendMenu(FormSysMenu,mf_Enabled,$E020,'Form Menu Item');

  Application.OnMessage := AppMessage;
end;

{ Intercept Windows messages & find those from our new menu items }
Procedure TForm1.AppMessage( var msg:TMsg; var Handled : Boolean);
begin
  if msg.WParam = $E010 then begin
     Handled := True;
     MessageBox(Handle,'From Application Menu','Menu Result',mb_OK);
     end;

  if msg.WParam = $E020 then begin
     Handled := True;
     MessageBox(Handle,'From Form Menu','Menu Result',mb_OK);
     end;
end;

end.
Regards Barry

Avatar of duke_n

ASKER

I know how to add items to system menu!!!

I wanted to add'em to make a MULTILEVEL, CASCADING(like start>programs menu, or explorer's file>new menu) !!!!!
ASKER CERTIFIED SOLUTION
Avatar of inthe
inthe

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