Click here to Skip to main content
11,719,903 members (84,125 online)
Click here to Skip to main content

OutlookTabCtrl, like CBCGPOutlookBar (in Mode2003)

, 17 Dec 2008 CPOL 183.4K 5.4K 186
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)

Share

About the Author

Borodenko Oleg
Software Developer Closed JSC 'Phazotron-7'
Belarus Belarus
No Biography provided

You may also be interested in...

Comments and Discussions

 
Questionrun error,"gettextextent" ,use vs2010 .thank you Pin
letiantxf5-Sep-14 0:34
memberletiantxf5-Sep-14 0:34 
AnswerRe: run error,"gettextextent" ,use vs2010 .thank you Pin
Borodenko Oleg5-Sep-14 1:30
memberBorodenko Oleg5-Sep-14 1:30 
GeneralRe: run error,"gettextextent" ,use vs2010 .thank you Pin
letiantxf7-Sep-14 3:57
memberletiantxf7-Sep-14 3:57 
GeneralRe: run error,"gettextextent" ,use vs2010 .thank you Pin
Borodenko Oleg7-Sep-14 13:14
memberBorodenko Oleg7-Sep-14 13:14 
GeneralRe: run error,"gettextextent" ,use vs2010 .thank you Pin
letiantxf12-Sep-14 3:55
memberletiantxf12-Sep-14 3:55 
GeneralRe: run error,"gettextextent" ,use vs2010 .thank you Pin
letiantxf12-Sep-14 4:00
memberletiantxf12-Sep-14 4:00 
GeneralRe: run error,"gettextextent" ,use vs2010 .thank you Pin
Borodenko Oleg13-Sep-14 9:40
memberBorodenko Oleg13-Sep-14 9:40 
GeneralRe: run error,"gettextextent" ,use vs2010 .thank you Pin
letiantxf16-Sep-14 21:35
memberletiantxf16-Sep-14 21:35 
QuestionTabs, splitter and windows layout Pin
Member 96655013-Apr-13 2:06
memberMember 96655013-Apr-13 2:06 
AnswerRe: Tabs, splitter and windows layout Pin
Borodenko Oleg3-Apr-13 7:01
memberBorodenko Oleg3-Apr-13 7:01 
Questionhow can I move the window to right of the listView(Mail, Calendar, Contacts...)?? Pin
chary_529-Sep-11 20:55
memberchary_529-Sep-11 20:55 
AnswerRe: how can I move the window to right of the listView(Mail, Calendar, Contacts...)?? Pin
Borodenko Oleg30-Sep-11 11:08
memberBorodenko Oleg30-Sep-11 11:08 
QuestionRe: how can I move the window to right of the listView(Mail, Calendar, Contacts...)?? Pin
chary_53-Oct-11 21:53
memberchary_53-Oct-11 21:53 
AnswerRe: how can I move the window to right of the listView(Mail, Calendar, Contacts...)?? Pin
Borodenko Oleg4-Oct-11 0:19
memberBorodenko Oleg4-Oct-11 0:19 
GeneralCan I use this control in .NET WinForm Application?? Pin
435sdfasfsddsf23-May-11 1:57
member435sdfasfsddsf23-May-11 1:57 
GeneralRe: Can I use this control in .NET WinForm Application?? Pin
Borodenko Oleg24-May-11 0:39
memberBorodenko Oleg24-May-11 0:39 
GeneralMy vote of 5 Pin
skyformat99@gmail.com17-Jan-11 20:39
memberskyformat99@gmail.com17-Jan-11 20:39 
QuestionHow to Notify the control MSG?(CTreeCtrl,CListCtrl etc.) Pin
CuTxYz6-Oct-10 23:51
memberCuTxYz6-Oct-10 23:51 
AnswerRe: How to Notify the control MSG?(CTreeCtrl,CListCtrl etc.) Pin
Borodenko Oleg8-Oct-10 0:13
memberBorodenko Oleg8-Oct-10 0:13 
GeneralRe: How to Notify the control MSG?(CTreeCtrl,CListCtrl etc.) Pin
CuTxYz8-Oct-10 20:13
memberCuTxYz8-Oct-10 20:13 
GeneralRe: How to Notify the control MSG?(CTreeCtrl,CListCtrl etc.) Pin
Borodenko Oleg11-Oct-10 0:19
memberBorodenko Oleg11-Oct-10 0:19 
GeneralRe: How to Notify the control MSG?(CTreeCtrl,CListCtrl etc.) Pin
CuTxYz11-Oct-10 6:12
memberCuTxYz11-Oct-10 6:12 
GeneralInclude this outlookTabCtrl and modify the controls in tab Pin
r.k.lavanya23-Sep-10 2:23
memberr.k.lavanya23-Sep-10 2:23 
GeneralRe: Include this outlookTabCtrl and modify the controls in tab Pin
Borodenko Oleg24-Sep-10 20:47
memberBorodenko Oleg24-Sep-10 20:47 
GeneralOutlookTabCtrl in CSizingControlBar Pin
presidentkevin1-May-10 22:57
memberpresidentkevin1-May-10 22:57 
GeneralRe: OutlookTabCtrl in CSizingControlBar Pin
Borodenko Oleg5-May-10 0:42
memberBorodenko Oleg5-May-10 0:42 
GeneralNot Work on other computers after release Pin
presidentkevin16-Apr-10 17:27
memberpresidentkevin16-Apr-10 17:27 
GeneralRe: Not Work on other computers after release Pin
Borodenko Oleg17-Apr-10 0:19
memberBorodenko Oleg17-Apr-10 0:19 
GeneralRe: Not Work on other computers after release Pin
presidentkevin29-Apr-10 22:23
memberpresidentkevin29-Apr-10 22:23 
General在中文的vs2008编译成功 Pin
pophelix15-Dec-09 18:07
memberpophelix15-Dec-09 18:07 
GeneralRe: 在中文的vs2008编译成功 Pin
Borodenko Oleg16-Dec-09 0:05
memberBorodenko Oleg16-Dec-09 0:05 
GeneralRe: 在中文的vs2008编译成功 Pin
LoveVc22-Jul-10 16:03
memberLoveVc22-Jul-10 16:03 
GeneralRe: 在中文的vs2008编译成功 Pin
Borodenko Oleg23-Jul-10 0:34
memberBorodenko Oleg23-Jul-10 0:34 
GeneralRe: 在中文的vs2008编译成功 Pin
Member 4408248-Dec-10 18:38
memberMember 4408248-Dec-10 18:38 
General好极了 Pin
pophelix15-Dec-09 18:05
memberpophelix15-Dec-09 18:05 
GeneralRe: 好极了 Pin
Member 4408248-Dec-10 18:46
memberMember 4408248-Dec-10 18:46 
GeneralRe: 好极了 Pin
batsword26-Apr-11 20:11
memberbatsword26-Apr-11 20:11 
GeneralRe: 好极了 [modified] Pin
Borodenko Oleg26-Apr-11 23:53
memberBorodenko Oleg26-Apr-11 23:53 
GeneralRe: 好极了 Pin
batsword27-Apr-11 16:06
memberbatsword27-Apr-11 16:06 
GeneralHide OutlookTabCtrl Pin
richi_84-Aug-09 0:13
memberrichi_84-Aug-09 0:13 
GeneralRe: Hide OutlookTabCtrl Pin
Borodenko Oleg4-Aug-09 0:39
memberBorodenko Oleg4-Aug-09 0:39 
GeneralRe: Hide OutlookTabCtrl Pin
richi_84-Aug-09 0:56
memberrichi_84-Aug-09 0:56 
GeneralRe: Hide OutlookTabCtrl Pin
Borodenko Oleg4-Aug-09 3:47
memberBorodenko Oleg4-Aug-09 3:47 
GeneralRe: Hide OutlookTabCtrl Pin
richi_84-Aug-09 4:05
memberrichi_84-Aug-09 4:05 
GeneralInitialisation of OutlookTabCtrlBase Pin
richi_85-Jul-09 23:16
memberrichi_85-Jul-09 23:16 
GeneralRe: Initialisation of OutlookTabCtrlBase Pin
Borodenko Oleg8-Jul-09 1:16
memberBorodenko Oleg8-Jul-09 1:16 
GeneralSetSel Pin
josip cagalj21-Apr-09 3:54
memberjosip cagalj21-Apr-09 3:54 
GeneralIcon hilited Pin
josip cagalj5-Feb-09 3:54
memberjosip cagalj5-Feb-09 3:54 
GeneralRe: Icon hilited Pin
Borodenko Oleg5-Feb-09 23:23
memberBorodenko Oleg5-Feb-09 23:23 
GeneralRe: Icon hilited Pin
josip cagalj5-Feb-09 23:37
memberjosip cagalj5-Feb-09 23:37 

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 | Terms of Use | Mobile
Web01 | 2.8.150901.1 | Last Updated 17 Dec 2008
Article Copyright 2007 by Borodenko Oleg
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid