Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C++

A raw toolbar for Dialog and Property page with plenty nice styles (version 1.01)

2.27/5 (6 votes)
23 Aug 2006CPOL2 min read 4   273  
A raw toolbar for Dialog and Property page with plenty nice styles

Download source program (version 1.01)

Update information

Only new features and bug-fixed are displayed bellow.
Please visit previous version 1.00 for more information.
 

  • FunctionCreate() function has been changed to:
    BOOL Create(CWnd*pMum,int iBmpID,int cx,int iBarID=-1,COLORREF clrBkgnd=RGB(192,192,192));
    In version 1.00, the function is:
    BOOL Create(CWnd*pMum,int iBmpID,int cx,int iBarID=-1);
      
    clrBkgnd : transparent color of bitmap resource, similar to the color in CImageList
     
    I developed 1.00 on Win98, but when I tested on XP, I found the problem: bitmap background is not transparent to COLOR_BTNFACE, this parameter allows to fit the color to COLOR_BTNFACE - automatically done by CImageList.
     
  • MessagesA new message is added to the toolbar: 
    If user right clicks a button, the new message is distribute to parent window.
     
    To process multiple messages in parent widow, a message class has to be used.
    Message signature is:
    message: WM_COMMAND, wParam: toolbar's ID (same as in version 1.00).
    lParam: a pointer to class ToolbarMine::Message.
     
    The inner message class contains following members:
    class Message
    {
    public:
    UINT uMessage;//see bellow
    intiIndex;//index of the button clicked
    CRectrcButton//rectangle of the button clicked 
    };
     
    uMessage has 2 cases:
     
    1. WM_LBUTTONDOWN
      It is the same as the only message in version 1.00.
      Please note: 
      The message is actually distributed at WM_LBUTTONUP for independent buttons.
      It is almost unnecessary to define new message constant, so I simply use this existing Windows constant.
      This is similar to Windows' common buttons, which tell us a button is clicked rather than down or up.
       
    2. WM_RBUTTONDOWN
      The message is distributed when user clicks a button by right-button of mouse.
      Right-clicking a button does not change button situations (checked or pressed) at all.
       
      The message allows us to do some interesting things with it.
      In my application (not sample program), I display a popup menu associated with the message, which contains "Help", "Edit", "Submit" and "Close" menu items, so my application can offer more options with a button.
       
    Please check source program for more.

7 interfaces on XP with different toolbar styles

(Every interface displays 14 toolbars which represent 14 button styles).

1. Toolbar style: NONE

Image 1

2. Toolbar style: RAISED

Image 2

3. Toolbar style: STRONG RAISED

Image 3

4. Toolbar style: SUNKEN

Image 4

5. Toolbar style: STRONG SUNKEN

Image 5

6. Toolbar style: COLORED

Image 6

7. Toolbar style: STRONG COLORED

Image 7

License

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