Link to home
Start Free TrialLog in
Avatar of Smave
Smave

asked on

InvalidateRect

If I understand things correctly, if you want a certain area of a window to be redrawn you call the CWnd::InvalidateRect function.

Question: Given an edit box in a form: How do get the coordinates of said edit box (in the CRect structure) to plug into the CWnd::InvalidateRect function?

Thanx
Ace
Avatar of DanRollins
DanRollins
Flag of United States of America image

Not neccessary.  

You can use Invalidate() or InvalidateRect(0) for the Edit control itself (rather than get a rect for some subset of the screen or some other window).

Also, it is not needed, sinc rhe Edit control updates itself each time its contents change.

But to answer your question, use the GetWindowRect() member function of the control.

-- Dan
Avatar of Smave
Smave

ASKER

GetWindowRect(IDC_EDIT_RecordCNT);

gave me a compiler error.

error C2664: 'GetWindowRect' : cannot convert parameter 1 from 'const int' to 'struct tagRECT *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

Do I need to create a member variable that is a control?

Thanx
Ace
ASKER CERTIFIED SOLUTION
Avatar of DanRollins
DanRollins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
One addition to what Dan Rollins suggested
1)The GetWindowRect returns the postion of the control in terms of screen coordinates, to get the position in terms of client coordinates - call ScreenToClient(rc);

Hope this helps