How to add an item (i.e. About...) in the system menu in a CFormView derived application?
Thanks.
Printable View
How to add an item (i.e. About...) in the system menu in a CFormView derived application?
Thanks.
Goto Resource view ..-.
select Menu->IDR-Mainframe...
there u can add your menu item ...
Hope this answers to ur query...
kings
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?
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:
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.Code:ON_COMMAND(X,OnX)
void CYourClass::OnX()
{
}
Thanks for reply.Quote:
Originally Posted by kirants
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();
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:ON_WM_SYSCOMMAND()
Sorry about the confusion :(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);
}
}
Thanks.
Now it works.
You are welcome :wave: