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?
I feel this should be done somehow with appendmenu(), but how?
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) !!!!!
I wanted to add'em to make a MULTILEVEL, CASCADING(like start>programs menu, or explorer's file>new menu) !!!!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
AppendMenu(AppSysMenu,mf_S
AppendMenu(AppSysMenu,mf_E
FormSysMenu := GetSystemMenu(Form1.Handle
AppendMenu(FormSysMenu,mf_
AppendMenu(FormSysMenu,mf_
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