Click here to Skip to main content
11,581,353 members (58,744 online)
Click here to Skip to main content

Extended Interface for Status Message

, 8 Apr 2002 174.3K 193 92
Rate this:
Please Sign up or sign in to vote.
Adding an extended property to Menus in order to provide automatic statusbar messages as the user chooses different menu options.
<!-- Download Links -->

MFC Updating Status Bar Automatically

Problem

Some of the features of MFC that we were accustomed to having are missing from the .NET architecture.  One of them is the automatic use of the status bar.  As the user moves across the menu, a description will appear in the status bar.

The .NET architecture allows you to repeat this functionality by overriding the MenuItem class.  Unfortunately, it's a manual process and requires a large case statement.

Hopefully, we can overcome this shortcoming with a quick and simple extended property.  Plus, give you a sample to create your own extended interfaces.

Background

The IExtenderProvider is a tremendously powerful tool when used in conjunction with the interface.  The syntax is quite simple. 

[ProvideProperty( "StatusMessage", typeof(Component)) ] 
public class StatusMessage : Component, IExtenderProvider 
{
   public void SetStatusMessage( Component pComponent, string strMessage )
      ... 

   public string GetStatusMessage( Component pComponent )
  ... 
}

The ProvideProperty tag tells the interface that you are adding a property called "StatusMessage" to all components in your current development.   Similar to a C# property, you will create a Set and Get pair of messages.

The source code for the interface is quite simple, but I'll refrain from discussing the actual coding process to keep this article on a basic level.

1.  Add the StatusMessage control to .NET

Adding the Component to the Toolbox

After copying the Extended Interface DLL (ExtendedInterface.DLL) to your desired destination, you will need to add it permanently to your toolbox. 

  1. With the toolbox open, right click the list to select 'Customize Toolbox.
  2. Select the tab .NET Framework Components
  3. Click Browse...
  4. Click on ExtendedInterface.DLL
  5. Click OK.

The Toolbox should have two new components: StatusMessage and ToolBarFunction.

Adding StatusMessage support is as easy as dragging the StatusMessage component onto your form.  The component will appear below your form.

The other component ToolBarFunction will be discussed in a later article.

2. Add the component to your current project.

Updating the StatusBar

You will also need to drag over a StatusBar from your Toolbox onto your form.  Make sure to add at least one StatusBarPanel to your StatusBar.

  1. Display the properties of your StatusBar.
  2. Click on the 'Panels' collection and add at least one panel.  Call it anything you wish, I used StatusMessage.
  3. Make sure AutoSize is set to Spring
  4. Click OK to close the collection.

3. Change the StatusMessage property

Modifying the StatusBar properties

You will need to modify your StatusMessage component to point to the StatusBarPanel that you have created.

  1. Display the properties of your StatusMessage.
  2. Click on the StatusBar property and use the combo dropdown to find the desired StatusBarPanel that you are wanting to use.

4. Add messages to your menus

Updating the text on the menus

Now click on each of your items in your menu.  Under the Misc category you will now have a new property called StatusMessage

Type in the text that you would like to appear in the status bar for each MenuItem.

5. Test your application

And voila!! Your .NET application now has support for your status bar!

Sample Image

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

Share

About the Author

Zombies with Coffee, LLC
Founder Zombies With Coffee, LLC
United States United States
Phillip has been a programmer long enough to remember cutting paper strip code out of Dr. Dobbs and running them thru a mechanical decoder to avoid typing in the samples.

You may also be interested in...

