Click here to Skip to main content
15,906,567 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: An easy one for you pro's... Pin
Brent Lamborn5-Dec-02 9:30
Brent Lamborn5-Dec-02 9:30 
GeneralRe: An easy one for you pro's... Pin
Christian Graus5-Dec-02 9:39
protectorChristian Graus5-Dec-02 9:39 
GeneralHelp with an Array of Controls and message maps Pin
VanHlebar4-Dec-02 13:47
VanHlebar4-Dec-02 13:47 
GeneralRe: Help with an Array of Controls and message maps Pin
Roger Allen5-Dec-02 1:27
Roger Allen5-Dec-02 1:27 
GeneralRe: Help with an Array of Controls and message maps Pin
VanHlebar5-Dec-02 1:48
VanHlebar5-Dec-02 1:48 
GeneralRe: Help with an Array of Controls and message maps Pin
Roger Allen5-Dec-02 3:13
Roger Allen5-Dec-02 3:13 
GeneralRe: Help with an Array of Controls and message maps Pin
VanHlebar5-Dec-02 11:07
VanHlebar5-Dec-02 11:07 
GeneralChanging the toolbar Pin
Rand Al'thor4-Dec-02 12:40
Rand Al'thor4-Dec-02 12:40 
Hi,

I'm creating an app with single document but multiple views.
I'm trying to dynamically change the toolbar as different views are activated.
At the moment, I overwrite the ActivateView() function of each view to make a call to the following function:

BOOL CMainFrame::SetupMainFrameToolbar(UINT ToolbarResourceID, BOOL loadToolbar/* = TRUE */)<br />
{	// Load the toolbar as necessary<br />
	if (loadToolbar == TRUE)<br />
	{	if (!m_wndToolBar.LoadToolBar(ToolbarResourceID))<br />
		{	TRACE0("Failed to create toolbar\n");<br />
			return (FALSE);      <br />
		}<br />
	}<br />
	<br />
	int tempID, location;<br />
	CString stringToDisplay, tempString;<br />
	// Loop through all of the buttons of the toolbar<br />
	UINT ButtonCounter = m_wndToolBar.GetCount();<br />
	for (int index = 0; index < ButtonCounter; index++)<br />
	{	// Get the command ID of the button<br />
		tempID = m_wndToolBar.GetItemID (index);<br />
		// Get the string resource associated with that command ID<br />
		tempString.LoadString(tempID);<br />
		// Find the last string in that resource<br />
		location = tempString.GetLength() - tempString.ReverseFind ('\n') - 1;<br />
		// Cut it and set as the button's title<br />
		stringToDisplay = tempString.Right (location);<br />
		m_wndToolBar.SetButtonText (index, _T((LPCTSTR) stringToDisplay));<br />
	}<br />
<br />
	// change the toolbar size to accomodate the text<br />
	m_wndToolBar.SetSizes (TOOLBAR_BUTTON_SIZE, TOOLBAR_BUTTON_IMAGE_SIZE);<br />
<br />
	if (loadToolbar == TRUE)<br />
	{	// Float and redock this toolbar to recalculate sizes<br />
		FloatControlBar(&(m_wndToolBar), CPoint(50,50));<br />
		DockControlBar (&(m_wndToolBar), AFX_IDW_DOCKBAR_TOP);<br />
	}<br />
	// Recalculate the main frame's layout to position the toolbar appropriately.<br />
	RecalcLayout();<br />
	// Invalidate the window containing the toolbar so it gets redrawn<br />
	m_wndToolBar.InvalidateRect (NULL, TRUE);<br />
	// done correctly<br />
	return (TRUE);<br />
}



As you can see, I was forced to float and redock the toolbar, as AutoSize() doesn't work (it clips my new toolbar to the width of the old toolbar) and RecalcLayout() makes my toolbar buggy (text is only displayed after first a mouse has hovered over the toolbar).

Anybody has ever done this before? Like totally replace the main toolbar everytime a new view is activated?

Help ^^

Big Grin | :-D
GeneralRe: Changing the toolbar Pin
Rand Al'thor4-Dec-02 15:23
Rand Al'thor4-Dec-02 15:23 
GeneralAdd grid control to a dialog Pin
peter ho4-Dec-02 12:35
peter ho4-Dec-02 12:35 
GeneralRe: Add grid control to a dialog Pin
Christian Graus4-Dec-02 15:29
protectorChristian Graus4-Dec-02 15:29 
GeneralRe: Add grid control to a dialog Pin
Kannan Kalyanaraman4-Dec-02 19:18
Kannan Kalyanaraman4-Dec-02 19:18 
GeneralDisabled Pin
Larsson4-Dec-02 12:29
Larsson4-Dec-02 12:29 
GeneralRe: Disabled Pin
tongc4-Dec-02 14:34
tongc4-Dec-02 14:34 
GeneralRe: Disabled Pin
Larsson5-Dec-02 4:03
Larsson5-Dec-02 4:03 
QuestionUtility to scan for unused headers? Pin
Andrew Welch4-Dec-02 12:22
Andrew Welch4-Dec-02 12:22 
GeneralCDatabase Pin
MFC is the Best4-Dec-02 12:03
MFC is the Best4-Dec-02 12:03 
Generalcreating CPropertyPages Pin
mariuszpopiolek4-Dec-02 11:37
mariuszpopiolek4-Dec-02 11:37 
Generalpassing an iterator Pin
Member 1043934-Dec-02 11:34
Member 1043934-Dec-02 11:34 
GeneralRe: passing an iterator Pin
Christian Graus4-Dec-02 11:48
protectorChristian Graus4-Dec-02 11:48 
GeneralRe: passing an iterator Pin
Member 1043934-Dec-02 12:10
Member 1043934-Dec-02 12:10 
GeneralRe: passing an iterator Pin
Christian Graus4-Dec-02 13:34
protectorChristian Graus4-Dec-02 13:34 
GeneralRe: passing an iterator Pin
Member 1043934-Dec-02 13:50
Member 1043934-Dec-02 13:50 
GeneralRe: passing an iterator Pin
Christian Graus4-Dec-02 15:22
protectorChristian Graus4-Dec-02 15:22 
GeneralRe: passing an iterator Pin
Anonymous4-Dec-02 14:26
Anonymous4-Dec-02 14:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.