|
-
September 28th, 2009, 01:47 PM
#9
Re: Why are my dialog bar buttons are disabled?
ovidiucucu,
Thank you for taking the time to post the EnableDlgBar program.
I am ashamed to admit that for years I have been led to believe that it was necessary to derive a class based on CDialogBar in order to initialize the child controls of a dialog bar. I came to this conclusion after reading several articles posted on the subject. You and Arjay are the first to suggest to me that all that added coding is unecessary, at least for my purposes.
It is interesting that the Wizard will not let one add a variable to any of the controls contained in a dialog bar resource that has not had an underlying class defined for that resource. This makes the initialization of the child controls slightly more cumbersome.
Another interesting difference between my old method of adding a class for the dialog bar is that the MainFrame member variable, m_wndDialogBar, no longer functions as a class. While that seems obvious, it becomes a bit of a problem when one tries to disable a dialogbar button using,
Code:
CButton * pButton = (CButton*)m_wndDialogBar.GetDlgItem(IDC_BUTTON_ADD);
pButton->EnableWindow(FALSE);
which no longer works using your method, and one must resort to using the CCmdUI* pCmdUI updating methods (which I now understand what Arjay was saying).
Interestingly, one can initialize all of the necessary dialog bar controls using the following type of CMainFrame initialization:
Code:
void CMainFrame::InitializeDialogBar1()
{
CComboBox * pBox = (CComboBox*) m_wndDialogBar.GetDlgItem(IDC_APPCOMBO);
pBox->AddString("LogOn.key");
pBox->AddString("CSurgRisk.key");
pBox->AddString("MatCalc.key");
pBox->AddString("StudyGroup.key");
pBox->AddString("Noo.key");
pBox->SetCurSel(4);
CEdit * pEdit = (CEdit*)m_wndDialogBar.GetDlgItem(IDC_EDIT1);
CString cs;
cs.Format("9C 50 BE 18 5F 7C 11 27\r\nDE 9A AA 24 1E 1F E6 0D\r\n4B BF E3 11 89 33 8F 0E\r\n29 4E 29 26 E9 EF 38 2B");
pEdit->SetWindowTextA(cs);
}
In short, you have brought me to a new level of programming and I thank you.
Last edited by Mike Pliam; September 28th, 2009 at 01:50 PM.
mpliam
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|