Getting window pointer of a control

Posted on 2003-02-20
Medium Priority
Last Modified: 2010-04-01
I've placed a text control with ID say IDC_TEST_1. Without using the member variables option, or CEDIT class's Create function how can I get a CWnd pointer for this control.
I know it can be done using CEdit's create function, but is there any way I can get the window pointer provided i only know the ID of the text control?
Question by:motorway
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
LVL 86

Accepted Solution

jkr earned 400 total points
ID: 7987173
In your dialog, you would call

CWnd* pWnd = GetDlgItem ( IDC_TEST_1);
LVL 48

Expert Comment

ID: 7987183
CEdit* pEdit;
pEdit = (CEdit*) GetDlgItem(IDC_TEST_1);

Author Comment

ID: 7991935
I want to show a rectangle on the selected text control. How can i do it?

Author Comment

ID: 7995467
I've tried to show a rectangle over the selected control. But, when I try to move the rectangle using the movewindow() function, the rectangle just disappears. My guess is that I'm not getting the coordinates of the selected control with respect to the dialog containing that control. How can I do it?

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

752 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