Toolbar and Statusbar on Dialog | CodeGuru

Toolbar and Statusbar on Dialog

Environment: VC6 , Windows 98 This is an example of creating a Toolbar and Statusbar on a Dialog Window. I came across some project (I cannot remember by whom) and thought of developing a more Windows-like project. Code for Creation of Toolbar m_pImageList = new CImageList; SetupImages(m_pImageList); TBBUTTON tb; m_ToolBar = new CToolBarCtrl; m_ToolBar->Create(WS_CHILD|WS_VISIBLE|WS_BORDER|TBSTYLE_FLAT, CRect(0,0,0,0), […]

Written By
CodeGuru Staff
CodeGuru Staff
Jun 27, 2002
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Environment: VC6 , Windows 98

This is an example of creating a Toolbar and Statusbar on a Dialog Window. I came across some project (I cannot remember by whom) and thought of developing a more Windows-like project.

Code for Creation of Toolbar

  m_pImageList = new CImageList;
  SetupImages(m_pImageList);

  TBBUTTON tb;

  m_ToolBar = new CToolBarCtrl;
  m_ToolBar->Create(WS_CHILD|WS_VISIBLE|WS_BORDER|TBSTYLE_FLAT,
    CRect(0,0,0,0), this, 0);

  m_ToolBar->SetImageList(m_pImageList);
  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);

Code for Creation of Statusbar

  m_StatusBar = new CStatusBarCtrl;
  m_StatusBar->Create(WS_CHILD|WS_VISIBLE|SBT_OWNERDRAW,
    CRect(0,0,0,0), this, 0);
  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));

Downloads

Download demo project - 22 Kb

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.