Implementing Docking control Bar in Child Frame

In a multiple view application, sometimes I need to implement different control bars for different views. This article presents how to implement docking control bar in a child frame. Suppose we want to embed a tool bar and a status bar in a child frame. First, declare them in ChildFrm.h:


protected:  // control bar embedded members
	...
	CStatusBar m_wndStatusBar;
	CToolBar m_wndToolBar;
	static UINT indicators[4]; // indicators of status bar


Next, over write CChildFrame::OnCreate(). Create control bars just as we do in CmainFrame.


int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	// TODO: Add your specialized creation code here
	if (!m_wndToolBar.Create(this) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1; // fail to create
	}

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1; // fail to create
	}

	// TODO: Remove this if you don't want tool tips or a resizeable toolbar
	m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
		CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

	// TODO: Delete these three lines if you don't want the toolbar to be dockable
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);
	return 0;
}

Then write the array of status bar' indicators as following:


UINT CChildFrame::indicators[4] =
{
	ID_SEPARATOR, // status line indicator
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
};

Now you can build the project and play with it. However, the menu item "Tool Bar" does not work properly at this stage. When there is any child frame in the main frame, the menu effects the tool bar in the child frame only. You can't toggle the show/hide of the tool bar in the main frame until you close all the child frames. Now I am going to create 2 new menu terms, Main Frame Tool Bar, and Child Frame Tool Bar, to toggle show/hide of the 2 tool bars. Use ClassWizard to add following 2 member functions in CMainFrame.


void CMainFrame::OnViewMainframetoolbar() 
{
	// TODO: Add your command handler code here
	if(m_wndToolBar.IsWindowVisible())
		m_wndToolBar.ShowWindow(SW_HIDE);
	else
		m_wndToolBar.ShowWindow(SW_SHOW);
	this->SendMessage(WM_SIZE, 0, 0);
}

void CMainFrame::OnUpdateViewMainframetoolbar(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_wndToolBar.IsWindowVisible());
}

Similarly add following member functions in CChildFrame.


void CChildFrame::OnViewChildframetoolbar() 
{
	// TODO: Add your command handler code here
	if(m_wndToolBar.IsWindowVisible())
		m_wndToolBar.ShowWindow(SW_HIDE);
	else
		m_wndToolBar.ShowWindow(SW_SHOW);
	this->SendMessage(WM_SIZE, 0, 0);
}

void CChildFrame::OnUpdateViewChildframetoolbar(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_wndToolBar.IsWindowVisible());	
}

Build the project and see how the menu items work. The same technique works for ReBar. If you have any qestion, feel free to drop me a line.

Download demo project - 23KB



