Re: Taskbar Button and SysMenu ?
Again are you calling CDialog::OnInitDialog in your OnInitDialog method?
I don't understand this code here?
you get the windows rect in screen corrdinates
m_cTopBorder.GetWindowRect(&r);
you convert it to client coordinates of the parent window
m_cTopBorder.ScreenToClient(&r);
then you discard variable r all together and call GetWindowRect with
rectArray[0].
m_cTopBorder.GetWindowRect(&rectArray[0]);
So the final thing in rectArray is screen coordinates, which is no good
Try this
BOOL CBmpBkgdTBarButtonsDlg::OnInitDialog()
{
CDialog::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(&rectArray[0]);
m_cTopBorder.ScreenToClient(&rectArray[0]);
m_cLeftBorder.GetWindowRect(&rectArray[1]);
m_cLeftBorder.ScreenToClient(&rectArray[1]);
m_cRightBorder.GetWindowRect(&rectArray[2]);
m_cRightBorder.ScreenToClient(&rectArray[2]);
m_cBottomBorder.GetWindowRect(&rectArray[3]);
m_cBottomBorder.ScreenToClient(&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);
}
}
AliR.
"cdg" <anyone@anywhere.com> wrote in message
news:PG5ni.173493$Sa4.150400@bgtnsc05-news.ops.worldnet.att.net...
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);
}