Custom Buttons Using CDialogBar, CButton, and CControlBar :: MFC
I am trying to implement a basic static toolbar. Here is the design.
- create a dialog box
- add a button (just consider one button for now)
- use CDialogBar to create the dialogbar at construction
- use GetDlgItem(IDC_Button) to get a pointer to the button
Okay. The design above works well. I have two major problems. First, the button does not look like a normal button. The button looks flat and is out of focus. Secondly, I am not sure where to add the message handler for the button.
What I have done is difficult to explain. I hope the brief explanation above is enough. Here is a simple code for it.
if (!m_MyDlgBar.Create(this, IDD_MYDLG, CBRS_BOTTOM, IDD_MYDLG))
TRACE0("Panel creation failed");
m_pButton = reinterpret_cast<CButton *>(m_MyDlgBar.GetDlgItem(IDC_BUTTON));
ShowControlBar(&m_MyDlgBar, TRUE, FALSE);
So basically, I need to somehow set the button to look like a normal button. Secondly, I need to know where to add a message handler for the button.
Okay. The solution is to update the button with ON_COMMAND_UPDATE.