Accessing CEdit in CComboBox

How can I access the edit control of a combo box ? I need to set the ES_READONLY style.

Thanks
xn12z9iAsked:
Who is Participating?
 
Tommy HuiConnect With a Mentor EngineerCommented:
Then why not use a CBS_DROPLIST?
0
 
xn12z9iAuthor Commented:
That seems to do the trick. However, now my recordset won't update to the combo box. Any ideas ?

Thanks!
0
 
jtwine100697Commented:
  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
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
jtwine100697Commented:
  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
 
xn12z9iAuthor Commented:
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
 
jtwine100697Commented:
  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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.