Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

InvalidateRect

Posted on 2002-03-18
4
Medium Priority
?
531 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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 this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

705 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