Click here to Skip to main content
Click here to Skip to main content

OutlookTabCtrl, like CBCGPOutlookBar (in Mode2003)

, 17 Dec 2008
Rate this:
Please Sign up or sign in to vote.
Control with modern design for multiple uses
OutlookTabCtrl.png

Introduction

Recently in one of my programs, I would have needed to use a CBCGPOutlookBar control (in Mode2003) from the BCGControlBar library. It is created as a ControlBar object and it is possible to bind it at the left or right side of a frame. I was not able to put it to the -- necessary for me -- float state. Also, it is not possible to create it as a child for any window, e.g. to put it on the dialog. The control that I created is derived from CWnd and is a common control based on MFC. It does not have restrictions and it is possible to put it on any window (main frame, dialog, float bar (ControlBar), etc).

Using the Code

The control includes three hierarchical classes:

Class

File

Description

OutlookTabCtrlBase

OutlookTabCtrl.h

Base class. Includes all the base functionality, but it does not draw or display the menu and setting dialog.

OutlookTabCtrl

OutlookTabCtrl.h

Derived from OutlookTabCtrlBase. Overrides and implements the virtual methods that are necessary to draw the control and save its state to the registry.

OutlookTabCtrlEx

OutlookTabCtrlEx.h

Derived from OutlookTabCtrl. Overrides and implements a single virtual method, ShowMenu. It shows the menu and, if it is possible, shows the dialog based on the OutlookTabCtrlCmdDialog class.

To create the control and add elements to it, you can do the next steps:

OutlookTabCtrlEx m_OutlookTabCtrlEx;
CListCtrl m_List1, m_List2;

...
...

if(m_OutlookTabCtrlEx.Create(this,
    WS_CHILD | WS_VISIBLE | WS_BORDER,CRect(3,3,200,350),
    ID_OutlookTabCtrl)==false)
    return -1;    // error.

CImageList imagelistBig, imagelistSmall;
CBitmap bmpBig, bmpSmall;

// Create ImageList for big icons.
imagelistBig.Create(24,24,ILC_COLOR24 | ILC_MASK,2,0);
bmpBig.LoadBitmap(IDB_BITMAP1);
imagelistBig.Add(&bmpBig,RGB(255,0,255));

// Create ImageList for small icons.
imagelistSmall.Create(16,16,ILC_COLOR24 | ILC_MASK,2,0);
bmpSmall.LoadBitmap(IDB_BITMAP2);
imagelistSmall.Add(&bmpSmall,RGB(255,0,255));

m_OutlookTabCtrlEx.SetImageLists(&imagelistBig,&imagelistSmall,NULL,NULL);

// Create child controls.
if(m_List1.Create(WS_CHILD | WS_CLIPCHILDREN | LVS_REPORT,CRect(0,0,0,0),
    &m_OutlookTabCtrlEx,ID_List1)==0 ||
    m_List2.Create(WS_CHILD | WS_CLIPCHILDREN | LVS_REPORT,CRect(0,0,0,0),
    &m_OutlookTabCtrlEx,ID_List2)==0)
    return -1;    // error.
m_List1.InsertColumn(0,"Mail",LVCFMT_LEFT,100);
m_List2.InsertColumn(0,"Calendar",LVCFMT_LEFT,100);

// Add child items in the m_OutlookTabCtrlEx.
if(m_OutlookTabCtrlEx.AddTab(&m_List1,"Mail",0,0)==NULL ||
    m_OutlookTabCtrlEx.AddTab(&m_List2,"Calendar",1,1)==NULL)
    return -1;    // error.

// Load state from registry.
if(m_OutlookTabCtrlEx.LoadState(AfxGetApp(),
    "OutlookTabCtrl","TabsState")==false)
    m_OutlookTabCtrlEx.PushTab();    // error - create default state.

m_OutlookTabCtrlEx.Update(); 

Windows for all new added elements should have the unique identifiers. Elements can be in the state of a tab or button. By default, an element is added as a tab. Using the Insert function, it is possible to add the element to the random position. Remove changes the position. The control is expected to call the Update function to show the results that are set by functions Delete, SetItemWnd, ShowItem, etc. The control can hide the element (ShowItem) or block it (Disable) and get an index between visible elements (GetVisibleIdxByHandle) or all elements in the control (GetIdxByHandle).

Also, it is possible to check the existence of the element (IsExist) or position it below the mouse cursor (HitTest). The control is able to save and load its state from the registry or other source (LoadState/SaveState). This is just a part of the possibilities. To get the full power, look at the opened and closed interfaces of the OutlookTabCtrlBase and OutlookTabCtrl classes, as well as the OutlookTabCtrlExCustom class for creating the user interface of the control.

Good luck.

History

  • 4 October, 2007 -- Original version posted
  • 11 October, 2007 -- Fixed problem with addition Dialog as child control; added functions SetLayout and SetButtonsAlign for determination places of the control's areas
  • 17 December, 2008 -- Just corrected some small errors

License

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

About the Author

Borodenko Oleg
Software Developer
Belarus Belarus
No Biography provided

