Re: Taskbar Button and SysMenu ?
Disregard the post about the dialog not displaying a taskbar button. I
possibly didn't notice that there was a taskbar button for the dialog when I
used the code (below).
However, the problem that I am having now is some previous code that I
worked out (with help from posting here) to drag the dialog from a border
area around the dialog is not working. The code is the correct order in
OnInitDialog().
BOOL CBmpBkgdTBarButtonsDlg::OnInitDialog()
{
ModifyStyle(0, WS_SYSMENU); // this is above the auto-generated icon
code
// TODO: Add extra initialization here
SetWindowText("Any Text Here"); // sets taskbar text
ModifyStyle(WS_CAPTION, 0, SWP_DRAWFRAME);
CRect r;
m_cTopBorder.GetWindowRect(&r);
m_cTopBorder.ScreenToClient(&r);
m_cTopBorder.GetWindowRect(&rectArray[0]);
m_cLeftBorder.GetWindowRect(&r);
m_cLeftBorder.ScreenToClient(&r);
m_cLeftBorder.GetWindowRect(&rectArray[1]);
m_cRightBorder.GetWindowRect(&r);
m_cRightBorder.ScreenToClient(&r);
m_cRightBorder.GetWindowRect(&rectArray[2]);
m_cBottomBorder.GetWindowRect(&r);
m_cBottomBorder.ScreenToClient(&r);
m_cBottomBorder.GetWindowRect(&rectArray[3]);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if(pSysMenu != NULL)
{
pSysMenu->RemoveMenu(SC_MOVE, MF_BYCOMMAND);
pSysMenu->RemoveMenu(SC_SIZE, MF_BYCOMMAND);
pSysMenu->RemoveMenu(SC_MAXIMIZE, MF_BYCOMMAND);
}
}
UINT CBmpBkgdTBarButtonsDlg::OnNcHitTest(CPoint point)
{
CPoint ptClient(point);
ScreenToClient(&ptClient);
for(int i = 0; i < 4; i++)
{
if(rectArray[i].PtInRect(ptClient))
return HTCAPTION;
}
return CDialog::OnNcHitTest(point);
}