|
-
December 3rd, 2005, 03:42 AM
#1
Add an item to system menu
How to add an item (i.e. About...) in the system menu in a CFormView derived application?
Thanks.
Last edited by Piccinano; December 4th, 2005 at 10:43 AM.
Reason: Change title
-
December 3rd, 2005, 09:08 PM
#2
Re: CFormView and system menu
Goto Resource view ..-.
select Menu->IDR-Mainframe...
there u can add your menu item ...
Hope this answers to ur query...
kings
kings4u
-
December 4th, 2005, 03:58 AM
#3
Re: CFormView and system menu
With this code i can add menu item in the system menu
CMenu* pMenu = GetSystemMenu(FALSE);
pMenu->AppendMenu ( MF_SEPARATOR, 50, "");
pMenu->AppendMenu ( MF_STRING, 50, "About...");
.... but how handle the message and show the "About.." dialog?
-
December 4th, 2005, 11:40 AM
#4
Re: CFormView and system menu
Read MSDN on AppendMenu.
The second parameter is the menu item command ID. In your case 50.
So, if you pass X as the command ID in AppendMenu, simply add a ON_COMMAND handler like below:
Code:
ON_COMMAND(X,OnX)
void CYourClass::OnX()
{
}
BTW, you do not need to pass 50 for seperator, second parameter is ignored for seperators, so to avoid confusion, why not simply pass 0.
-
December 5th, 2005, 03:45 AM
#5
Re: CFormView and system menu
 Originally Posted by kirants
Read MSDN on AppendMenu.
The second parameter is the menu item command ID. In your case 50.
So, if you pass X as the command ID in AppendMenu, simply add a ON_COMMAND handler like below:
Code:
ON_COMMAND(X,OnX)
void CYourClass::OnX()
{
}
BTW, you do not need to pass 50 for seperator, second parameter is ignored for seperators, so to avoid confusion, why not simply pass 0.
Thanks for reply.
I add
pMenu->AppendMenu ( MF_SEPARATOR);
pMenu->AppendMenu ( MF_STRING, ID_ABOUTBOX, "Information...");
in CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
Then add
ON_COMMAND(ID_ABOUTBOX,OnClickedButtonAbout)
in MESSAGE_MAP of CMainView
but it doesn't show the About dialog with
CAboutDlg aboutDlg;
aboutDlg.DoModal();
Last edited by Piccinano; December 5th, 2005 at 06:48 AM.
-
December 5th, 2005, 12:29 PM
#6
Re: CFormView and system menu
oops..sorry about that.. menu items in system menu generare WM_SYS_COMMAND and not WM_COMMAND.
So, you need to add a
to your message map implemented as:
Code:
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
// TODO: Add your command handler code here
if(ID_APP_ABOUT == nID)
{
CAboutDlg oDlg;
oDlg.DoModal();
}
else
{
CFrameWnd::OnSysCommand(nID,lParam);
}
}
Sorry about the confusion
-
December 5th, 2005, 01:16 PM
#7
Re: CFormView and system menu
-
December 5th, 2005, 01:19 PM
#8
Re: CFormView and system menu
You are welcome
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|