Re: Change status bar text back to default 5 seconds after every change?
- From: "ssamuel" <ssamuel@xxxxxxxxx>
- Date: 13 Nov 2006 14:24:45 -0800
cdj,
Create a custom control. Inside it, do what you're currently doing. I
assume you're doing something like using OnChange to start a timer and
using the timer's callback to reset the status bar's data. To prevent
the endless loop, add a boolean member variable. Try this:
public class myControl : StatusBar
{
private boolean bDefault = true;
private Timer timeReset = new Timer(...);
public void OnChange(...)
{
if (!this.bDefault)
this.timeReset.Reset();
}
public void OnTimerTick(...)
{
this.bDefault = true;
// set text back to default
Text = "Ready.";
}
public void SetText(string text)
{
this.bDefault = false;
Text = text;
}
}
I don't guarantee this code compiles, it's more to demonstrate a point.
You probably want to use a property override instead of SetText(), but
I wrote it that way for clarity. Also, I've not dealt with thread
safety.
Stephan
sherifffruitfly wrote:
Hi,
I'm using StatusBar text to inform the user what's going on in the
application. I pass a reference to from the main form's class to other
(instances of) classes that are doing the actual work, and they update
the Text property in various ways.
It would be slick (imo) if, after the user is informed about the antics
of some class-instance, if the StatusBar text would revert back to some
default text-variable in the main form class after some specified
interval of time (like 5 seconds).
Problem is, that I can't use the StatusBar's OnChange event (or
whatever's it's called) - if I did, then every time the "reversion" was
perform, the event would fire again.
So how would I go about implementing this? Even just a skeleton
code-example would be helpful.
Thanks for any ideas,
cdj
.
- Follow-Ups:
- Re: Change status bar text back to default 5 seconds after every change?
- From: sherifffruitfly
- Re: Change status bar text back to default 5 seconds after every change?
- References:
- Change status bar text back to default 5 seconds after every change?
- From: sherifffruitfly
- Change status bar text back to default 5 seconds after every change?
- Prev by Date: Re: Change status bar text back to default 5 seconds after every change?
- Next by Date: Re: Positioning a Window
- Previous by thread: Re: Change status bar text back to default 5 seconds after every change?
- Next by thread: Re: Change status bar text back to default 5 seconds after every change?
- Index(es):
Relevant Pages
|