# Visual C++ ShowWindow question



## tim8w (Nov 9, 2004)

I'm working with someone elses code but what I need to do is very simple. There is a dialog and I need to disable a button within it. Here is the Init code for the dialog:


```
void ConnectionDialog::initDialog() {
  HWND box = GetDlgItem(handle, IDC_SERVER_EDIT);

  std::list<char*> mru = MRU::getEntries();
  std::list<char*>::iterator i;

  // I need to disable the button here. It's ID is IDC_OPTIONS
  // I tried:
  //  HWND optionButton = GetDlgItem(handle, IDC_OPTIONS);
  //  optionButton->ShowWindow( SW_HIDE );
  //
  // Locate the combo-box
  // NB: TCharArray converts the supplied char* and assumes ownership!
  for (i=mru.begin(); i!=mru.end(); i++) {
    int index = SendMessage(box, CB_ADDSTRING, 0, (LPARAM)TCharArray(*i).buf);
  }

  // Select the first item in the list
  SendMessage(box, CB_SETCURSEL, 0, 0);
}
```
I tried the following code:


```
HWND optionButton = GetDlgItem(handle, IDC_OPTIONS);
optionButton->ShowWindow( SW_HIDE );
```
but the compiler didn't like it. What am I doing wrong?

Thanks,
Tim


----------



## CarpeDiem (Dec 3, 2004)

You can try:

ShowWindow(optionButton ,SW_HIDE);

If you are using MFC, you can try:

GetDlgItem(handle, IDC_OPTIONS)->ShowWindow(SW_HIDE);


----------



## MacFromOK (Mar 19, 2001)

From the MS SDK:

The EnableWindow function enables or disables mouse and keyboard input to the specified window or control. When input is disabled, the window does not receive input such as mouse clicks and key presses. When input is enabled, the window receives all input. 

BOOL EnableWindow(
HWND hWnd,	// handle to window
BOOL bEnable // flag for enabling or disabling input
);	


Parameters

hWnd:
Identifies the window to be enabled or disabled. 

bEnable:
Specifies whether to enable or disable the window. If this parameter is TRUE, the window is enabled. If the parameter is FALSE, the window is disabled. 

Cheers, Mac


----------

