Damn button!
-
I can't seem to disable a button, so that it is showed as grayed-over. However, if I call IsWindowEnabled() after attempting to disable it, it says that it is disabled. Disabling it by setting its property to disabled doesn't work either. It still shows itself as enabled when the app launches. The button is on a dialog-bar, and I attempt to disable it via the following:
m_wndDialogBar.GetDlgItem(IDC_MY_BUTTON)->EnableWindow(FALSE);
Calling UpdateWindow() doesn't seem to help at all either. - John
-
I can't seem to disable a button, so that it is showed as grayed-over. However, if I call IsWindowEnabled() after attempting to disable it, it says that it is disabled. Disabling it by setting its property to disabled doesn't work either. It still shows itself as enabled when the app launches. The button is on a dialog-bar, and I attempt to disable it via the following:
m_wndDialogBar.GetDlgItem(IDC_MY_BUTTON)->EnableWindow(FALSE);
Calling UpdateWindow() doesn't seem to help at all either. - John
I may be wrong here...as always. ;) But... I think your on the right track, but using the wrong thinking. A dialog bar is a dialog...but its not really a Dialog in the normal sense of things. Its really derrived from CControlBar like CToolbar. I think. Try treating your CButton's like standard everyday toolbar buttons and use GetToolbarCtrl. ie:
CToolBarCtrl& myControl = m_wndToolBar.GetToolBarCtrl();
myControl.EnableButton(IDC_MYBUTTON, FALSE);I'm really stabbing at shadows here, so if I'm wrong I never posted this. If I'm right...you bet I posted it. ;) Frank
-
I may be wrong here...as always. ;) But... I think your on the right track, but using the wrong thinking. A dialog bar is a dialog...but its not really a Dialog in the normal sense of things. Its really derrived from CControlBar like CToolbar. I think. Try treating your CButton's like standard everyday toolbar buttons and use GetToolbarCtrl. ie:
CToolBarCtrl& myControl = m_wndToolBar.GetToolBarCtrl();
myControl.EnableButton(IDC_MYBUTTON, FALSE);I'm really stabbing at shadows here, so if I'm wrong I never posted this. If I'm right...you bet I posted it. ;) Frank
-
I can't seem to disable a button, so that it is showed as grayed-over. However, if I call IsWindowEnabled() after attempting to disable it, it says that it is disabled. Disabling it by setting its property to disabled doesn't work either. It still shows itself as enabled when the app launches. The button is on a dialog-bar, and I attempt to disable it via the following:
m_wndDialogBar.GetDlgItem(IDC_MY_BUTTON)->EnableWindow(FALSE);
Calling UpdateWindow() doesn't seem to help at all either. - John
Yeah, Frank had the right idea. Because the button is on a dialog bar, you need to enable/disable it like it was a toolbar button. That is, you need to create an Update UI handler for it in your message map:
ON_UPDATE_COMMAND_UI(IDC_MY_BUTTON, OnUpdateMyButton)
And then in the handler, set the state of the button:
void CMyClass::OnUpdateMyButton(CCmdUI* pCmdUI)
{
if (i_want_the_button_to_be_enabled)
pCmdUI->Enable();
else
pCmdUI->Disable();
}Hope this helps. ------------------------ Derek Waters derek@lj-oz.com