Is there a way to move the right-most button of a CMFCToolbar to the right most position (of the rect) ?
-
Based on the "Visual C++ 2008 Feature Pack" sample VisualStudioDemo I have a toolbar (CMFCToolbar) in a docking pane (CDockPane) that contains operations to be done on the content of the docking pane. Currently, all the toolbar buttons are "aligned" from the left side; as it is expected when working with a toolbar. Is there a way to move the right-most button in the toolbar to be at the right-most side or the rect (of the toobar) ? for example ( in ascii art) to have something like this (toolbar is between [] )
================================================== | \[button1|button2|button3| button4\] | |------------------------------------------------| | |
The toolbar rect spans the whole width of the docking pane (also resizes when the docking pane resizes) Looking at the CMFCToolbar documentation and code (afxtoolbar.cpp/.h) does not seem to offer some API to do that. So, Am I chasing a wild goose? Thanks. Max.
I'd rather be phishing!
-
Based on the "Visual C++ 2008 Feature Pack" sample VisualStudioDemo I have a toolbar (CMFCToolbar) in a docking pane (CDockPane) that contains operations to be done on the content of the docking pane. Currently, all the toolbar buttons are "aligned" from the left side; as it is expected when working with a toolbar. Is there a way to move the right-most button in the toolbar to be at the right-most side or the rect (of the toobar) ? for example ( in ascii art) to have something like this (toolbar is between [] )
================================================== | \[button1|button2|button3| button4\] | |------------------------------------------------| | |
The toolbar rect spans the whole width of the docking pane (also resizes when the docking pane resizes) Looking at the CMFCToolbar documentation and code (afxtoolbar.cpp/.h) does not seem to offer some API to do that. So, Am I chasing a wild goose? Thanks. Max.
I'd rather be phishing!
Yes, of course... :)
// CYourToolBar : public CMfcToolBar
/*virtual*/ void CYourToolBar::AdjustLocations()
{
__super::AdjustLocations();if (GetSafeHwnd())
{
int iCount(GetCount());
if (iCount)
{
CRect crClient(0, 0, 0, 0);
GetClientRect(crClient);CMFCToolBarButton\* pcButton(GetButton(iCount - 1)); if (pcButton) { CRect crPos(pcButton->Rect()); if (crClient.right > crPos.right) { crPos.OffsetRect(crClient.right - crPos.right, 0); pcButton->SetRect(crPos); UpdateTooltips(); } } }
}
}They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)
-
Yes, of course... :)
// CYourToolBar : public CMfcToolBar
/*virtual*/ void CYourToolBar::AdjustLocations()
{
__super::AdjustLocations();if (GetSafeHwnd())
{
int iCount(GetCount());
if (iCount)
{
CRect crClient(0, 0, 0, 0);
GetClientRect(crClient);CMFCToolBarButton\* pcButton(GetButton(iCount - 1)); if (pcButton) { CRect crPos(pcButton->Rect()); if (crClient.right > crPos.right) { crPos.OffsetRect(crClient.right - crPos.right, 0); pcButton->SetRect(crPos); UpdateTooltips(); } } }
}
}They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)
Excellent !!! plug the code right in and works nearly ok; I have some minoe redraw issue that should be easy to track down. :thumbsup: Thanks.
I'd rather be phishing!