Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

multilevel system menu

Posted on 1999-01-21
3
Medium Priority
?
203 Views
Last Modified: 2010-04-06
How can I add a multilevel menu to my app system menu?
I feel this should be done somehow with appendmenu(), but how?
0
Comment
Question by:duke_n
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 1362742
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

0
 
LVL 1

Author Comment

by:duke_n
ID: 1362743
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) !!!!!
0
 
LVL 17

Accepted Solution

by:
inthe earned 80 total points
ID: 1362744
hi duke_n
god this took me ages to work out but finally i cracked it.hop it's what you were after,you need to create a popup first then append away
Regards Barry

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

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

var
  Form1: TForm1;

implementation

{$R *.DFM}
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;
 
  if msg.WParam = $E060 then begin
     Handled := True;
     Showmessage ('Hello how are you');
      end;
end;
procedure TForm1.FormCreate(Sender: TObject);

var
  FormSysMenu, AppSysMenu : THandle;
  MenuItemInfo:TMenuItemInfo;
  hPopup : HMenu;
  begin
  AppSysMenu := GetSystemMenu(Application.Handle,False);
   AppendMenu(AppSysMenu,mf_Separator,0,'');
  AppendMenu(AppSysMenu,mf_ENABLED,$E010,'App Menu Item');
  hPopup := CreatePopupMenu;
  AppendMenu(appsysmenu,MF_POPUP,hPopup,'&Test');
  FormSysMenu := GetSystemMenu(Form1.Handle,False);
  AppendMenu(FormSysMenu,mf_Separator,0,'');
  AppendMenu(FormSysMenu,mf_Enabled,$E020,'Form Menu Item');
  AppendMenu(Formsysmenu,MF_POPUP,hPopup,'&Test');
  Appendmenu(hpopup,mf_enabled,$E030,'&Here');
  Appendmenu(hpopup,mf_enabled,$E040,'&Is');
  Appendmenu(hpopup,mf_enabled,$E050,'&A Pop-up');
  Appendmenu(hpopup,mf_enabled,$E060,'&Menu');
  Application.OnMessage := AppMessage;
end;

end.




0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question