Displaying a help- string in the status bar

  • Thread starter Thread starter Hinnerk Feldwisch
  • Start date Start date
H

Hinnerk Feldwisch

Hello,

I'm writing a program with VB.NET at the moment, and want to have an easy
possibility to display a help string in the status bar when the user places
the mouse over a control.
I know that there was an easy way some years ago, when I used Delphi 3 or VB
4; but I didn't find it anymore - is it still possible?

Then I tried to filter a appropiate message from the message queue, and
installed a filter with application.addMessagefilter() (or similar). I also
overwrote the WndProc- procedure. But I'm not sure which WM I shall filter;
I heard about WM_SETCURSOR, this should be called not for the controls but
for the parent form.
This doesn't work though...

Any help?
Thank you very much!,
Hinnerk
 
Hinnerk,
I would handle the MouseMove or MouseEnter & MouseLeave event for each
control, If the mouse moves over the control update the status text,
otherwise clear it.

I would consider creating an ExtenderProvider to implement this. (Implement
the System.ComponentModel.IExtenderProvider interface). Which allows you to
put the StatusBarExtenderProvider component on your form, then this
component adds properties to all your other controls. Internally
StatusBarExtenderProvider maintains a collections of each control with the
properties, it would also handle the MouseMove event (or MouseEnter &
MouseLeave) for each control, updating the Status Bar as needed.

StatusBarExtenderProvider can use AddHandler & RemoveHandler to attach event
handlers to the controls being tracked.

I do not have a clear example handy right now.

ErrorProvider, HelpProvider and ToolTip are examples of Extender Providers
available in the Framework.

Hope this helps
Jay
 
Jay B. Harlow said:
I would handle the MouseMove or MouseEnter & MouseLeave event for each
control, If the mouse moves over the control update the status text,
otherwise clear it.

I would consider creating an ExtenderProvider to implement this. (Implement
the System.ComponentModel.IExtenderProvider interface). Which allows you to
put the StatusBarExtenderProvider component on your form, then this
component adds properties to all your other controls. Internally
StatusBarExtenderProvider maintains a collections of each control with the
properties, it would also handle the MouseMove event (or MouseEnter &
MouseLeave) for each control, updating the Status Bar as needed.

Hello Jay,

thank you very much, that was exactly the idea I needed! IExtenderProvider
is the way to go...

Thanks again,
Hinnerk
 
I'm writing a program with VB.NET at the moment, and want to have an easy
possibility to display a help string in the status bar when the user places
the mouse over a control.

This is an ideal job for an extender-provider. An extender provider
associates some data with a chosen group of objects, possibly those based on
Control or MenuItem or whatever.

The Extender Provider would handle the mouse enter event and then provide a
nother event that you could use to update the status bar.

Last months issue of Well Formed had an atricle on creating
extender-providers that updated a status bar for a MenuItem. This
functionality could easily be adapted to provide a status message for chosen
controls.

Check out the contents of that issue here
http://www.bobpowell.net/August2003.htm There are C# and VB editions.

--
Bob Powell [MVP]
C#, System.Drawing

September's edition of Well Formed is now available.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm
 
Another technique to try is one I picked up from Francesco Balena's
excellent book "Programming Microsoft Visual Basic .NET"

Basically, in your form, you hook into the Application object's Idle event
(which is conveniently fired after a mouse move message is processed by the
form). We work in C# at work, so the code is in C#, but it should be easy
enough to translate - just change the event handler to have a Handles
clause, and remove the delegate assignment in the Form Load event:

private void Form1_Load(object sender, System.EventArgs e)

{

Application.Idle += new System.EventHandler(this.Application_Idle);

}

private void Application_Idle(object sender, EventArgs e)

{

Control ctrl = this.GetChildAtPoint(this.PointToClient(Cursor.Position));

if(ctrl != null)

{

this.statusBar1.Text = ctrl.Name;

}

}
 
Back
Top