Solved

Can someone tell me how to disable and make them look grey for the ComboBox and the Text control?

Posted on 2007-03-20
4
256 Views
Last Modified: 2008-02-01
Can someone tell me how to disable and make them look grey for the ComboBox and the Text control?  Is there such message that I would send to the control?  Thanks.
0
Comment
Question by:lapucca
  • 2
4 Comments
 
LVL 86

Assisted Solution

by:jkr
jkr earned 100 total points
ID: 18761263
You could just call

::EnableWindow(hWndControl, FALSE);
0
 
LVL 11

Accepted Solution

by:
DeepuAbrahamK earned 200 total points
ID: 18762281
If you are using MFC:

CWnd* pWndParent = GetParent();
CWnd* pWnd = pWndParent->GetDlgItem(IDC_EDIT1);
pWnd->EnableWindow(FALSE);

Otherwise use:

BOOL EnableWindow(HWND hWnd,BOOL bEnable);

Best Regards,
DeepuAbrahamK
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 18762325
If you designed your dialog form with a resource editor, e. g. in Visual Studio, you can set each control (combobox or textcontrol) to being (initially) disabled (deactivated) what means they are grey until they get enabled. (static) text controls often have no specific ID but only IDC_STATIC (what is -1). if you want to enable/disable a static text control you should replace IDC_STATIC by a specific text id, e. g. IDC_STC_MYTEXT. If done so, you can use your hander for the WM_INITDIALOG message - in MFC it is the overloaded member function YourDialog::OnInitDialog() to enable or disable controls.The most easiest way to do that is to add a member variable for each control what can be done in the resource editor. Say you have

class YourDialog : public CDialog
{
    ...
public:
        CComboBox m_cmbCompute;
        CStatic


};
0
 
LVL 39

Assisted Solution

by:itsmeandnobodyelse
itsmeandnobodyelse earned 200 total points
ID: 18762337
... continued

class YourDialog : public CDialog
{
    ...
public:
        CComboBox m_cmbCompute;   // generated by class wizard
        CStatic          m_stcMyText;    // generated by class wizard
    ....


then in OnInitDialog you can do:

void YourDialog::OnInitDialog()
{
       ...
       m_cmbCompute.EnableWindow(FALSE);  // disable combobox
       m_stcMyText.EnableWindow(FALSE);   // disable static text

      return FALSE;
}

You normally would enable the controls in some other handler of your dialog, e. g. when a button was clicked or some entry of another combobox was selected.

Regards, Alex
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

733 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