Solved

InvalidateRect

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 111
unable to delete all specified values regedit 38 714
child constructor and parent constructor, overriding and overloading 6 93
Problem to App 4 116
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

762 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