Click here to Skip to main content
6,305,776 members and growing! (17,922 online)
Email Password   helpLost your password?
Desktop Development » Dialogs and Windows » Dialogs     Intermediate

Toolbar & StatusBar on Dialog

By Barretto VN

Toolbar / Statusbar on Dialog Window
VC6, VC7Win2K, WinXP, MFC, Dev
Posted:2 Aug 2002
Updated:7 Aug 2002
Views:74,783
Bookmarked:36 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
20 votes for this article.
Popularity: 3.42 Rating: 2.63 out of 5
2 votes, 18.2%
1
1 vote, 9.1%
2
1 vote, 9.1%
3
1 vote, 9.1%
4
6 votes, 54.5%
5

Sample Image - DlgToolStatusBar.gif

What's New

Carried out some changes as suggested by Russ Freeman. The Changes are as follows

  • Moved all string in code to String Table
  • Delete unwanted sub-class files CStatusBar
  • Added menu to generate 3 types of ToolBars
  • Retained Old Toolbar as is
  • New Toolbars use Arrays
  • Added Date & Time on the Statusbar
  • Added message Maps for new Toolbars

Introduction

This Article demonstrates the technique of creating Toolbar and StatusBar on a Dialog Window.

To acheive the goal you create a Dialog-based project from the New Project Wizard, a blank form with Ok and Cancel buttons is created by default.

Delete the buttons since you will most probably be making the project menu-driven.

//

//  First we create the ImageList for use with the ToolBar

//  in following manner

CWinApp* pApp = AfxGetApp();
mImageList->Create(24, 24, ILC_COLOR8 | ILC_MASK,  9, 9);
mImageList->Add(pApp->LoadIcon(IDI_HELP));
mImageList->Add(pApp->LoadIcon(IDI_BOLD));
mImageList->Add(pApp->LoadIcon(IDI_DRAWING));
mImageList->Add(pApp->LoadIcon(IDI_STRIKEOUT));
//

// next we create the Toolbar

//


TBBUTTON tb;

m_ToolBar.Create(WS_CHILD|WS_VISIBLE|WS_BORDER|TBSTYLE_FLAT, 
    CRect(0,0,0,0), this, 0);

m_ToolBar.SetImageList(&m_pImageList); 
   // Set ImageList for this Toolbar created 

   // in the previous section

tb.iBitmap = 0;
tb.iString = NULL;
tb.fsState = TBSTATE_ENABLED;
tb.fsStyle = TBSTYLE_BUTTON;
tb.idCommand = ID_HELP_ABOUT;

m_ToolBar.AddButtons(1, &tb);
tb.iBitmap = 1;
tb.idCommand = ID_BOLD;
m_ToolBar.AddButtons(1, &tb);
tb.iBitmap = 2;
tb.idCommand = ID_DRAWING;
m_ToolBar.AddButtons(1, &tb);

TBBUTTON tb1;
tb1.fsStyle = TBSTYLE_SEP;
m_ToolBar.AddButtons(1, &tb1);

tb.iBitmap = 3;
tb.idCommand = ID_STRIKEOUT;
tb.iString = NULL;
m_ToolBar.AddButtons(1, &tb);

//

// We now Create the Statusbar as show below

//


 
m_StatusBar.Create(WS_CHILD|WS_VISIBLE|SBT_OWNERDRAW,
    CRect(0,0,0,0), this, 0);

// You can set the no. of parts of the StatusBar (4 in this case) 

// and the width of each part not -1 means remaining width


int strPartDim[4]= {180, 260, 340, -1};
m_StatusBar.SetParts(4, strPartDim);

m_StatusBar.SetText(_T("Dialog / StatusBar / Toolbar"),0,0);
m_StatusBar.SetText(_T("Example"), 1, 0);
    
CString string;
string.LoadString(IDS_MYCOMPUTER);
m_StatusBar.SetText(string, 3 ,SBT_NOBORDERS   );
m_StatusBar.SetIcon(3,     SetIcon(AfxGetApp()->LoadIcon(IDI_COMP), FALSE));

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

About the Author

Barretto VN


Member
Nothing to boast about
Location: India India

Other popular Dialogs and Windows articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 9 of 9 (Total in Forum: 9) (Refresh)FirstPrevNext
GeneralVery helpful - but image list wrong size Pinmemberrneville3:09 7 Apr '04  
GeneralRe: Very helpful - but image list wrong size PinmemberBarretto VN0:49 9 Apr '04  
GeneralBug OnTimer PinmemberTomBest1:03 12 Dec '03  
GeneralRe: Bug OnTimer PinmemberBarretto VN3:29 10 Mar '05  
GeneralThe Menue Pinmemberjoerghamster2:30 14 Mar '03  
AnswerRe: The Menue PinmemberAmar Sutar4:23 6 Apr '06  
GeneralRe: Some bad habits and other code comments. PinmemberGeorge17:17 8 Aug '02  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 7 Aug 2002
Editor: Nishant Sivakumar
Copyright 2002 by Barretto VN
Everything else Copyright © CodeProject, 1999-2009
Web20 | Advertise on the Code Project