Click here to Skip to main content
15,867,568 members
Articles / Desktop Programming / WTL
Article

Outlook Bar Control and Frame (WTL)

Rate me:
Please Sign up or sign in to vote.
5.00/5 (7 votes)
27 Jun 2001 275.4K   7.1K   84   31
An outlook control and framework that can be used in your WTL Application

Sample Image - atloutlookbar3.gif

Credit and Acknowledgments

First of all I would like to credit the Original Author Iuri Apollonio on the fantastic control that he has developed using MFC. His code has been used to port the control to WTL with a few WTL tweaks and fixes. The original article can be found at

The Outlook caption bar is based on the Window Caption Bar written by Maxime Labelle, the original article can be found at http://www.codeproject.com/useritems/captionbarctrl.asp

The Flatbutton on the caption bar is based on Davide Calabro's excellent CButtonST class, that has been ported to WTL. The Flatbutton class has been extended to include functionality to get the outlook flatbutton style.

Overview

I needed a Outlook bar to use in a ATL/WTL project, my attention turned to Iuri Apollonio Outlook bar Control that was MFC based and this article basically ports the original CGfxOutBarCtrl. Three ATL files contain the port.
  • atloutbarctrl.h (Contains the main COutBarCtrl Class for WTL)
  • atlgroupedit.h (Contains the CGroupEdit class for WTL and used by the COutBarCtrl Class)
  • atloutbarsplit.h (Contains the COutlookSplitterWindow class for WTL and used by the COutBarCtrl Class)

The caption bar can be found in

  • atlcaptionbar.h (Contains the main CCaptionBar)

The flatbutton class can be found in

  • atlflatbutton.h (Contains the main CButtonST class)

The COutlookSplitterWindow bar is inherited from the WTL CSplitterWindow class, additional functionality had to be added to make the left pane aligned (i.e. left pane does not move width wise when the app is resized). This functionality strangely exist in the base class for a right pane. Further tweks had to be added to make it act like a outlook splitter. The original CGfxSplitterWindow has not been ported as MFC and WTL splitter classes vary.

Requirements

You will require the WTL Libraries, these can be downloaded from the microsoft site, there are various articles on the net that tell you how to do this, so I won't bore you with the details.

Note - This control uses the WTL CString class and the STL std::list template class.

