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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 814
  • Last Modified:

Accessing CEdit in CComboBox

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

Thanks
0
xn12z9i
Asked:
xn12z9i
  • 3
  • 2
1 Solution
 
Tommy HuiCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now