[RESOLVED] CMFCToolBar issue: Can't change title?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: [RESOLVED] CMFCToolBar issue: Can't change title?

  1. #1
    Join Date
    Jun 2002
    Location
    Monte Carlo
    Posts
    118

    [RESOLVED] CMFCToolBar issue: Can't change title?

    Visual Studio 2013. C++.

    Created a blank, SDI MFC app.

    I added a new CMFCToolBar (by hand, didn't use a wizard)

    It docks OK. The commands work OK. It renders OK. No problems there.

    In the code, attempting to set the window text of this toolbar has no effect. The title bar text is always "Standard". I triple triple triple checked to make sure I don't have any resource ID conflicts. In a small app as this, it was pretty easy to verify this.

    The toolbar also does not show in the menu illustrated in the screenshot. (The bottom, undocked toolbar should be titled "My Page Bar" and I think it should show up in the popup menu.)
    Name:  ToolBarIssue.jpg
Views: 207
Size:  15.3 KB

    I know I'm probably missing a simple step somewhere, but I haven't seen it. It looks like its getting mixed up with the Standard Toolbar resource ID somewhere but I could see nothing in the .rc or resource.h files. A search yielded a few results with similar problems, but I've had no luck finding out what I'm missing.

    Hope someone can help.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,418

    Re: CMFCToolBar issue: Can't change title?

    Show your code to implement the toolbars.
    Victor Nijegorodov

  3. #3
    Join Date
    Jun 2002
    Location
    Monte Carlo
    Posts
    118

    Re: CMFCToolBar issue: Can't change title?

    Declared as
    CMFCToolBar m_wndPageBar; // MainFrm.h

    In...
    int CMainFrame::OnCreate
    Code:
    	
          if (!m_wndPageBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
    		!m_wndPageBar.LoadToolBar(IDR_PAGEBAR))
    	{
    		TRACE0("Failed to create page toolbar\n");
    		return -1;      // fail to create
    	}
    
    // Setting title
    	CString pageBarTitle;
    	bNameValid = pageBarTitle.LoadString(IDS_PAGEBAR_TITLE);
    	ASSERT(bNameValid);
    	m_wndPageBar.SetWindowText(pageBarTitle);
    
    // Docking Behavior
    	m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
    	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
    	m_wndPageBar.EnableDocking(CBRS_ALIGN_ANY); // Here
    	EnableDocking(CBRS_ALIGN_ANY);
    	DockPane(&m_wndMenuBar);
    	DockPane(&m_wndToolBar);
    	DockPane(&m_wndPageBar); // Here

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,418

    Re: CMFCToolBar issue: Can't change title?

    And what ID did you set for m_wndPageBar? The default one (the same that for m_wndToolBar?
    Try to set some unique ID for m_wndPageBar!
    Victor Nijegorodov

  5. #5
    Join Date
    Jun 2002
    Location
    Monte Carlo
    Posts
    118

    Re: CMFCToolBar issue: Can't change title?

    Is there another source of IDs that I may have overlooked?

    // From Resource.h
    //
    #define IDR_MAINFRAME 128 // This is loaded (m_wndToolBar)
    #define IDR_MAINFRAME_256 129

    // Below is mine
    #define IDR_PAGEBAR 310 // PageBar here..
    #define ID_CANCEL_EDIT_CNTR 32768 // Btn Commands
    #define ID_PAGE_FIRST 32772
    #define ID_PAGE_PREV 32773
    #define ID_PAGE_NEXT 32774
    #define ID_PAGE_LAST 32775
    #define ID_PAGE_ADD 32776
    #define ID_PAGE_DELETE 32777

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,418

    Re: CMFCToolBar issue: Can't change title?

    Quote Originally Posted by mega Kluge View Post
    Is there another source of IDs that I may have overlooked?

    // From Resource.h
    //
    #define IDR_MAINFRAME 128 // This is loaded (m_wndToolBar)
    #define IDR_MAINFRAME_256 129

    // Below is mine
    #define IDR_PAGEBAR 310 // PageBar here..
    And where and how do you set this IDR_PAGEBAR to the toolbar?
    Victor Nijegorodov

  7. #7
    Join Date
    Jun 2002
    Location
    Monte Carlo
    Posts
    118

    Re: CMFCToolBar issue: Can't change title?

    These are the only two references to IDR_PAGEBAR in the entire solution:

    Code:
    mainfrm.cpp(101, 29): !m_wndPageBar.LoadToolBar(IDR_PAGEBAR))
    resource.h(110, 9): #define IDR_PAGEBAR                     310
    And in mainfrm.cpp, it is set/loaded here:
    Code:
    	if (!m_wndPageBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
    		!m_wndPageBar.LoadToolBar(IDR_PAGEBAR))
    	{
    		TRACE0("Failed to create page toolbar\n");
    		return -1;      // fail to create
    	}

  8. #8
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,418

    Re: CMFCToolBar issue: Can't change title?

    I already saw it.
    Therefore I wrote you in the post#4:
    Try to set some unique ID for m_wndPageBar!
    Well, the "unique" in this context should mean IDR_PAGEBAR.
    See MSDN article CToolbat::CreateEx and the last parameter of this method.
    Victor Nijegorodov

  9. #9
    Join Date
    Jun 2002
    Location
    Monte Carlo
    Posts
    118

    Re: CMFCToolBar issue: Can't change title?

    THANK YOU! That solved it 100%!

    I changed the call to:

    Code:
    	if (!m_wndPageBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, 0, IDR_PAGEBAR) ||
    		!m_wndPageBar.LoadToolBar(IDR_PAGEBAR))
    	{
    		TRACE0("Failed to create page toolbar\n");
    		return -1;      // fail to create
    	}
    Rating your post highest and marking this as resolved. Thank you so much for your time. Much appreciated.

  10. #10
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,418

    Re: [RESOLVED] CMFCToolBar issue: Can't change title?

    You are welcome!
    Victor Nijegorodov

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center