mfc >> Moving a Button in a Dialog

by UmFodmlu » Mon, 26 Apr 2004 22:41:01 GMT

I want to move a button in a dialog window but cannot, below are the steps that I am taking when the user makes the BN_CLICKED command

CButton *pBtnOK = (CButton *)GetDlgItem(IDC_BTN)
pBtnOK->GetWindowRect( &Rect )
Rect.left += 1
Rect.right += 1
pBtnOK->MoveWindow( &Rect, TRUE)

Thanks in advance.

mfc >> Moving a Button in a Dialog

by Scott McPhillips [MVP] » Tue, 27 Apr 2004 02:18:11 GMT



GetWindowRect get screen coordinates (position on the screen).
MoveWindow requires client coordinates (position within the parent
window). Use the ScreenToClient function to convert.

--
Scott McPhillips [VC++ MVP]

Similar Threads

1. Automaticall move pointer to the default button in a dialog box

2. Automaticall move pointer to the default button in a dialog bo

That worked.
Thank you very much,
Tim

"AliR (VC++ MVP)" wrote:

> Call SetDefID(IDYES); after you create the button.
> 
> AliR.
> 
> 
> "TOB" < XXXX@XXXXX.COM > wrote in message 
> news: XXXX@XXXXX.COM ...
> >I have the option in the Control Panel for Mouse/ Pointer Options/ Snap To 
> >set
> > So that the mouse pointer automatically moves to the default button in a
> > dialog box.
> >
> > If  have a dialog box with no button in it and I add the line:
> > Create("Yes",WS_VISIBLE|WS_CHILD|WS_TABSTOP|WS_GROUP|BS_DEFPUSHBUTTON,CRect(5,5,50,30),this,IDYES);
> >
> > The mouse will not be moved the Yes Button
> >
> > But if I have the line
> > Create("OK",WS_VISIBLE|WS_CHILD|WS_TABSTOP|WS_GROUP|BS_DEFPUSHBUTTON,CRect(5,5,50,30),this,IDOK);
> > I will move to the button
> > Why and how do I get the mouse to move to the "Yes" button.
> > Thank you,
> > 
> 
> 
> 

3. Moving a dialog to a fixed position within another dialog

4. I don't want to move maximized dialog when I push left mouse button. but it moves.

Dear all,

I tried to maximize dialog in dialog based application. I used
'ShowWindow(SW_MAXIMIZE);'

and

I tried to move dialog around.

I used

::OnLButtonDown(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default

 AfxGetMainWnd()->PostMessage(WM_NCLBUTTONDOWN, HTCAPTION,
MAKELPARAM(point.x,point.y));
 SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENWSE));

// CDialog::OnLButtonDown(nFlags, point);
}


I don't want to move maximized dialog when I push left mouse button. but it
moves.

and I want to move normal dialog uesed 'ShowWindow(SW_RESTORE)' when I push
left mouse button.


5. Closing a child Dialog when the Mouse button is clicked outside the Parent Dialog

6. Locked buttons keep moving off the panel when displayed

I have an inherited form that has two buttons (Done, Canel) which are 
inherited from the base form.  Those buttons are locked.  When I open my 
inherited form the buttons are missing.  It turns out that they exist but 
they coordinates are about 6000 to the right of the form.  If I change the 
coordinates to be back on the form, save the form, lock the controls again, 
then run the form the buttons are missing again with the coordinates that 
again are off the panel.

Does anyone know why this behavior is happening?

-- 
-----------
Thanks,
Steve

7. on button click form moves to the top - CSharp/C#

8. WTL move a button with scroll bar