Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

InvalidateRect

Posted on 2002-03-18
4
Medium Priority
?
539 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:Smave
  • 2
4 Comments
 
LVL 49

Expert Comment

by:DanRollins
ID: 6878747
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
0
 

Author Comment

by:Smave
ID: 6878825
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
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 200 total points
ID: 6878868
>> GetWindowRect(IDC_EDIT_RecordCNT);

You should check the online help because that command is wrong in at least two obvious ways.  IDC_EDIT_RecordCNT is just an integer that identifies a control.  

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

no, but if you do, the command would like like:

CRect rc;
m_ctlEdit1.GetWindowRect( & rc );

if you don't create a member-variable control, you could use:

GetDlgItem(IDC_EDIT_RecordCNT)->GetWindowRect( & rc );

But as I said in the other question, the edit control will display the value automatically and does not need to be updated

(Exception: The screeen won't update right away if you do a lot of work in OnInitDialog.  Just set things up and return, otherwise all message processing stops).

-- Dan
0
 
LVL 1

Expert Comment

by:kirthir
ID: 6878992
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

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question