Solved

Accessing CEdit in CComboBox

Posted on 1998-03-09
6
737 Views
Last Modified: 2013-11-20
How can I access the edit control of a combo box ? I need to set the ES_READONLY style.

Thanks
0
Comment
Question by:xn12z9i
  • 3
  • 2
6 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 50 total points
ID: 1316841
Then why not use a CBS_DROPLIST?
0
 

Author Comment

by:xn12z9i
ID: 1316842
That seems to do the trick. However, now my recordset won't update to the combo box. Any ideas ?

Thanks!
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 1316843
  Maybe xn12z9i wants to be able to preform clipboard operations on it?

   Try using a value of 1001 (0x3E9) to get the Child Edit Control of a ComboBox.

   
   CEdit   *pWnd = NULL;

   pWnd = (CEdit*)m_cbMyComboBox.GetDlgItem( 1001 );
   if( pWnd )
      pWnd -> SetReadOnly( TRUE );

   
   That will make the edit control ReadOnly.  Note that it will then take on a grey/disabled background.

   Note:  I do not need any lectures on the casting of the CWnd pointer to a CEdit.  I know the dangers, and it is safe for this use.

-=- James.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 4

Expert Comment

by:jtwine100697
ID: 1316844
  The only problem you might have is that the control will look "disabled".  You should be able to subclass the edit control, and then handle its painting, if needed.

-=- James.
0
 

Author Comment

by:xn12z9i
ID: 1316845
Doing the GetDlgItem( 1001 ) did the trick.  Where did you find that particular trick ?  (e-mail me: mccarty.mj@mellon.com)

BTW, does anyone know why the CRecordset did not update the combo box with the CBS_DROPDOWNLIST style ?

Thanks to all !!
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 1316846
  Note that after you accept an answer, people cannot comment without first paying to "see" the answer...

   (I am going to post a question to customer service about this...)

   If you examine the control with Spy++, you will notice that all of the Edit controls of ComboBoxes have the ID of 1001.  That is all there is to it!

-=- James.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 85
tripleUp challenge 7 67
abstract class with all non abstract mentods 6 72
Line meaning 9 77
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 …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now