How to use the control in your WTL App

  1. Make sure you have the following ATL files included in your stdafx.h

    • atlwin.h
    • atlctrls.h
    • atlmisc.h

    atlmisc.h is required as it has the definition for the WTL CString Class

  2. Add the header file atloutbarctrl.h and atloutbarsplit.h to the Main frame class and declare an instance of the Outlook bar control, Outlook Bar Splitter objects and the Image Lists that are to be used in the outlook bar.
    COutBarCtrl wndBar;
    CImageList imaLarge, imaSmall;
    COutlookSplitterWindow m_splitter
  3. Create the outlook splitter class e.g.
    m_hWndClient = m_splitter.Create(m_hWnd, rect, NULL, 
        WS_CHILD | WS_VISIBLE);
  4. Create the outlook bar control and set the image lists on the OnCreate function in the Main Frame class e.g.
    DWORD dwf = COutBarCtrl::fDragItems|COutBarCtrl::fEditGroups|
        COutBarCtrl::fEditItems|COutBarCtrl::fRemoveGroups| 
    COutBarCtrl::fRemoveItems|COutBarCtrl::fAddGroups|
        COutBarCtrl::fAnimation; 
    if (!wndBar.Create(WS_CHILD|WS_VISIBLE, CRect(0,0,0,0), 
        m_splitter.m_hWnd, 1234, dwf)) 
    { 
       DWORD word = GetLastError(); 
       return 0; 
    } 
    wndBar.SetOwner(m_hWnd);
    
    imaLarge.Create(IDB_IMAGELIST, 32, 0, RGB(128,128,128));
    imaSmall.Create(IDB_SMALL_IMAGELIST, 16, 0, RGB(0,128,128));
    
    wndBar.SetImageList(&imaLarge, COutBarCtrl::fLargeIcon);
    wndBar.SetImageList(&imaSmall, COutBarCtrl::fSmallIcon);
    wndBar.SetAnimationTickCount(20);
    wndBar.SetAnimSelHighlight(200);
    
    wndBar.AddFolder("Folder 1", 0);
    wndBar.AddFolder("Folder 2", 1);
    wndBar.AddFolder("Folder 3", 2);
    
    wndBar.InsertItem(0, 0, "Item 1", 0, 0);
    wndBar.InsertItem(0, 1, "Item 2", 1, 0);
    wndBar.InsertItem(0, 2, "Item 3", 2, 0);
  5. You need to set a few of the splitter methods for it to act like a outlook splitter.
    m_splitter.m_bFullDrag = false; // Draws the Ghost bar instead
    m_splitter.SetSplitterExtendedStyle(SPLIT_LEFTALIGNED); 
      // Aligns the outlook bar to the left
    
    m_splitter.SetSplitterPanes(wndBar, m_list); 
      // Set the outlook bar on the left pane
    
    m_splitter.SetSplitterPos(120); // width of the initial outlook bar
  6. To receive Events on when the tab has been selected add the Macro to the message Map.
    MESSAGE_HANDLER(WM_OUTBAR_NOTIFY, OnOutbarNotify)

    On the onNotify handler, trap the Events.

    LRESULT OnOutbarNotify(UINT /*uMsg*/, WPARAM wParam, 
        LPARAM lParam, BOOL& /*bHandled*/)
    {
       switch (wParam)
       {
          case NM_OB_ITEMCLICK:
        // cast the lParam to an integer to get the clicked item
        {
           int index = (int) lParam;
         CString cs, cs1;
         cs1 = wndBar.GetItemText(index);
         cs.Format("Clicked on %d - <%s>", (int)lParam, cs1);
         MessageBox(cs, "Outlook Bar", MB_OK);
        }
        return 0;
    
        case NM_OB_ONLABELENDEDIT:
        // cast the lParam to an OUTBAR_INFO * struct; 
        // it will contain info about the edited item
        {
           OUTBAR_INFO * pOI = (OUTBAR_INFO *) lParam;
        }
        return 1;
    
        case NM_OB_ONGROUPENDEDIT:
        // cast the lParam to an OUTBAR_INFO * struct; 
        // it will contain info about the edited folder
              {
           OUTBAR_INFO * pOI = (OUTBAR_INFO *) lParam;
        }
        return 1;
    
        case NM_OB_DRAGITEM:
        // cast the lParam to an OUTBAR_INFO * struct; 
        // it will contain info about the dragged items
              {
           OUTBAR_INFO * pOI = (OUTBAR_INFO *) lParam;
        }
        return 1;
       }
       return 0;
    }

The Demo App shows how to use the control in full.

Updates

  • v1.00 - Initial Port
  • v1.01 - Added Outlook Caption Bar to demo app also shows how to use nested vertical and horizontal splitter bar to get outlook feel. Fixed potential painting problem in outlook control when resizing the application.
  • v1.02 - Extended the Outlook framework, by adding the flat button on the caption bar. Also uses panes to lock and unlock the floating tree window.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United Kingdom United Kingdom
Was made redundant in early 2003 after 10 years in computer programming, since then started my own business (selling computer books on the net)
www.pricecutbook.co.uk


Comments and Discussions

 
Generala bug... Pin
nullpointer5-May-01 9:55
nullpointer5-May-01 9:55 
GeneralRe: a bug... Pin
10-May-01 6:29
suss10-May-01 6:29 
GeneralRe: a bug... Pin
27-Aug-01 19:14
suss27-Aug-01 19:14 
GeneralRe: a bug... Pin
dududu17-May-04 19:47
dududu17-May-04 19:47 
GeneralHorizontal Splitters Pin
25-Mar-01 4:09
suss25-Mar-01 4:09 
GeneralRe: Horizontal Splitters Pin
15-Apr-01 8:15
suss15-Apr-01 8:15 
GeneralRe: Horizontal Splitters Pin
30-Jun-01 10:21
suss30-Jun-01 10:21 
GeneralRe: Horizontal Splitters Pin
Rashid Thadha1-Jul-01 11:35
Rashid Thadha1-Jul-01 11:35 
Additional functionality had to be added to make the left pane aligned (left pane not moving when the app is re-sized).

I Really should have inherired a new class from CSpliterWindow, I may change the code for the next update.

Blush | :O

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.