See a description of how to move a form in a non-customer area, both overloading wm_nchittest and returning htcaption. But I think there's something wrong with the right mouse button function. Here I introduce a method, you can already move the form in the client area and the right mouse button function.
1, a new project dlg. Use the default settings.
2. Add Message handler function:
void CDlgDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
PostMessage(WM_NCLBUTTONDOWN,HTCAPTION,MAKELPARAM(point.x,pointy));
CDialog::OnLButtonDown(nFlags, point);
}
3, add right key function. The right mouse button function has been implemented
void CDlgDlg::OnRButtonDown(UINT nFlags, CPoint point)
{
CMenu menu,*sub;
menu.LoadMenu(IDR_MENU1);
sub=menu.GetSubMenu(0);
ClientToScreen(&point);
sub->TrackPopupMenu(TPM_RIGHTBUTTON,point.x,point.y,this);
CDialog::OnRButtonDown(nFlags, point);
}
See source code for other implementation details.
This article supporting source code