
How do I Enable / Disable button in Dialog Bar?
Rick,
Your CMainFrame needs to have something like
ON_UPDATE_COMMAND_UI(IDC_BUTTON1, CMainFrame::OnUpdateButton1)
wherein you would put stuff like
void CMainFrame::OnUpdateButton1(CCmdUI *pCmdUI)
{
CString editText; // text in edit box
// get text from edit box
m_wndMyDialogBar.GetDlgItem(IDC_EDIT1)->GetWindowText(editText);
// enable button if there is any text in the edit box
pCmdUI->Enable(editText.GetLength());
Quote:
}
Quote:
> I have a dialog bar that I inserted into my program. It consists of a
push
> button and an Edit Box. I'm trying to figure out how to disable the push
button
> when there are no characters in the Edit Box and enable it when there
are. I'm
> handling the ON_EN_CHANGE message for the Edit Box with the following
code. It
> checks if the Edit Box has text, it gets the window handle of the button
and
> disables/enables the button. I can see the button "flash" for a brief
moment,
> but it never disables. What is keeping the button enabled and how can I
disable
> it???
> void CMainFrame::OnChangeEdit1()
> {
> CString strFubar;
> m_wndMyDialogBar.GetDlgItemText(IDC_EDIT1,strFubar);
> if (strFubar.IsEmpty()) // Disable pushbutton if string is empty
> m_wndMyDialogBar.GetDlgItem(IDC_BUTTON1)->EnableWindow(FALSE);
> else
> m_wndMyDialogBar.GetDlgItem(IDC_BUTTON1)->EnableWindow(TRUE);
> }