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
250 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Grammars for C C++ and java 1 122
Should CArray be used for a list of pointers in C++? 19 102
sorting efficency of sorting algorithm 30 112
VS2015 Redefinition errors 4 47
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

786 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