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

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

Title # Comments Views Activity
Parsing XML instructions in Java/any other language.... 3 116
C++ Language error 28 245
FMX enumerated colours 2 115
Unresolved External Symbols 3 105
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

861 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