Click to See Complete Forum and Search --> : Non Client Messages


VermaV
April 30th, 1999, 01:51 AM
Hi,

I developed a small application where I converted the client mouse messages to non-client mouse messages. Here is how I did it :


void CMoveWinView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_fDragging=TRUE;
AfxGetMainWnd()->SendMessage(WM_NCLBUTTONDOWN,HTCAPTION,0);
CView::OnLButtonDown(nFlags, point);
}

void CMoveWinView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (m_fDragging)
AfxGetMainWnd()->SendMessage(WM_NCMOUSEMOVE,HTCAPTION,0);

CView::OnMouseMove(nFlags, point);
}

void CMoveWinView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_fDragging=FALSE;
AfxGetMainWnd()->SendMessage(WM_NCLBUTTONUP,HTCAPTION,0);
CView::OnLButtonUp(nFlags, point);
}





The problem is that it worked fine !!!
I passed the mouse co-ordinates as 0 in SendMessage but still the frame window is moved correctly when we drag in client area!!
Any of the brainy code gurus out there .... please explain!!

Vishal

Playman Cheng
April 30th, 1999, 03:38 AM
The answer is there is not some intelligent code generated.When you send the WM_NCLBUTTONDOWN to
the main window,the window capture the mouse,so the mouse messages are all sended to the main window until the mouse button is up,that is,your
view's OnMouseMove and OnLButtonUp is not executed
at all.I think this is the answer,your idea?

VermaV
April 30th, 1999, 05:18 AM
Thanx for the answer, it helped but I have a doubt, rather another question :

How does the Frame window handle mouse co-ordinates. When the mouse is in the client area how does the frame window treat it relative to the caption bar ?

Vishal