Thread: CDialogBar question for MFC

  1. #1
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001

    CDialogBar question for MFC

    Hope you are ready for my slew of questions about MFC.

    The biggest problem I have is using the friggin class wizard because I can never get it to do what I want.

    I have constructed a CDialogBar that uses CBRS_FLOAT_MULTI and CBRS_ALIGN_ANY. The actual dialog control has one button on it labeled btnLoad.

    I understand how to construct the CDialogBar but how do I control the dialog itself. The docs say you normally don't have to derive a class from CDialog for a CDialogBar...but they don't explain why by Load button is not showing up in the main frame window class.

    According to what they are saying the button in the dialog box template used in CDialogBar should show up in my main frame window class and then I just react to the message from that class. But it doesn't show up.

    So do I have to create a class derived from CDialog to control the actual dialog and also create the CDialogBar? I'm sorta lost.

    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
        if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
            return -1;
        if (!m_wndToolBar.CreateEx(this) ||
            TRACE0("Failed to create toolbar\n");
            return -1;      // fail to create
        m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() & ~CBRS_HIDE_INPLACE);
      if (!m_wndDlgBar.Create(this, IDR_MAINFRAME, 
            TRACE0("Failed to create dialog bar\n");
            return -1;        // fail to create
        m_wndDlgBar.EnableDocking(CBRS_FLOAT_MULTI | CBRS_ALIGN_ANY);
      if (!m_wndReBar.Create(this) ||
            TRACE0("Failed to create rebar\n");
            return -1;      // fail to create
        m_wndReBar.SetBarStyle(m_wndReBar.GetBarStyle() & ~CBRS_HIDE_INPLACE);
      if (!m_wndStatusBar.Create(this) ||
            TRACE0("Failed to create status bar\n");
            return -1;      // fail to create
        // TODO: Remove this if you don't want tool tips
        m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
        return 0;
    BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
        if( !CFrameWnd::PreCreateWindow(cs) )
            return FALSE;
        // TODO: Modify the Window class or styles here by modifying
        //  the CREATESTRUCT cs
        return TRUE;
    Problem is when I create a function for OnBtnload() for my CDialog...the button is still greyed out. In fact it's like my code isn't even being linked into the project but it does appear in the project. This is proven by the fact that I can delete the code and the program still runs. So its not even using the code for the dialog. How do I get the class wizard to associate my dialog code with the actual CDialogBar??

    Geez..........Direct3D is a helluva lot easier than this.

    Last edited by VirtualAce; 01-31-2005 at 08:52 AM.

  2. #2
    train spotter
    Join Date
    Aug 2001
    near a computer
    Hmmm....looks OK. Do the same and have seen similar problem when the toolbar buttons don't function as expected but can't remember the solution.

    a save, 'clean' and full rebuild. (could be MSVC error)

    Make sure button is 'enabled' (disabled set to FALSE)? (does the button appear in the resource script and header?)

    Try a isolating the error, eg by changing to different dialog bar, styles ect and/or removing all code that is not esential.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Fixed it. I set it as default button and unchecked notify. Geez MFC is picky eh.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM