Custom Buttons Using CDialogBar, CButton, and CControlBar :: MFC

This is a discussion on Custom Buttons Using CDialogBar, CButton, and CControlBar :: MFC within the Windows Programming forums, part of the Platform Specific Boards category; Hi. I am trying to implement a basic static toolbar. Here is the design. - create a dialog box - ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348

    Custom Buttons Using CDialogBar, CButton, and CControlBar :: MFC

    Hi.

    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.

    -----
    CDialogBar m_MyDlgBar;
    CButton *m_pButton;

    int CMainFrame::OnCreate()
    {
    ...
    if (!m_MyDlgBar.Create(this, IDD_MYDLG, CBRS_BOTTOM, IDD_MYDLG))
    {
    TRACE0("Panel creation failed");
    return -1;
    }

    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.

    Thanks,
    Kuphryn

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Okay. The solution is to update the button with ON_COMMAND_UPDATE.

    Kuphryn

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21