[wxWidgets] Add “About…” to the system menu

Posted on Dec 21, 2014

Original post: https://forums.wxwidgets.org/viewtopic.php?f=20&t=13921

MyDialog.h

class MyDialog : public wxDialog
{
	...

	// Override MSWTranslateMessage
	bool MSWTranslateMessage(WXMSG* pMsg);
};

MyDialog.cpp

// Include aboutdlg.h
#include <wx/aboutdlg.h>

MyDialog::MyDialog(wxWindow* parent)
{
	...

	// Add the menu item, "About...", to the system menu
	HMENU hSystemMenu = ::GetSystemMenu((HWND__*)GetHWND(), FALSE);
	::AppendMenu(hSystemMenu, MF_SEPARATOR, 0, wxT(""));
	::AppendMenu(hSystemMenu, MF_STRING, wxID_ABOUT, wxT("About..."));
	::DrawMenuBar((HWND__*)GetHWND());
}

// implement the message handler
bool MyDialog::MSWTranslateMessage(WXMSG* pMsg)
{
	if (WM_SYSCOMMAND==pMsg->message && wxID_ABOUT==pMsg->wParam)
	{
		wxAboutDialogInfo di;
		di.SetName(wxT("My App"));
		di.SetVersion(wxT("1.00"));
		di.SetDescription(wxT("This app does cool trix!"));

		wxAboutBox(di);

		return true; // Message processed
	}

	return wxDialog::MSWTranslateMessage(pMsg);
}