Skin Customization Page for the BCGControlBar Library

.

The BCGToolbar Library

This 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 Started

Use 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:
  • Macstyle.*
  • Funnystyle.*
  • MyVisualManager.*
  • SkinPage.*
Also add the necessary resources from the .RC file.

The CSkinPage Class

The 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);

Return Value

None

Parameters

  • 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.

Remarks

None

Adding the Custom Page

In 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>".

That's it! Go ahead and try it out. If you are not familiar with the BCGControlBar library go ahead and download a copy. The library are free to use for freeware develpment, and quite inexpensive for commercial applications compared to similar libraries like the ones from Stingray and Dundas. Keep up the good work Stas!!

Please note that I'm not in any way connected to BCGSoft, other than I use the library in my daily work.

About the Author

Christian Skovdal Andersen is a co-owner of a small software company in Denmark, Europe, specialised in telephony- and windows development. He is into MFC/ATL programming, and enjoys writing an article now and then. Be sure to visit my Web site (in Danish) to see many more technical articles, code and tips.

Downloads

Download demo - 139 Kb


Comments

  • This is spam !!!

    Posted by Legacy on 01/24/2004 12:00am

    Originally posted by: Tina

    I am getting sick and tired of this ****!
    If you want to promote somebody elses written stuff, which is not even open source and has NAG SCREEN then do it somewhere else!
    Some of us would actualy like to know how to do things ourselves not to pay like 600 USD.
    Then I would not come to this site in first place!

    FOR ME....THIS IS SPAM!

    And do it somewhere else!

    Reply
  • http://www.codejock.com

    Posted by Legacy on 06/08/2003 12:00am

    Originally posted by: The Best Tools On The NET - VS.NET and Office XP/2003 GUI!

    http://www.codejock.com

    Reply
  • Why reinventing the wheel?

    Posted by Legacy on 01/17/2003 12:00am

    Originally posted by: Brasil Carnival

    The best think I've ever seen for skinning (and used since) is an ActiveX control (don't yell:-)) called ActiveSkin from www.Softshape.com.
    Bad part is that it doesn't skin the common window dialogs. If you buy a plug-in to it, SkinBoxer from http://smartbrainsoftware.com you can EVEN skin the default windows (common dialog windows like mesasgeBox, Open/Save dlg, etc). Never been able to skin those since now.
    All together, best packege ever! Yoohoo!!

    Reply
  • compiling error

    Posted by Legacy on 03/14/2002 12:00am

    Originally posted by: Edgardo

    'bcgcb.h' this file is missing on your demo?

    Reply
  • BCGToolBar Skin

    Posted by Legacy on 09/21/2001 12:00am

    Originally posted by: mack

    Resource leak in the download!

    Help

    Thanks,

    Reply
  • Form++ Library(With Full MFC Source Code)

    Posted by Legacy on 08/29/2001 12:00am

    Originally posted by: Steven zhang

    Form++ Library provides Microsoft Foundation Class (MFC)/Visual C++ developers with a complete library of MFC extension classes which implement a drag and drop (e.g. VC,VB Form Editor) graphical interface. These classes fill many of the holes existing in the Windows Graphics Device Interface (GDI) and allow developers to incorporate custom graphical objects and enhanced drawing capabilities into their applications. All of these classes fit seamlessly with MFC, and inherit many of MFC's existing classes. Easily give your application a new look in minutes!
    http://www.ucancode.net

    Reply
  • Asserts Mushroom skin

    Posted by Legacy on 03/15/2001 12:00am

    Originally posted by: Steve Quick

    In the customize dialog, select the Mushroom skin, close the dialog and redisplay the dialog. The following asserts:

    // Function name : CSkinPage::SelectSkin
    // Description : Set the skin that is currently active
    // Return type : void - none
    // Argument : int iSkin -- index of the skin as it is used in the BCGM_NEWSKIN handler
    void CSkinPage::SelectSkin(int iSkin)
    {
    ASSERT(iSkin>=0);
    ASSERT(iSkin < m_listSkinObj.GetCount());
    m_iSelectedSkin = iSkin;
    }

    Change the 2nd assert to use "<=" instead of "<".

    ASSERT(iSkin <= m_listSkinObj.GetCount());

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

Top White Papers and Webcasts

  • Live Event Date: November 20, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Are you wanting to target two or more platforms such as iOS, Android, and/or Windows? You are not alone. 90% of enterprises today are targeting two or more platforms. Attend this eSeminar to discover how mobile app developers can rely on one IDE to create applications across platforms and approaches (web, native, and/or hybrid), saving time, money, and effort and introducing apps to market faster. You'll learn the trade-offs for gaining long …

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds