[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to get a handle to edit control of CComboBox ???

Posted on 2001-08-31
7
Medium Priority
?
3,663 Views
Last Modified: 2013-11-20

 Hello there,
   I created an object of CComboBox with CBS_DROPDOWN style which allows to edit the text.Now I have to implement UNDO functionality in it.But there is no undo method associated with CComboBox.Is there any way to get the handle of Edit Control of it,using which UNDO is possible. If it is not possible.please tell me how to use CComboBoxEx.I tried with that , but it doesn't shows the dropdown list.
please do reply soon.
0
Comment
Question by:Narendra_bt
7 Comments
 
LVL 2

Expert Comment

by:BogdyPtr
ID: 6445782
I don't think it's posible.
To use CComboBoxEx declare a CComboBoxEx var in your window class and after the window was created call Create method for the combobox like in the code below:

m_cbxMyCombo.Create( CBS_DROPDOWN | WS_CHILD | WS_VISIBLE, CRect( 100, 100, 200, 200), this, 1 );    

This should do it.
0
 
LVL 7

Expert Comment

by:jimwasson
ID: 6445832
I think you're looking for GetDlgItem (the MFC version prototype is):
void CWnd::GetDlgItem( int nID, HWND* phWnd ) const

and associated functions GetDlgItemText() and SetDlgItemText.

You can look up the article "Retrieving Data from the Dialog Object" in the Visual Studio help for complete details.
0
 
LVL 1

Expert Comment

by:guoching
ID: 6446709
Since the edit box is a child window of ComboBox,we can use ::ChildWindowFromPoint(HWND,POINT) to get the Handle of Edit.

eg.
POINT ptn;
ptn.x = 2;
ptn.y = 2; //ComboxBox must be larger than two pixel
HWND hEdit = ::ChildWindowFromPoint(combox.m_hWnd,ptn);
0
Technology Partners: 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!

 
LVL 4

Accepted Solution

by:
jtwine100697 earned 150 total points
ID: 6447069
It is undocumented, but ComboBoxes create their edit control with an ID of 1001, so you should be able to use GetDlgItem(...) to get the handle of the edit control:

    CWnd *pCBEdit = m_cbComboBox.GetDlgItem( 1001 );

-=- James.
0
 

Author Comment

by:Narendra_bt
ID: 6447087

Hello James,
 Thanks,it works perfectly.

Narendra
0
 
LVL 2

Expert Comment

by:BogdyPtr
ID: 6447186
I don't know if it's recomanded to use a undocumented facility. It's undocumented because it my change and may not be avable in the next versions of window. But I think that it's a nice solution. jtwinwe where do u find out this ?
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 6447703
> I don't know if it's recomanded to use a undocumented facility. It's undocumented because it my change [...]
> and may not be avable in the next versions of window.

With regard to APIs, that is very true.  But this particular behaviour is not likely to change: it has been this way since at least Windows 3.1.  Changing it risks breaking existing apps.

> But I think that it's a nice solution. jtwinwe where do u find out this ?

You can use Spy to determine the IDs of child windows.  It is also documented in an MFC FAQ somewhere.

-=- James.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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 …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses
Course of the Month19 days, 5 hours left to enroll

834 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