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
245 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
Comment Utility
You could just call

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

Accepted Solution

by:
DeepuAbrahamK earned 200 total points
Comment Utility
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
Comment Utility
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
Comment Utility
... 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now