Click here to Skip to main content
15,906,467 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The following code segment is part of the OnCreate Handler of an MFC application whose starting codes were generated by wizard.
(The code is not well formatted. I don't ever see the Question Formating code bar when I try to post a question any longer).


C++
m_wndToolBar is a member of type CMFCToolBar.


int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
     .
     .
     .
     .

     if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");

		HCURSOR hCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW); 
		SetCursor(hCursor);
		return -1;      // fail to create
	}
        
     //I attempted to add a separator and change button style but nothing happened
	int iCount = m_wndToolBar.GetCount();
	m_wndToolBar.InsertSeparator(8);

	for(int i = 9; i < iCount; i++)
	{
		m_wndToolBar.SetButtonStyle(i,TBBS_SEPARATOR);
	}
        .
        .
        .
        .
        .
}
Posted
Updated 30-Jan-16 5:55am
v2
Comments
Kornfeld Eliyahu Peter 30-Jan-16 14:29pm    
Read the note on this page: https://msdn.microsoft.com/en-us/library/w13yte29.aspx

1 solution

In earlier times I got lots of trouble with that, so my experience is that you better re-create the toolbar.

I had done this mostly be creating the toolbar WITH ALL FEATURES, and deleted the un-wanted stuff.

It is some code, but: it works. ;-)
 
Share this answer
 
Comments
Gbenbam 8-Feb-16 20:55pm    
Can you show me a snippet of the code with which you did it?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900