Comments and Discussions

 
QuestionTabs, splitter and windows layout PinmemberMember 96655013-Apr-13 2:06 
AnswerRe: Tabs, splitter and windows layout PinmemberBorodenko Oleg3-Apr-13 7:01 
Questionhow can I move the window to right of the listView(Mail, Calendar, Contacts...)?? Pinmemberchary_529-Sep-11 20:55 
AnswerRe: how can I move the window to right of the listView(Mail, Calendar, Contacts...)?? PinmemberBorodenko Oleg30-Sep-11 11:08 
QuestionRe: how can I move the window to right of the listView(Mail, Calendar, Contacts...)?? Pinmemberchary_53-Oct-11 21:53 
AnswerRe: how can I move the window to right of the listView(Mail, Calendar, Contacts...)?? PinmemberBorodenko Oleg4-Oct-11 0:19 
GeneralCan I use this control in .NET WinForm Application?? Pinmember435sdfasfsddsf23-May-11 1:57 
GeneralRe: Can I use this control in .NET WinForm Application?? PinmemberBorodenko Oleg24-May-11 0:39 
GeneralMy vote of 5 Pinmemberskyformat99@gmail.com17-Jan-11 20:39 
QuestionHow to Notify the control MSG?(CTreeCtrl,CListCtrl etc.) PinmemberCuTxYz6-Oct-10 23:51 
AnswerRe: How to Notify the control MSG?(CTreeCtrl,CListCtrl etc.) PinmemberBorodenko Oleg8-Oct-10 0:13 
GeneralRe: How to Notify the control MSG?(CTreeCtrl,CListCtrl etc.) PinmemberCuTxYz8-Oct-10 20:13 
GeneralRe: How to Notify the control MSG?(CTreeCtrl,CListCtrl etc.) PinmemberBorodenko Oleg11-Oct-10 0:19 
GeneralRe: How to Notify the control MSG?(CTreeCtrl,CListCtrl etc.) PinmemberCuTxYz11-Oct-10 6:12 
GeneralInclude this outlookTabCtrl and modify the controls in tab Pinmemberr.k.lavanya23-Sep-10 2:23 
GeneralRe: Include this outlookTabCtrl and modify the controls in tab PinmemberBorodenko Oleg24-Sep-10 20:47 
GeneralOutlookTabCtrl in CSizingControlBar Pinmemberpresidentkevin1-May-10 22:57 
GeneralRe: OutlookTabCtrl in CSizingControlBar PinmemberBorodenko Oleg5-May-10 0:42 
GeneralNot Work on other computers after release Pinmemberpresidentkevin16-Apr-10 17:27 
GeneralRe: Not Work on other computers after release PinmemberBorodenko Oleg17-Apr-10 0:19 
GeneralRe: Not Work on other computers after release Pinmemberpresidentkevin29-Apr-10 22:23 
General在中文的vs2008编译成功 Pinmemberpophelix15-Dec-09 18:07 
GeneralRe: 在中文的vs2008编译成功 PinmemberBorodenko Oleg16-Dec-09 0:05 
GeneralRe: 在中文的vs2008编译成功 PinmemberLoveVc22-Jul-10 16:03 
GeneralRe: 在中文的vs2008编译成功 PinmemberBorodenko Oleg23-Jul-10 0:34 
GeneralRe: 在中文的vs2008编译成功 PinmemberMember 4408248-Dec-10 18:38 
General好极了 Pinmemberpophelix15-Dec-09 18:05 
GeneralRe: 好极了 PinmemberMember 4408248-Dec-10 18:46 
GeneralRe: 好极了 Pinmemberbatsword26-Apr-11 20:11 
GeneralRe: 好极了 [modified] PinmemberBorodenko Oleg26-Apr-11 23:53 
GeneralRe: 好极了 Pinmemberbatsword27-Apr-11 16:06 
GeneralHide OutlookTabCtrl Pinmemberrichi_84-Aug-09 0:13 
GeneralRe: Hide OutlookTabCtrl PinmemberBorodenko Oleg4-Aug-09 0:39 
GeneralRe: Hide OutlookTabCtrl Pinmemberrichi_84-Aug-09 0:56 
GeneralRe: Hide OutlookTabCtrl PinmemberBorodenko Oleg4-Aug-09 3:47 
GeneralRe: Hide OutlookTabCtrl Pinmemberrichi_84-Aug-09 4:05 
GeneralInitialisation of OutlookTabCtrlBase Pinmemberrichi_85-Jul-09 23:16 
GeneralRe: Initialisation of OutlookTabCtrlBase PinmemberBorodenko Oleg8-Jul-09 1:16 
GeneralSetSel Pinmemberjosip cagalj21-Apr-09 3:54 
GeneralIcon hilited Pinmemberjosip cagalj5-Feb-09 3:54 
GeneralRe: Icon hilited PinmemberBorodenko Oleg5-Feb-09 23:23 
GeneralRe: Icon hilited Pinmemberjosip cagalj5-Feb-09 23:37 
GeneralRe: Icon hilited PinmemberBorodenko Oleg9-Feb-09 0:40 
GeneralRe: Icon hilited Pinmemberjosip cagalj9-Feb-09 0:45 
GeneralRe: Icon hilited Pinmemberjosip cagalj9-Feb-09 0:53 
GeneralRe: Icon hilited Pinmemberjosip cagalj9-Feb-09 1:00 
GeneralCDialog problem Pinmemberjosip cagalj19-Jan-09 0:56 
GeneralRe: CDialog problem PinmemberBorodenko Oleg20-Jan-09 0:42 
GeneralRe: CDialog problem Pinmemberjosip cagalj20-Jan-09 1:27 
Generaloh, Good! Pinmemberpiaopiao26-Sep-08 3:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 17 Dec 2008
Article Copyright 2007 by Borodenko Oleg
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid