Solved

multilevel system menu

Posted on 1999-01-21
3
190 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 20 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi and Access based Enumeration 9 92
Wincontrol not (correctly) drawn 15 59
MS Access from Delphi 31 104
Problem working with dynamic array - help 2 49
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

752 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