CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2009
    Posts
    3

    Question How to create "Stylish" toolbar for dialog based applications?

    Hi all,
    I have some problems in creating a toolbar for a dialog based application.
    I added the follow lines in the OnInitDialog function:

    m_imgListToolBar.Create( 16, 16, ILC_COLOR32|ILC_MASK, 8, 8 );
    HICON hToolBarIcon[2];
    hToolBarIcon[0]=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
    m_imgListToolBar.Add(hToolBarIcon[0]);
    hToolBarIcon[1]=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
    m_imgListToolBar.Add(hToolBarIcon[1]);
    m_toolBar.Create( TBSTYLE_WRAPABLE| TBSTYLE_TRANSPARENT | TBSTYLE_FLAT | CCS_TOP | WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE,CRect(0,0,0,0),this, IDR_TOOLBAR );
    m_toolBar.SetBitmapSize(CSize(16,16));
    m_toolBar.SetImageList(&m_imgListToolBar);
    TBBUTTON Buttons[2];
    CString str;

    for( int i=0; i<2; i++)
    {
    str.Format("B%d",i+1);
    Buttons[i].iString=m_toolBar.AddStrings(str);
    Buttons[i].dwData=0;
    Buttons[i].fsState=TBSTATE_ENABLED;
    Buttons[i].fsStyle=TBSTYLE_BUTTON | TBSTYLE_TOOLTIPS;
    Buttons[i].iBitmap=i;
    Buttons[i].idCommand=IDM_ABOUTBOX;
    };
    m_toolBar.AddButtons(2,Buttons);
    m_toolBar.AutoSize();
    m_toolBar.ShowWindow(SW_SHOW);

    This creates a toolbar, but the toolbar is not like those of the SDI and MDI applications whose menus and toolbars seem to share a "Common" style and my toolbar seems to use the style of the parent dialog. I think the uploaded pictures may be more helpful to explain what I mean.

    When I tried to add a rebar, I encountered the same problem.

    Perhaps I missed something, any help will be appreciated, thank you in advance.
    Attached Images Attached Images   

  2. #2
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    2,042

    Re: How to create "Stylish" toolbar for dialog based applications?

    Please put [code][/code] tags around your code.

    Did you try removing these?
    Code:
    	m_toolBar.Create( TBSTYLE_WRAPABLE| TBSTYLE_TRANSPARENT | TBSTYLE_FLAT | CCS_TOP | WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE,CRect(0,0,0,0),this, IDR_TOOLBAR );
    Cheers, D Drmmr

    Please put [code][/code] tags around your code to preserve indentation and make it more readable.

    As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

  3. #3
    Join Date
    Aug 2009
    Posts
    3

    Re: How to create "Stylish" toolbar for dialog based applications?

    I removed "TBSTYLE_TRANSPARENT | TBSTYLE_FLAT", but it did not work, thank you.

  4. #4
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    2,042

    Re: How to create "Stylish" toolbar for dialog based applications?

    What type is m_toolBar?
    Cheers, D Drmmr

    Please put [code][/code] tags around your code to preserve indentation and make it more readable.

    As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

  5. #5
    Join Date
    Aug 2009
    Posts
    3

    Re: How to create "Stylish" toolbar for dialog based applications?

    Quote Originally Posted by D_Drmmr View Post
    What type is m_toolBar?
    CToolBarCtrl m_toolBar;
    CImageList m_imgListToolBar;

    MSDN says: CToolBarCtrl is more suitable for dialog based applications and CToolBar is more flexible.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured