-
August 6th, 2009, 02:37 AM
#1
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.
-
August 6th, 2009, 02:43 AM
#2
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
-
August 6th, 2009, 03:39 AM
#3
Re: How to create "Stylish" toolbar for dialog based applications?
I removed "TBSTYLE_TRANSPARENT | TBSTYLE_FLAT", but it did not work, thank you.
-
August 6th, 2009, 09:22 AM
#4
Re: How to create "Stylish" toolbar for dialog based applications?
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
-
August 6th, 2009, 09:36 AM
#5
Re: How to create "Stylish" toolbar for dialog based applications?
Originally Posted by D_Drmmr
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|