There is no non-client area in my dialog because I want to draw a custom title. But this means that the system menu is not displayed when the user clicks on the title.
I changed WM_NCHITTEST to reply HTCLIENT to my header and I can record the WM_NCRBUTTONUP message, but I need help demonstrating the system menu, I cannot figure out how to do this properly.
So far I have this:
void CSkinnedDialog::OnNcRButtonUp( UINT nHitTest, CPoint point )
{
CMenu* pMenu = GetSystemMenu(FALSE);
if (int cmd = pMenu->TrackPopupMenu(TPM_RETURNCMD, point.x, point.y, this))
SendMessage(WM_SYSCOMMAND, cmd, MAKELPARAM(point.x, point.y));
}
void CSkinnedDialog::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
LRESULT CSkinnedDialog::OnNcHitTest( CPoint point )
{
LRESULT res = CDialog::OnNcHitTest(point);
ScreenToClient(&point);
if (res == HTCLIENT && point.y < m_nFrameHeight)
{
res = HTCAPTION;
}
return res;
}
void CSkinnedDialog::SysMenuAddAboutEntry()
{
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, "About...");
}
}
, . , (, "..." , , , , ββ.