CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: CMFCToolBar::ReplaceButton() has no effect

  1. #1
    Join Date
    Oct 2014
    Posts
    1

    CMFCToolBar::ReplaceButton() has no effect

    actually I want to solve a quite simple thing, but I spent already the whole day...now I am running out of ideas!

    The requested behaviour: depending on program state I want to display different buttons at the Toolbar.

    At first step, I tried to exchange a button in CMainFrame::OnCreate(...) !! It is a SDI sample

    Code:
       
    {
          CMFCToolBarButton     button(ID_ONLINE,IDB_GO_ONLINE,(LPCTSTR)"ONLINE");
    
    		int ret = m_wndToolBar.ReplaceButton(ID_ONLINE,button);
          TRACE("%d",ret);
       }
    the retcode '1' says, that button is exchanged, but nothing happened. The original button image and text from resource toolbar is still displayed.
    Hint: the IDB_GO_ONLINE ID is the ID of a bitmap resource, which I have created with same size and resolution than toobar (16x15,24 Bit)

    Could anybody help?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,725

    Re: CMFCToolBar::ReplaceButton() has no effect

    Did you try CMFCToolBar::AdjustLayout or CMainFrame::RecalcLayout?
    Victor Nijegorodov

  3. #3
    Join Date
    Nov 2014
    Location
    Near Kiel
    Posts
    1

    Re: CMFCToolBar::ReplaceButton() has no effect

    I have struggled with the same issue. In my case the solution was to replace LoadToolBar with LoadToolBarEx.

    Meaning instead of
    m_wndToolBar.LoadToolBar((theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME)

    use
    CMFCToolBarInfo params;
    ...
    m_wndToolBar.LoadToolBarEx(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME, params, TRUE)

    Kind Regards
    Alex

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




On-Demand Webinars (sponsored)