单击对话框的任何地方都能拖动对话框

单击对话框的任何地方都能拖动对话框

 

This  is  how you create a dialog that can be dragged by clicking anywhere on it, ie. not just the caption bar. 


void  CNCHitDlg::OnLButtonDown(UINT nFlags, CPoint point) 
{
 CDialog::OnLButtonDown(nFlags, point); 
 
// fake windows into thinking your clicking on the caption, does not
 
// maximize on double click
 PostMessage( WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM( point.x, point.y));
}
 

or 

UINT CNCHitDlg::OnNcHitTest(CPoint point) 
{
 UINT nHitTest 
= CDialog::OnNcHitTest( point );
 
// also fake windows out, but this maximizes the window when you double
 
// click on it. 
 return (nHitTest == HTCLIENT) ? HTCAPTION : nHitTest;
}



你可能感兴趣的:(单击对话框的任何地方都能拖动对话框)