Comments and Discussions

 
GeneralPlease show me a program that runs on the screen. Pin
supermon212-Jul-10 18:18
groupsupermon212-Jul-10 18:18 
Questionprob with StatusMessage property Pin
c-n-sourceteam8-Apr-07 0:02
memberc-n-sourceteam8-Apr-07 0:02 
AnswerRe: prob with StatusMessage property Pin
c-n-sourceteam8-Apr-07 1:59
memberc-n-sourceteam8-Apr-07 1:59 
Generalmore toolbar problem Pin
amoba22-Sep-05 3:37
memberamoba22-Sep-05 3:37 
GeneralNice way of doing this...BUT... Pin
TomasOBraonain8-Oct-04 4:39
memberTomasOBraonain8-Oct-04 4:39 
GeneralRe: Nice way of doing this...BUT... Pin
SeveredCross6-Jul-05 7:36
memberSeveredCross6-Jul-05 7:36 
GeneralRe: Nice way of doing this...BUT... Pin
brucemo21-Sep-05 21:27
memberbrucemo21-Sep-05 21:27 
GeneralStill can't get localization to work Pin
Ian McCarthy6-Oct-04 1:27
memberIan McCarthy6-Oct-04 1:27 
GeneralClick_Event()... Pin
Per Rollvang7-Mar-04 16:22
memberPer Rollvang7-Mar-04 16:22 
GeneralRe: Click_Event()... Pin
DCEdwards19665-May-04 6:39
memberDCEdwards19665-May-04 6:39 
GeneralRe: Click_Event()... Pin
wilsonstl8-Sep-04 10:51
memberwilsonstl8-Sep-04 10:51 
GeneralRe: Click_Event()... Pin
Klepton2-Dec-04 19:22
memberKlepton2-Dec-04 19:22 
GeneralDocking Menu Pin
mantujap5-Feb-04 4:15
membermantujap5-Feb-04 4:15 
GeneralRe: Docking Menu Pin
spvarapu30-Apr-05 20:46
memberspvarapu30-Apr-05 20:46 
Hi Mahantesh

You got any solution for this docking menu bar, i am looking for this feature, i think u got some solution regarding this...

Please help me....

Thanks in advance


Sreenivasulu Palavarapu
Lera Technologies,
Secunderabad.
GeneralGreat Article! Pin
roelang@hotmail.com25-Sep-03 20:01
memberroelang@hotmail.com25-Sep-03 20:01 
GeneralRe: Great Article! Pin
LimeyRedneck7-Feb-05 8:05
memberLimeyRedneck7-Feb-05 8:05 
GeneralRe: Great Article! Pin
spvarapu30-Apr-05 20:49
memberspvarapu30-Apr-05 20:49 
Generaladding Localizable status messages Pin
bobbisson6-Apr-03 22:26
memberbobbisson6-Apr-03 22:26 
GeneralRe: adding Localizable status messages Pin
bobbisson22-Apr-03 0:21
memberbobbisson22-Apr-03 0:21 
GeneralGood Article Pin
Srinivasa Raghavan28-Mar-03 0:32
memberSrinivasa Raghavan28-Mar-03 0:32 
GeneralTip: Storing and Restoring the Status Text Pin
amberstar16-Feb-03 1:22
memberamberstar16-Feb-03 1:22 
GeneralRe: Tip: Storing and Restoring the Status Text Pin
Le_MuLoT28-Nov-05 8:21
memberLe_MuLoT28-Nov-05 8:21 
GeneralRe: Tip: Storing and Restoring the Status Text Pin
jefrubio4-May-06 1:26
memberjefrubio4-May-06 1:26 
GeneralLocalization Pin
Thomas S. Andersen7-Nov-02 22:12
sussThomas S. Andersen7-Nov-02 22:12 
GeneralRe: Localization Pin
psdavis11-Nov-02 5:23
memberpsdavis11-Nov-02 5:23 
GeneralRe: Localization Pin
Thomas S. Andersen11-Nov-02 23:59
sussThomas S. Andersen11-Nov-02 23:59 
Questionwhat about the dll Pin
Rüpel11-Apr-02 20:51
memberRüpel11-Apr-02 20:51 
AnswerRe: what about the dll Pin
Rick York11-Apr-02 20:55
memberRick York11-Apr-02 20:55 
GeneralRe: what about the dll Pin
Rüpel11-Apr-02 21:38
memberRüpel11-Apr-02 21:38 
AnswerRe: what about the dll Pin
psdavis12-Apr-02 3:49
memberpsdavis12-Apr-02 3:49 
AnswerAlso, what about the MDI form? Pin
dolphinegd30-Oct-03 22:30
memberdolphinegd30-Oct-03 22:30 
GeneralRe: Also, what about the MDI form? Pin
LimeyRedneck7-Feb-05 8:01
memberLimeyRedneck7-Feb-05 8:01 

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
Web04 | 2.8.150603.1 | Last Updated 9 Apr 2002
Article Copyright 2002 by Zombies with Coffee, LLC
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid