DAC84
DAC84

Reputation: 489

CToolBar at the right corner of the dialog

I am writing an MFC Document-View application with tool bars. I want to add a tool bar at the top-right corner of the mainframe windoiw. Currently i am using below code to set the tool bar

if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP | CBRS_BORDER_RIGHT
    | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
    !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
    TRACE0("Failed to create toolbar\n");
    return -1;      // fail to create
}

The above code will create the tollbar at the top left corner of the mainframe. I want to shifted it from left corner to right corner. I want the tool bar to be in top-right corner.

Options is there in MFC to set tool bar in right side,left side,top and bottom. But there is no option to set it at the top-right

Thanks in advance!

Upvotes: 0

Views: 725

Answers (2)

Mark Ransom
Mark Ransom

Reputation: 308392

You might be able to create another toolbar to the left of your existing toolbar, and leave it empty. Resize it to whatever space is left over.

Sorry but it's been too long since I worked with toolbars to give any details.

Upvotes: 1

DAC84
DAC84

Reputation: 489

As per my knowledge , the only way to do this is by adding dummy buttons in the middle and move the button to the end.

    LPTBBUTTON  newbutton=NULL;
    newbutton=(LPTBBUTTON)calloc(20,sizeof(TBBUTTON));
    int i=0;

    for(i=0;i<20;i++)
    {

        newbutton[i].iBitmap=-1;// for dummy button
        newbutton[i].idCommand=1222;
        newbutton[i].fsState=TBSTATE_ENABLED;
        newbutton[i].fsStyle=TBSTYLE_BUTTON; //TBSTYLE_SEP;
        newbutton[i].iString=-1;

     }
     m_wndToolBar.GetToolBarCtrl().AddButtons(20,newbutton) // this will add 20 new buttons 
     m_wndToolBar.GetToolBarCtrl().MoveButton(1,20);// This will move button from left to right

But the only problem in this model is to adjust the button to handle Maximize option. Need to handle maximize button press and move the button gain to the right.

If there is any option please let me know. Thanks

Upvotes: 0

Related Questions