Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - CXTPToolBar Dynamic Caption
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPToolBar Dynamic Caption

 Post Reply Post Reply
Author
Message
danpetitt View Drop Down
Senior Member
Senior Member


Joined: 17 July 2005
Location: United Kingdom
Status: Offline
Points: 109
Post Options Post Options   Thanks (0) Thanks(0)   Quote danpetitt Quote  Post ReplyReply Direct Link To This Post Topic: CXTPToolBar Dynamic Caption
    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?
Back to Top
danpetitt View Drop Down
Senior Member
Senior Member


Joined: 17 July 2005
Location: United Kingdom
Status: Offline
Points: 109
Post Options Post Options   Thanks (0) Thanks(0)   Quote danpetitt Quote  Post ReplyReply Direct Link To This Post Posted: 25 July 2006 at 5:32am
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.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 25 July 2006 at 8:39am
Hi,
 
Add update handler for button and call
 
pCmdUI->SetText("Nw Text");
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
danpetitt View Drop Down
Senior Member
Senior Member


Joined: 17 July 2005
Location: United Kingdom
Status: Offline
Points: 109
Post Options Post Options   Thanks (0) Thanks(0)   Quote danpetitt Quote  Post ReplyReply Direct Link To This Post Posted: 25 July 2006 at 2:07pm
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
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 25 July 2006 at 2:24pm
Hi,
It must work.
 
What toolkit version do you have?
May be it is Dialog/ActiveX application?
 
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
danpetitt View Drop Down
Senior Member
Senior Member


Joined: 17 July 2005
Location: United Kingdom
Status: Offline
Points: 109
Post Options Post Options   Thanks (0) Thanks(0)   Quote danpetitt Quote  Post ReplyReply Direct Link To This Post Posted: 25 July 2006 at 3:09pm
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.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 25 July 2006 at 3:24pm
Hi,
Where this toolbar located? On Frame? may be in simple Wnd?
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
danpetitt View Drop Down
Senior Member
Senior Member


Joined: 17 July 2005
Location: United Kingdom
Status: Offline
Points: 109
Post Options Post Options   Thanks (0) Thanks(0)   Quote danpetitt Quote  Post ReplyReply Direct Link To This Post Posted: 25 July 2006 at 3:26pm
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.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 25 July 2006 at 3:31pm
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
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 25 July 2006 at 3:35pm
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
Back to Top
danpetitt View Drop Down
Senior Member
Senior Member


Joined: 17 July 2005
Location: United Kingdom
Status: Offline
Points: 109
Post Options Post Options   Thanks (0) Thanks(0)   Quote danpetitt Quote  Post ReplyReply Direct Link To This Post Posted: 25 July 2006 at 4:21pm
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...
 

Add resource string ID_PROJECT_ADDEXISTINGITEM = "File Open"
 
Then add these:
int CClassViewPane::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)
{
 if (lpCreateControl->nID == ID_PROJECT_ADDEXISTINGITEM)
 {
  lpCreateControl->buttonStyle = xtpButtonIconAndCaption;
  return TRUE;
 }
 return FALSE;
}
 
void CClassViewPane::OnProjectAddexistingitem()
{
 // TODO: Add your command handler code here
}
 
void CClassViewPane::OnUpdateProjectAddexistingitem( CCmdUI *pUI )
{
 pUI->SetText( "Aha oh my word" );
}
 
You will see it truncate.
 
You can then try this (where m_uCount is a var initialised to 0)...
void CClassViewPane::OnUpdateProjectAddexistingitem( CCmdUI *pUI )
{
 CString str;
 str.Format( "%d Aha oh dear", m_uCount++ );
 pUI->SetText( str );
}
 
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.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 26 July 2006 at 9:24am
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
Back to Top
danpetitt View Drop Down
Senior Member
Senior Member


Joined: 17 July 2005
Location: United Kingdom
Status: Offline
Points: 109
Post Options Post Options   Thanks (0) Thanks(0)   Quote danpetitt Quote  Post ReplyReply Direct Link To This Post Posted: 28 July 2006 at 8:36am
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?
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.