CXTPToolBar Dynamic Caption |
Post Reply |
Author | ||
danpetitt
Senior Member Joined: 17 July 2005 Location: United Kingdom Status: Offline Points: 109 |
Post Options
Thanks(0)
Posted: 24 July 2006 at 6:05pm |
|
I want to change the caption of a button on a toolbar dynamically so it may have more text than the default and thus needs sizing bigger.
How would I go about doing this?
|
||
danpetitt
Senior Member Joined: 17 July 2005 Location: United Kingdom Status: Offline Points: 109 |
Post Options
Thanks(0)
|
|
I have had a good look around the samples and source, and I cant see a simple or workable way of doing this.
Basically I have a process that adds items to a listctrl and I have buttons above to filter the types of entries in the list. The button names show a count of the entries added so they will increment and need to redraw the button.
I am a bit stuck on this, could anyone post some ideas on resolving this for me, thanks.
|
||
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
|
Hi,
Add update handler for button and call
pCmdUI->SetText("Nw Text");
|
||
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
||
danpetitt
Senior Member Joined: 17 July 2005 Location: United Kingdom Status: Offline Points: 109 |
Post Options
Thanks(0)
|
|
I have that, but it doesnt work right:
* It doesnt resize the button so the caption gets truncated
* The toolbar doesnt show the new text until you move the mouse over the toolbar
|
||
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
|
Hi,
It must work.
What toolkit version do you have?
May be it is Dialog/ActiveX application?
|
||
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
||
danpetitt
Senior Member Joined: 17 July 2005 Location: United Kingdom Status: Offline Points: 109 |
Post Options
Thanks(0)
|
|
Nope, brand new MFC Toolkit 10.2, only upgraded and used it a few days ago.
I can see my OnUpdate handlers are being called (I have traced them out), but the buttons arent updating with new text. If I wave the mouse over at least one of the buttons, they are all redrawn.
But the button is not resized when it is drawn ... I have fudged this for now by adding loads of spaces around the default text to ensure its big enough when its created ... bit nasty to do this though.
|
||
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
|
Hi,
Where this toolbar located? On Frame? may be in simple Wnd?
|
||
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
||
danpetitt
Senior Member Joined: 17 July 2005 Location: United Kingdom Status: Offline Points: 109 |
Post Options
Thanks(0)
|
|
I have got the toolbar to redraw by addin a m_wndToolbar.RedrawWindow() after I pUI->SetText in the OnUpdate handlers.
Bit nasty, but it works.
It also still gets truncated if I remove my 'space' padding.
|
||
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
|
Just checked Notifications sample. All work.
replace OnUpdateViewFullscreen in this sample to:
void CNotificationsView::OnUpdateViewFullscreen(CCmdUI* pCmdUI)
{ CWnd* pWnd = GetParent(); LPCTSTR lpszCaption = (pWnd->GetStyle() & WS_MAXIMIZE) != 0? _T("Normal"): _T("Maximized");
pCmdUI->SetText(lpszCaption);
} and you will see.
|
||
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
||
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
|
Hi,
So you have simple CXTPToolBar ... if you don't use CommandBars but create it with CreateToolbar, it can't reposition self. but it send WM_SIZE to parent window when he have to be repositioned. Just cach WM_SIZE and reposition it.
|
||
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
||
danpetitt
Senior Member Joined: 17 July 2005 Location: United Kingdom Status: Offline Points: 109 |
Post Options
Thanks(0)
|
|
I am using a toolbar thats attached to a view pane ... yes, your notifications sample works fine but not in the same context as my app.
Try adding some OnUpdate handlers to the ClassViewPane on the whidbey sample .. its then reproducable...
You will see it truncate.
You can then try this (where m_uCount is a var initialised to 0)...
You will then see that the button doesnt redraw until the mouse is waved over the button.
Hope this helps you reproduce and show me where i am going wrong, thanks. |
||
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
|
Hi,
ok, Dan, you catch me. Indeed in such context it doesn't work. Fixed for 10.3 release.
Here is workaround:
void CClassViewPane::OnUpdateProjectAddexistingitem( CCmdUI *pUI )
{ CXTPControl* pControl = CXTPControl::FromUI(pUI); CString strCaption("Aha oh my word");
if (pControl->GetCaption() != strCaption) { pControl->SetCaption(strCaption); CXTPClientRect rc(this);
SendMessage(WM_SIZE, 0, MAKELPARAM(rc.Width(), rc.Height())); //Recalculate toolbr position. } } |
||
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
||
danpetitt
Senior Member Joined: 17 July 2005 Location: United Kingdom Status: Offline Points: 109 |
Post Options
Thanks(0)
|
|
Wondeful, great news.
What are the plans for 10.3 by the way ... release date, contents etc? Or is it released when it seems that enough has been added/fixed?
|
||
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |