Trying to move a Button 
Author Message
 Trying to move a Button

Try GetWindowRect() instead. This function gives you screen-relative
coordinates. Then call ScreenToClient() to convert to the window where the
button resides.

--Mark Wing


Quote:
>  I have a CButton on a dialog that I need to move under code control under

certain circumstances.

Quote:
>CButton->MoveWindow(..); works well. The big problem I'm having is in

getting the current coords of the control.

Quote:
>CButton->GetClientRect(..)  has top and left always set to 0.
>How do I find out where a control is relative to the window it is in??

  >      Thanks Michael.


Tue, 04 Dec 2001 03:00:00 GMT  
 Trying to move a Button
you can get the relative to the parent window with the following code
snippet (works for every object derived from CWnd):

// ************

RECT rect;
button.GetWindowRect(&rect);
// now rect contains your desired coordinates

button.MoveWindow(&rect);

// ************

hope this helps...

see ya,
peterco

Quote:
> I have a CButton on a dialog that I need to move under code control under

certain circumstances.
Quote:

>CButton->MoveWindow(..); works well. The big problem I'm having is in

getting the current coords of the control.
Quote:

>CButton->GetClientRect(..)  has top and left always set to 0.

>How do I find out where a control is relative to the window it is in??

>         Thanks Michael.



Tue, 04 Dec 2001 03:00:00 GMT  
 Trying to move a Button
i'm not so sure... GetWindowRect returns screen coords meaning that the
coords in rect are relative to the upper left corner of the screen not the
parent window..
to get this to work you have to call MapWindowPoints or ScreenToClient to
convert from screen coords to parent window coords...


Quote:
> you can get the relative to the parent window with the following code
> snippet (works for every object derived from CWnd):

> // ************

> RECT rect;
> button.GetWindowRect(&rect);
> // now rect contains your desired coordinates

> button.MoveWindow(&rect);

> // ************

> hope this helps...

> see ya,
> peterco


> > I have a CButton on a dialog that I need to move under code control
under
> certain circumstances.

> >CButton->MoveWindow(..); works well. The big problem I'm having is in
> getting the current coords of the control.

> >CButton->GetClientRect(..)  has top and left always set to 0.

> >How do I find out where a control is relative to the window it is in??

> >         Thanks Michael.



Fri, 01 Feb 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Trying to move a Button

2. Try this one Moving VB SQL statement to visual c++

3. I need vc ide macro help, trying to create a move to end of word macro

4. Trying to move From VB to VC

5. I need vc ide macro help, trying to create a move to end of word macro

6. Still trying to move a string from one list box to another

7. WTL move a button with scroll bar

8. Moving a button.

9. redrawing while mouse button is moving

10. Move, resize button in CPropertySheet

11. CFileDialog move Buttons and Combobox

12. Move a button in the CView

 

 
Powered by phpBB® Forum Software