Solved

Accessing CEdit in CComboBox

Posted on 1998-03-09
6
747 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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…
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.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

895 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

13 Experts available now in Live!

Get 1:1 Help Now