|
-
March 21st, 2009, 09:27 PM
#1
How to place a button at the far right of a Toolbar
I have created a toolbar dynamically using the following function :
m_ToolBar->Create(WS_CHILD | WS_VISIBLE | CCS_TOP | CCS_NODIVIDER | TBSTYLE_FLAT | TBSTYLE_TRANSPARENT ,CRect(0,0,0, 0),this,0);
And then adding buttons as follows:
tbbutton[0].iBitmap = 0;
tbbutton[0].idCommand = ID_BUTTON32785;
tbbutton[0].fsState = TBSTATE_ENABLED ;//TBSTATE_ENABLED;
tbbutton[0].fsStyle = TBSTYLE_BUTTON;
tbbutton[0].dwData = 0;
tbbutton[0].iString = 0;
tbbutton[1].iBitmap = 1;
tbbutton[1].idCommand = ID_BUTTON32786;
tbbutton[1].fsState = TBSTATE_ENABLED;//TBSTATE_ENABLED ;
tbbutton[1].fsStyle = TBSTYLE_BUTTON;
tbbutton[1].dwData = 0;
tbbutton[1].iString = 1;
tbbutton[2].iBitmap = 2;
tbbutton[2].idCommand = ID_BUTTON32787;
tbbutton[2].fsState = TBSTATE_ENABLED;//TBSTATE_ENABLED;
tbbutton[2].fsStyle = TBSTYLE_BUTTON;
tbbutton[2].dwData = 0;
tbbutton[2].iString = 2;....
....
....
The above code adds the buttons starting at the top left hand side of the toolbar and then every call to the same structure creates the button in the next right position from the left. What I want to do is to place three buttons starting from the left side going right which is what the code above does on the toolbar then leaving a space and then placing one button at the far right... Is it possible to do this ?
Thanks
Last edited by justmehere; March 21st, 2009 at 09:29 PM.
Reason: more clearity
-
March 22nd, 2009, 01:26 AM
#2
Re: How to place a button at the far right of a Toolbar
I would think the child windows are placed wherever you specified their CRect(left,top,right,bottom) coordinates during creation.
These coords should be relative to its parent starting at the upper left-hand corner (0,0).
-
March 22nd, 2009, 06:00 AM
#3
Re: How to place a button at the far right of a Toolbar
One solution is to insert a separator button before the buttons(s) which you want to place in the right. Then you can resize the separator button to let the required space.
-
March 22nd, 2009, 01:04 PM
#4
Re: How to place a button at the far right of a Toolbar
Thanks sinclaire and ovidiucucu for the reply.
Sinclaire I tried the following code to add one single button to the toolbar which I am assuming is the parent.
m_ToolBar = new CToolBarCtrl;
if(!m_ToolBar)
return false;
m_ToolBar->Create(WS_CHILD | WS_VISIBLE | CCS_TOP | CCS_NODIVIDER | TBSTYLE_FLAT | TBSTYLE_TRANSPARENT ,CRect(0,0,270, 72),this,0);
CButton m_button;
m_button.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, CRect(0,0,72,72), m_ToolBar, ID_BUTTON32785);
It does not work for me in that nothing shows up on the Toolbar control. Please also note that I had commented out all other codes (see original code above) which adds the other buttons so the only button being added is this piece of code.
ovidiucucu can you give me some idea with code on how to go about doing what you had suggested ? I am not sure on how to proceed.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|