Moving a Dialogbox
-
Hi, how kan i mov a Dialogbox without a titlelist? Is just normal Dialogwindow without a titlelist and system menue, i kan only move, replace, them in the screen when is a titlelist created? :( i think on a event like OnMouseDown or somethink like this, is there any API or Function for this? thanx mirsad
-
Hi, how kan i mov a Dialogbox without a titlelist? Is just normal Dialogwindow without a titlelist and system menue, i kan only move, replace, them in the screen when is a titlelist created? :( i think on a event like OnMouseDown or somethink like this, is there any API or Function for this? thanx mirsad
hmmm.....i had the same prob.....though i can move the dialog where i want to it still doesnt move the way it does as it does in the windows dialog...... well thiz is what i have done..... sense for the drag of the mouse,whenever the mouse is dragged use the SetWindowPos() function..... here is the coding i have used in the in OnMouseMove() function......
void CxyzDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call defaultif(m\_DragOn==TRUE) { CPoint point1=point; ClientToScreen(&point1); this->SetWindowPos(&CWnd::wndTop ,point1.x-473,point1.y-23,0,0, SWP\_SHOWWINDOW|SWP\_NOSIZE); }//end of if(m\_DragOn==TRUE) CDialog::OnMouseMove(nFlags, point);
}
please note that the m_DragOn is set to ONE on the OnLButtonDown()function and set to zero on the OnLButtonUp() function..... also note that in the SetWindowPos() function i have changed the value of the x cordinate by 473 and y cordinate by 23(which happenz to make the mouse pointer to point to the center of my dialog)....u will have to set the value accordingly!!!!! ps:there definitely an another way to do it,but i guess thiz gives a good result as well..... hope thiz helpz ...... cheerz.....:-D "faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
-
hmmm.....i had the same prob.....though i can move the dialog where i want to it still doesnt move the way it does as it does in the windows dialog...... well thiz is what i have done..... sense for the drag of the mouse,whenever the mouse is dragged use the SetWindowPos() function..... here is the coding i have used in the in OnMouseMove() function......
void CxyzDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call defaultif(m\_DragOn==TRUE) { CPoint point1=point; ClientToScreen(&point1); this->SetWindowPos(&CWnd::wndTop ,point1.x-473,point1.y-23,0,0, SWP\_SHOWWINDOW|SWP\_NOSIZE); }//end of if(m\_DragOn==TRUE) CDialog::OnMouseMove(nFlags, point);
}
please note that the m_DragOn is set to ONE on the OnLButtonDown()function and set to zero on the OnLButtonUp() function..... also note that in the SetWindowPos() function i have changed the value of the x cordinate by 473 and y cordinate by 23(which happenz to make the mouse pointer to point to the center of my dialog)....u will have to set the value accordingly!!!!! ps:there definitely an another way to do it,but i guess thiz gives a good result as well..... hope thiz helpz ...... cheerz.....:-D "faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
If I understand your question, Handle the WM_NCHITTEST. Write the following code in OnNcHitTest(CPoint point) { CRect rect; GetClientRect(&rect); ClientToScreen(&rect); if (rect.PtInRect(point)) return HTCAPTION; return CDialog::OnNcHitTest(point); } Good code for life.
-
If I understand your question, Handle the WM_NCHITTEST. Write the following code in OnNcHitTest(CPoint point) { CRect rect; GetClientRect(&rect); ClientToScreen(&rect); if (rect.PtInRect(point)) return HTCAPTION; return CDialog::OnNcHitTest(point); } Good code for life.
-
hi, @rateep thanx for the great help! That is what i need! @khan++, i kant find the WM_NCHITTEST event in my Class Wizard :( thanx mirsad
mirso67 wrote: kant find the WM_NCHITTEST event in my Class Wizard Switch MessageView of Your Windows Message Handller from Dialog to Windows, you wil find this option in
combobox
situated atbottom-right
ofWindow Message Handller
Wizard
[Vote One Here, Complete my Survey....] Alok Gupta
visit me at http://www.thisisalok.tk "I Think Believe this Will Help" -
mirso67 wrote: kant find the WM_NCHITTEST event in my Class Wizard Switch MessageView of Your Windows Message Handller from Dialog to Windows, you wil find this option in
combobox
situated atbottom-right
ofWindow Message Handller
Wizard
[Vote One Here, Complete my Survey....] Alok Gupta
visit me at http://www.thisisalok.tk "I Think Believe this Will Help" -
Hi, how kan i mov a Dialogbox without a titlelist? Is just normal Dialogwindow without a titlelist and system menue, i kan only move, replace, them in the screen when is a titlelist created? :( i think on a event like OnMouseDown or somethink like this, is there any API or Function for this? thanx mirsad
-
Simply Add this code to WM_LBUTTONDOWN event : void CYourDialog::OnLButtonDown(UINT nFlags, CPoint point) { CDialog::OnLButtonDown(nFlags, point); PostMessage( WM_NCLBUTTONDOWN, HTCAPTION,MAKELPARAM( point.x, point.y)); } Thats it!!! m0n0