Solved

InvalidateRect

Posted on 2002-03-18
4
519 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 50 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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

623 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