.NET
  Home arrow .NET arrow Page 3 - New Features for the Statusbar in MFC
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
.NET

New Features for the Statusbar in MFC
By: Gabor Bernat
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2009-10-08

    Table of Contents:
  • New Features for the Statusbar in MFC
  • Animation
  • Progress bar
  • Double click response

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    New Features for the Statusbar in MFC - Progress bar


    (Page 3 of 4 )

    It is always a good idea to remind the user of the status of the data procession, if possible. Adding a little progress bar inside the Statusbar is one of the best solutions.

    A progress bar requires its own pane. Create one with the ID of ID_PROG_BAR. Add any default text, as the size it does not matter. We will change it.

    int id = m_wndStatusBar.CommandToIndex(ID_PROG_BAR;

     

    m_wndStatusBar.SetPaneWidth(id, 100);

    m_wndStatusBar.EnablePaneProgressBar (id, 100);

     

    The short code snippet above is all you need to get it up and working. To simulate it I decided to increase the progress by one at every OnTimer call (so every single second). I set 100 pixels as the length of the progress bar and set the maximum value of the progress bar to one hundred with the second function (besides enabling it). You can use the following method to ensure a nice demo (add it at the end of OnTimer function):

    if(m_alfa == 100)

    m_alfa = 0;

     

    m_wndStatusBar.SetPaneProgress( m_wndStatusBar.CommandToIndex(ID_PROG_BAR), ++m_alfa);

     

    Most of the time you may want to modify this from other classes. If this is the case, you need to create a method for accessing the Statusbar. The most advisable is to implement a member function of the mainframe that returns a reference or pointer. You can ask for the mainframe's pointer from any class via the following line:

     

    ((CMainFrame*) AfxGetMainWnd ())->GetStatusBar().SetPaneText(…);

     

    if the GetStatusbar is defined as:

     

    CMFCStatusBar& CMainFrame::GetStatusBar()

    {

    return m_wndStatusBar;

    } 

    More .NET Articles
    More By Gabor Bernat


     

    .NET ARTICLES

    - Introducing .NET
    - Building Business Objects for an Application
    - Methods for an Application`s Business Logic ...
    - Properties of an Application`s Business Logi...
    - Classes and Properties in an Application`s B...
    - Organizing Code for the Business Logic Layer...
    - Building the Business Logic Layer
    - Completing a Business Layer with Windows Wor...
    - Building Applications with Windows Workflow ...
    - Building the Data and Business Layers Using ...
    - The Transformed XML Explorer in MFC
    - List Control and Property Grid with the MFC ...
    - Font, Shell and Masked Edit Controls for MFC
    - Color, Link and Image Editor Controls for M...
    - New Controls for MFC





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 10 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek