Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame
The BCGToolbar LibraryThis article is written as an extension to an excellent toolbar library written by Stas Levin. This article is written with version 5.2 of the library, but take a look at the BCGSoft website for the latest version. I will not get into how you use and install the library.
This article decribes how to add a custom page to the Customisation dialog box, which is displayed when you right click on a toolbar or menu and choose "Customize...” The sample program is based on the sample "CustomPages", which comes with the library. Parts of the code are also based on the BCGSkins sample, which demonstrate how to add skins to your application with the BCGControlBar library. I will not describe the CSkinPage class in detail, but rather describe how to use it.
Getting StartedUse an existing BCGControlBar application or create a new application using the application wizard. Copy the following files to your application directory from the sample project:
The CSkinPage ClassThe page to be added is a CPropertyPage derivative called CSkinPage. It extend CPropertyPage with the methods AddSkin() and SelectSkin().
void AddSkin(LPCSTR szName, LPCSTR szDescription, UINT nIDBitmapPreview);
- szName - The name of the skin as it is displayed in the list.
- szDescription - A short description of the skin, that is displayed below the list with available skins
- nIDBitmapPreview - A bitmap resource to be displayed as a preview when the skin is selected from the list.
Adding the Custom PageIn CMainFrame::OnViewCustomize() insert this code, that will be executed when you choose to customize the toolbars and menus.
CList lstCustomPages; lstCustomPages.AddTail (RUNTIME_CLASS (CSkinPage)); //------------------------------------ // Create a customize toolbars dialog: //------------------------------------ CBCGToolbarCustomize* pDlgCust = new CBCGToolbarCustomize (this, TRUE, // Automatic menus scaning BCGCUSTOMIZE_MENU_SHADOWS | BCGCUSTOMIZE_TEXT_LABELS | BCGCUSTOMIZE_LOOK_2000 | BCGCUSTOMIZE_MENU_ANIMATIONS, // default parameters &lstCustomPages); // ptr to custom prop pages runtime classes pDlgCust->Create (); // Very ugly cast!!! CMyBCGToolbarCustomize* pTemp = (CMyBCGToolbarCustomize*)pDlgCust; // Get a ptr to the skinpage and add some skins CSkinPage* pSkinPage = DYNAMIC_DOWNCAST(CSkinPage, pTemp->GetCustomPageList()->GetHead()); pSkinPage->AddSkin("Office XP", "The new Windows look", IDB_PREVIEW2); pSkinPage->AddSkin("Mac", "That ol\' mac style. For people that just can't let go :-)", IDB_PREVIEW1); pSkinPage->AddSkin("Stas on mushrooms", "A weird and strange windows look, " "that you propably won't stand for long", IDB_PREVIEW3); int iSelectedSkin = theApp.GetInt("ActiveSkin", 0); pSkinPage->SelectSkin(iSelectedSkin);This function does not do anything interesting. The index of the selected skin comes in from the WPARAM parameter and is transferred directly to the SetSkin() function in the application class. Make sure that the order in which you add the skins to the list is exactly the same as the order in which the index is handled in SetSkin() - starting from one, since the first entry always is "<no skin>".
Please note that I'm not in any way connected to BCGSoft, other than I use the library in my daily work.