Microsoft KB Archive/256066

From BetaArchive Wiki
Knowledge Base

HOWTO: Use the StatusBar ActiveX Control in Visual FoxPro

Article ID: 256066

Article Last Modified on 7/13/2004


  • Microsoft Visual FoxPro 5.0 Standard Edition
  • Microsoft Visual FoxPro 5.0a
  • Microsoft Visual FoxPro 6.0 Professional Edition

This article was previously published under Q256066


This article shows how to programmatically access the most common properties and methods of the StatusBar ActiveX control using Visual FoxPro.


A StatusBar control provides a window, usually at the bottom of a parent form, through which an application can display various kinds of status data. The StatusBar control can be divided up into a maximum of sixteen Panel objects that are contained in a Panels collection.
Running the following code illustrates some of the most common usages for the StatusBar ActiveX control. To use this code, copy it into a new program in Visual FoxPro and run it.

Public frmOLETest
Local lnPanels

frmOLETest = CREATEOBJECT('Form') && Create Instance of the Form

With frmOLETest     && Set Default Values for the Form
    .CAPTION = 'StatusBar Control Test Form'
    .WIDTH = 800
    .HEIGHT = 200
    .VISIBLE = .T.
    .ADDOBJECT('OCXTest','StatusBarControl', ;
        'MSComctlLib.sBarCtrl.2') && Create Instance of the StatusBar Control

With frmOLETest.OCXTest     && Set Values and options of the StatusBar Control
*!* Default Panel
    .Panels(1).TEXT = "Sample Text"     && Default Text For Panel 1
    .Panels(1).TOOLTIPTEXT = "Panel 1"
    .Panels(1).STYLE = 0

*!* Additional Panels
    For lnPanels = 2 TO 8
              .Panels.ADD()                         && Adds Panels 2 to 8
              .Panels(lnPanels).STYLE = lnPanels - 1    && Show each Panel Style
*!* Style 0 = Text or Bitmap
*!*      1 = Caps Lock
*!*  2 = Num Lock
*!*  3 = Insert
*!*  4 = Scroll Lock
*!*  5 = System Time
*!*  6 = System Date
*!*  7 = Kana entry (Japanese characters)
              .Panels(lnPanels).TOOLTIPTEXT = "Panel " + ;

Define CLASS StatusBarControl AS OLECONTROL
    Visible = .T.
    Height = 25


For additional information, visit the MSDN Web site and search under: FoxPro StatusBar Control at: Microsoft Developer Network

The "StatusBar Control" section in CMCTL198.CHM. This Help file is usually located in the MSDN directory under a Visual Studio 98 installation.

Keywords: kbhowto kbctrl KB256066