Re: Replace Titlebar with Region ?
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_NOZORDER
);
}
bMoveDialog = false;
}
CDialog::OnMouseMove(nFlags, point);
}
void CBitmapBkgdTBarDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
ReleaseCapture();
CDialog::OnLButtonUp(nFlags, point);
}