I have used the following codes to move window and paint the background window now when I move window to edges of the screen the background of my application which is a picture of bitmap type gets disturbed.How to solve this problem?
void CDemoDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
CRect myRect;
GetWindowRect(&myRect);
GetCursorPos(&point);
SendMessage(WM_NCLBUTTONDOWN, HTCAPTION, 0);
__super::OnLButtonDown(nFlags, point);
}
void CDemoDlg::OnMouseMove(UINT nFlags, CPoint point)
{
CRect myRect;
GetWindowRect( &myRect);
CPoint curpoint;
GetCursorPos(&curpoint);
{
MoveWindow(curpoint.x - point.x, curpoint.y - point.y,
myRect.right - myRect.left, myRect.bottom - myRect.top, TRUE);
}
__super::OnMouseMove(nFlags, point);
}
void CDemoDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this);
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CPaintDC dc(this);
CRect rect;
GetClientRect(&rect);
BITMAP bmp;
HBITMAP hBmp = ::LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_MAIN_BG));
::GetObject(hBmp, sizeof(bmp), &bmp);
HDC hDC = ::CreateCompatibleDC(NULL);
SelectObject(hDC, hBmp);
::BitBlt(dc.m_hDC, 0, 0, rect.Width(), rect.Height(), hDC, 0, 0, SRCCOPY);
CDialog::OnPaint();
}
}
Its causing problem when I move the app with mouse event out side the screen Limits. How can I stop the app edges crossing the screen limits.