CompuServe Thread

#CDialogBar ctls

2 messages in this thread
#30618From: Bruce McCarrollJul 11, 1994 11:31 PM
I need help in enabling/disabling buttons on a dialog bar: In the header of class CMyFrame (derived from CMDIChildWnd) I define CDialogBar m_dlgBar; The dialog bar is created from a template in int CMyFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) In the view (derived from CScrollView and using CMyFrame) I try to control some buttons void CMyView::OnInitialUpdate() (and elsewhere in CMyView) { …… CDialogBar* pDB = &(((CMyFrame*)GetParentFrame())->m_dlgBar); // THIS NEXT EXPRESSION ADDS LABEL TO BUTTON OK pDB->SetDlgItemText( IDC_ADDSELECT, "Add Item"); // customize button // THIS NEXT EXPRESSION DOES *NOT* GRAY THE BUTTON (pDB->GetDlgItem( IDC_SORT))->EnableWindow( FALSE); …… CScrollView::OnInitialUpdate(); } I should appreciate any help. thanks, bruce
#30637From: Thomas Zeisluft [MVP]Jul 12, 1994 2:57 AM
Bruce, enabling/diabling of controls should be done using MFC's OnUpdateCommandUI mechanism. Add the following to your view: to the .h afx_msg void OnUpdateSortButton(CCmdUI* pCmdUI); and the following to the .cpp //message map entry ON_UPDATE_COMMAND_UI( IDC_SORT, OnUpdateSortButton ) // actual handler void CYourView::OnUpdateSortButton(CCmdUI* pCmdUI) { // TODO: Add your control notification handler code here pCmdUI->Enable( TRUE/FALSE ); // supply argument as needed } Let me know if it doesn't work ! ThomasZ