Re: Replace Titlebar with Region ?
It sounds like a good suggestion, but now it seems I am not sure "how to"
determine if the mouse is in draggable area. Even only a small area similar
to a standard titlebar.
I tried the code below, and it's not correctly working. I used a "simple"
static control set to notify, and this is probably not the right approach.
Because I can only drag the dialog after I clicked the hidden control area,
then reclick anywhere in the dialog to drag. And I needed only this border
to be the draggable area. Also, I cannot drag from the control area at all
after it has been clicked.
I would prefer using OnNcHitTest( ), but I am not sure how to determine
the draggable area.
***
class CBitmapBkgdTBarDlg::
bMove;
***
void CBitmapBkgdTBarDlg::OnTitlebar()
{
bMove = true;
}
void CBitmapBkgdTBarDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
if(bMove)
PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x,point.y));
bMove = false;
CDialog::OnLButtonDown(nFlags, point);
}
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
news:266i93l60munna7snjuebo30at9toteqoq@4ax.com...
UINT CMyClass::OnNcHitTest(...)
{
determine if mouse is in a draggable area
if(indraggablearea)
return HTCAPTION;
else
return CWhateverSuperclass::OnNcHitTest(...)
}
joe
On Sat, 14 Jul 2007 17:02:19 GMT, "cdg" <anyone@anywhere.com> wrote:
I tried your code suggestion with a few modifications for a program
that
has a border (about the width of a standard titlebar) around the entire
dialog. And this border would be the only draggable area.
However, it is not dragging the dialog. Do you know of any other code
or
approach for doing this, or do see any problems with the code below.
***
class CBitmapBkgdTBarDlg
private:
CPoint pStartPoint;
bool bMoveDialog;
***
void CBitmapBkgdTBarDlg::OnTitlebar()
{
bMoveDialog = true;
}
void CBitmapBkgdTBarDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
pStartPoint = point;
CDialog::OnLButtonDown(nFlags, point);
}
void CBitmapBkgdTBarDlg::OnMouseMove(UINT nFlags, CPoint point)
{
if(bMoveDialog)
{
SetCapture();
if(nFlags & MK_LBUTTON && pStartPoint.x >= 0 && pStartPoint.y >=
0)
{
CPoint diff = point - pStartPoint;
CRect rect;
GetWindowRect(rect);
rect.OffsetRect(diff);
SetWindowPos(NULL,rect.left,rect.top,rect.Width(),rect.Height(),SWP_NOZORDE
R
);
}
bMoveDialog = false;
}
CDialog::OnMouseMove(nFlags, point);
}
void CBitmapBkgdTBarDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
ReleaseCapture();
CDialog::OnLButtonUp(nFlags, point);
}
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm