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
257 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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…
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.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

626 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