Comments

  • GHD produits sont adaptés pour obtenir à peu près n'importe quel genre de style de cheveux parfaite

    Posted by ogrbkr770 on 07/16/2013 07:04am

    Tout d'abord le GHD défrisant pour cheveux IV a peu de concurrence très réaliste, GHD considéré comme un niveau de consommation et professionnels (coiffeurs) comme le numéro un des outils de coiffure. Deuxièmement, le développement de technologies qui réduisent les coûts de production - et ma réponse est que GHD n'est pas allé sur les coûts de production d'ions de réduction au détaillant (propriétaires de salon) et les prix réels des coûts ont augmenté en raison de l'augmentation du prix indicatif. Retours à vide MK1 à Mk3 ont été en vente qu'ils avaient un prix public conseillé de 99 EUR, maintenant GHD MK4 styler a un RRP £ 119 [url=http://ghdpascherfer.webgarden.es/]lisseur ghd pas cher[/url] Est-ce vrai, beaucoup de gens achèteront seulement un redresseur et pas de shampooing et de produits complémentaires. Donc, je ne suis pas sûr de savoir comment cela fonctionne comme une stratégie d'entreprise à long terme, une chose est sûre cependant, c'est que le consommateur est certainement bénéficier de ces marques connues prices.Some réduits sont moins chers, Revlon et Remington, offrant un très bon choix en des alternatives moins chères. Bien qu'ils ne peuvent toujours pas être classés comme pas cher que vous pourriez espérer, mais ils sont encore à moitié prix marque GHD. Ils sont aussi faites de plaques en céramique et tourmaline. Cela verrouille à l'humidité dans vos cheveux et ne se dessèche pas. Ces produits sont excellents car ils sont à double usage, pour le redressage et le curling, ils ne seront pas endommager vos cheveux et céramique dure beaucoup plus longtemps que l'aluminium fait. [url=http://ghdpascherfer.hpage.com/]lisseur ghd pas cher[/url] Quand on sait ghd Norvège peut créer une variété de cheveux de style. Donc, nous voulons tous avoir un tel outil. Pour nous permettre easilycreate boucles et les vagues, ainsi que les cheveux raides parfait. Mais vous savez ce lisseur ghd sont le meilleur choix pour vous. Nous devons choisir lisseur ghd approprié pour vous, plutôt que de suivre le chemin de quelqu'un d'autre de l'acheter.

    Reply
  • Monster Beats Nieuwe hoofdtelefoon, welke je comfortabeler kan maken wanneer je hoort de muziek

    Posted by mrswanzi on 06/06/2013 12:30am

    [url=http://koptelefoon-monsterbeats.tumblr.com/]beats by dre[/url] Met kwaliteits koptelefoons zoals de Monster Beats koptelefoon is het geluid dat de luisteraars te horen vrijwel identiek aan wat de artiesten horen tijdens de oorspronkelijke opnames in de studio. Studio kwaliteit geluiden zijn niet langer voorbehouden alleen voor artiesten en dj¡¯s. Het volledige gamma van Monster Hoofdtelefoon brengt professionele geluidskwaliteit voor de consument, recht in je woonkamer, of onderweg [url=http://koptelefoon-monsterbeats.manifo.com/]Beats by dre Goedkope[/url] koper suggesties aanbevolen dat voor veel mensen de oordopjes gingen "te diep". Echter, niet hebben dat je ophouden. wanneer u een geweldig in vorm te krijgen, de Beats Tour draadloze oordopjes lijken fenomenaal. groene beats by dre studio te koop Ik zou zeer raden het kopen van de Beat Tour als je probeert om een instapmodel beste uitstappen oordopjes af te maken. Beats By Dr. Dre must-have voor de echte muziekliefhebber! [url=http://koptelefoon-monsterbeats.webspawner.com/]beats by dre kopen[/url] Nog voor de headphones voor de consument op de markt verschenen, liepen verschillende grote artiesten uit de Amerikaanse hip hop- en rapscene al met een Beats by Dr. Dre rond. Zo is Lady GaGa in de clip van Pokerface uit 2008 te zien met een Beats by Dr. Dre. Het is slechts een paar tellen, maar na de introductie van de muziekvideo stellen vele fans diezelfde twee vragen: van welk merk is toch die hoofdtelefoon met die rode B en hoe kom ik daaraan Steeds meer artiesten volgden het voorbeeld van LeBron James en Lady GaGa. Niet omdat de hoofdtelefoons significant beter waren dan andere merken, maar puur vanwege de uitstraling: mode.

    Reply
  • What would make life come current to be more colorful of Studio

    Posted by motherdhmm on 06/04/2013 07:13am

    [url=http://www.headphonescheaponlineaustralia.com/]beats by dre[/url] Monstrosity Beats Assignment, Audiophiles would surely frown on of earphones with a bass lift that¡¯s this hefty. But if you attend to electronic music or hip-hop¡ªtwo genres that again piece sounds in the subwoofer sphere, from 20 Hz to with reference to 90 Hz¡ªflat-response earphones, such as the Etymotic ER-4S, are probably not prospering to turn over the sound you want. Contrary to popular creed, not all interchange engineers use upright flat-response monitors in the studio. They usually parallel alongside alternating between pairs that support ignoble halt and ones that boost exorbitant end. In other words, the Tour tandem does not check you from hearing inevitable types of music the way they were meant to be heard. While I relish in the ring from flat-response earphones, I¡¯ll let in that the Tour set of two makes listening to tracks like The Knife¡¯s ¡°Silent Yell¡± a luck of fun. Even on orchestral tracks, like Jonny Greenwood¡¯s lots to There Whim Be Blood, the Junket is a pleasure, boosting the low-end resonance of the orchestra more subtly than you might envision after glancing at the earphones¡¯ frequency-response curve. [url=http://www.headphonescheaponlineaustralia.com/]beats headphones Australia[/url] Miscreation headphones of Kobe Bryant, he is thoroughly engraved on the reminiscence of basketball lovers. Beats on Dre create glaring exhaust of this celebrity purpose to concoct a small copy headphone named Beats not later than Dr. Dre Studio Kobe Bryant Little Version Headphones. There is no doubt that this headphone last will and testament be the with greatest satisfaction seller at present. You can not aside the high-quality of this and the unexcelled mould which prompt our mind. Monster headphones with bruit about canceling technology are on the engraving brim of vogue that spreads nationwide. [url=http://www.headphonescheaponlineaustralia.com/]beats headphones Australia[/url] Starting with the obverse complete, it is unequivocal that the caricature permissible does not stand up to the ¡°tm¡± (trademark) hieroglyph below the word ¡°studio¡± on the bum communistic management corner of the caddy (may be a slight small, but you can conjure up that a not much pamper of passage is missing from the image on the right). At the retaliation of the enclose, you can get a load of that the pictures of the headphones are slightly different. They are positioned minor extent differently. Then there¡¯s also the paucity of the ¡± tm ¡°announcement underneath the¡± studio ¡°word at the bottom heraldry sinister corner.¡± tm ¡°is also missing on the vertical text on the formerly larboard of the crate beneath the not to mince words¡± dre ¡°, and is also missing from the model line of work of the last paragraph of text.

    Reply
  • ghd merchandise returret

    Posted by motherdhmm on 05/30/2013 09:05am

    [url=http://www.buy-beatsdrdre.com/]beats by dre australia[/url] Der er GHD IV styler straightenrs på internettet til handel, lave en vurdering af stræk fleece. Derfor skal vi gøres manuelt, men det er bare for at holde godt for cusomers.ghd glattejern. [url=http://www.blog.cheapbeatsbydre.co.nz/beats-by-dre-headphones]beats by dre headphones[/url] Hurtigt snart efter detoksificering låse, følgende gør nogen forskel i øjeblikket at blive i stand til at eventuelt kunne være blevet tabt hår. De er rent faktisk nødvendigt at undgå vilde hår skade som følge af varme niveau priser pres på grund af type og konstruktion regnfulde og desuden fugtigt krøllede hår. Umiddelbart efter erhvervelse af for at blive udtørret låse, skal du helt oprydning denne bestemte slags, så du kan fjerne troubles sammen med hår. Sørg som head of hår kan være helt helt moderne sammenholdt med gået tabt ved udnytter plus desuden drage fordel med de sande ghd fladjern tekniske personale, overbevisninger protectant. At kunne erhverve til at blive en specifik forsvarende flick, så du kan reducere varme niveau værdier skade bil Frisure plus stil tilgang. Varm temperatur protectant kan også dygtig bo klart af tilfældige krøllede hår anvender op. [url=http://www.blog.cheapbeatsbydre.co.nz/]beats by dre[/url] Når det er sagt, problem fremragende attributter for god hår dage Symbolformatering definitivt virkelig er deres egen person auto

    Reply
  • The activities the competition has been doing in the matter of nike and the things that you want to complete totally different.

    Posted by icoppyapedcap on 04/21/2013 09:26pm

    Ky [url=http://hunter-rain-boots.webnode.jp]レインブーツハンター[/url] eVt [url=http://hunterrainbootsjp.webnode.jp]レインブーツメンズ[/url] u VnyYpf ZqzA [url=http://hunter-boots8.webnode.jp]レインブーツハンター[/url] bt W [url=http://rain-boots-men.webnode.jp]ハンター長靴[/url] lz [url=http://hunter-rain-boots-ja.webnode.jp]レインブーツ人気[/url] NxoUzpTbq Y[url=http://rainshoesja.webnode.jp]ブーツ[/url] jiNqtJokDv [url=http://ja-hunter-rain-boots.webnode.jp]レインブーツハンター[/url] c QprDsr [url=http://rain-boots-popular.webnode.jp]レインブーツメンズ[/url] Njt [url=http://rain-boots-men6.webnode.jp]ハンターレインブーツ[/url] Yyf Sbk [url=http://jahunterrainboots.webnode.jp]ハンターブーツ[/url] Zit

    Reply
  • How to draw the toolbar background?

    Posted by Legacy on 10/10/2003 12:00am

    Originally posted by: zzfa

    I found that your menubar'color differ from toolbar's,Can you tell me how to draw the toolbar background where is no button?
    thank you very much!

    Reply
  • docking toolbar in Windows SDK??

    Posted by Legacy on 05/05/2001 12:00am

    Originally posted by: Shibu J

    How do I add a docking toolbar with images on each button in Windows Platform SDK?

    Reply
  • Toolbar in a view?

    Posted by Legacy on 07/17/1999 12:00am

    Originally posted by: Tesic Goran

    Hi,
    
    

    How can I add toolbar in a CView derived class?

    Thank you beforehand

    Best regards

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • IBM Worklight is a mobile application development platform that lets you extend your business to mobile devices. It is designed to provide an open, comprehensive platform to build, run and manage HTML5, hybrid and native mobile apps.

  • Live Event Date: November 13, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT APIs can be a great source of competitive advantage. The practice of exposing backend services as APIs has become pervasive, however their use varies widely across companies and industries. Some companies leverage APIs to create internal, operational and development efficiencies, while others use them to drive ancillary revenue channels. Many companies successfully support both public and private programs from the same API by varying levels …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds