CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2001
    Location
    Rotmanka, Poland
    Posts
    88

    Problem with change a toolbar main label

    Hi All !

    I want to change a text what is visible in toolbar when is flyable (this in toolbar label). So I call a method:


    m_wndToolBar.SetWindowText("Ala ma kota");

    But this not efect. I try several methods to update toolbar but I havn't result. I can only manually dock and undock toolbar - int this moment label is update.

    Thnx in advance for any sugastions
    Olekba

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

    Re: Problem with change a toolbar main label

    You should set the text not for the toolbar window but for its parent frame window (when toolbar is floating).
    Try something like this (I am not 100% sure it will work cause I never did it myself) :
    Code:
    if ( m_wndToolBar.IsFloating() ) // only when we float
    {
          m_wndToolBar.GetParent()->GetParent()->SetWindowText("Ala ma kota");
    }
    And don't forget to check the return value for each GetParent() call to be not NULL!

  3. #3
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: Problem with change a toolbar main label

    A toolbar can have 2 states
    • Docked - in this state, the toolbar is attached to one of the frame's edges and moves as the frame is moved. In this state, one cannot see the toolbar's titlebar ( which shows the text ), hence the text is not visible
    • Floating - in this state, the toolbar is shown as a popup window with a title bar and in this state, the frame can be moved without the toolbar moving. In this state, you can see the title. I think this is what you mean by flyable, if I understand you right.

    Now, what is your problem ? Are you trying to change the text and runtime and you see no effect ? However, this statement of yours seems to contradict that
    Quote Originally Posted by olekba
    I can only manually dock and undock toolbar - int this moment label is update.
    Are you saying that when the toolbar is floating, and you change the text, it doesn't take effect immediately, but you have to dock and undock it to see the change ?
    Please explain.

  4. #4
    Join Date
    Sep 2001
    Location
    Rotmanka, Poland
    Posts
    88

    Re: Problem with change a toolbar main label

    VictroN solution work !!! THNX Very Much

  5. #5
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: Problem with change a toolbar main label

    I see.. I think my guess was right..

    Reason:
    The toolbar control as such doesn't have a titlebar. It is a child window hosted inside a frame. When it is docked, the frame is the main frame window that you see. WHen it is floating, the title bar and all that that you see also is a frame and the toolbar is made a child of this popup frame window. The MFC class for this floating frame is CMiniDockFrameWnd. So the text that you see is actually the text of the CMiniDockFrameWnd object.

    Solution:
    Code:
    if(m_wndToolBar.IsFloating())
    {
    	m_wndToolBar.GetParentFrame()->SetWindowText(_T("New text"));
    }
    else
    {
    	m_wndToolBar.SetWindowText(_T("New text"));
    }

  6. #6
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: Problem with change a toolbar main label

    oopps.. I just repeated what VictorN said

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Problem with change a toolbar main label

    Quote Originally Posted by kirants
    oopps.. I just repeated what VictorN said
    ... but more clearly!

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured