CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Threaded View

  1. #1
    Join Date
    May 2002
    Posts
    1,798

    How to modify the System Menu to execute a function

    I wish to add the item 'Website' to an MFC Dialog app System Menu so that it can activate the following method:
    Code:
    void CMyDlg::OnWebpage() 
    {
    	ShellExecute( NULL, NULL, _T("http://www.codeguru.com"), NULL, NULL, 0 );
    	
    }// OnWebpage()
    I have tried this:
    Code:
    #define IDM_WEBSITE  (WM_USER + 101)
    //..
    		if (!strAboutMenu.IsEmpty())
    		{
    			pSysMenu->AppendMenu(MF_SEPARATOR);
    			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
    			pSysMenu->AppendMenuW(MF_STRING, IDM_WEBSITE, _T("Website"));
    		}
    //..
    void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam)
    {
    	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
    	{
    		CAboutDlg dlgAbout;
    		dlgAbout.DoModal();
    	}
    	else if ((nID & 0xFFF0) == IDM_WEBSITE)
    	{
    		OnWebpage();
    	}
    	else
    	{
    		CDialogEx::OnSysCommand(nID, lParam);
    	}
    }
    The code compiles without error but and the 'website' item appears on the System Menu but it doesnt do anything.

    I've inspected the following but don't really understand how it works and it seems to me there should be a simpler way to accomplish my end.

    Modifying the System Menu By John Simmons 26 Jan 2007
    http://www.codeproject.com/Articles/...he-System-Menu
    Any help appreciated.
    Last edited by Mike Pliam; February 12th, 2013 at 12:46 AM.
    mpliam

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured