Solved

Accessing CEdit in CComboBox

Posted on 1998-03-09
6
758 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 Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 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