application causing orange flashing in taskbar - c#

Sometimes when our application launches it flashes orange in the taskbar. I don't think we explicitly wrote any code to do this but it still happens. Our program is a c# winforms app that sometimes takes a while to load. Any ideas what could be causing this and how I can prevent it?

I believe you can use MSDN's flashwinfo .
Edit - Here's some more info .

From my experience, if the application isn't the current application the user is using, but does something 'on its own' to update the UI(?) the system recognizes this and notifies the user by the orange flash thing.
So if your application is doing some long processing and the user clicks away to another application/window, they probably will get the orange flash.

A possible alternative would be to prevent the application from showing in the Taskbar until loading has completed.
So, something along the lines of:
// prevent from showing in the constructor (or via the designer)
public MyAppMainForm()
{
this.ShowInTaskbar = false;
// other initialization
}
// now you're ready to show in the Taskbar
private void MyAppMainForm_Load(object sender, EventArgs e)
{
this.ShowInTaskbar = true;
}

Related

Black areas on inherited ToolStrip [duplicate]

I use StatusStrip that contains ToolStripStatusLabel. OS - Windows 7, framework 2.0.
Usually all displayed normal, but sometimes ToolStripStatusLabel looks like black box:
I read that windows bug, but how I can fix it?
This is an obscure bug, triggered when you display the form with the Windows toolbar overlapping your StatusStrip. Moving the window away from the toolbar doesn't get the ToolStripItems on the status strip repainted properly. You'll find a bit of background in this forum post. There was a weak promise for a future fix for it, no idea if that ever happened. Probably not if you are running this on Win7.
You'll need to pay more attention to the position of the window, making sure that parts of it don't disappear underneath the toolbar. In general something you'd always consider, extra important as long as this bug doesn't get fixed. If you don't want to nail down the startup position (you ought to, users tend to like a window getting redisplayed where they last moved it) then simply change the form's StartPosition property to "CenterScreen".
This bug has never been fixed. It was in framework 2 and is still in framework 4.
The answer from Hans is a copy of the answer in social.msdn.microsoft.com.
But it is not helpful for me because "CenterScreen" does not solve the problem.
The cause of the problem is not the Windows Taskbar. The cause is a bug that does not draw the StatusStrip when the main Form is behind ANY other window at the first moment of drawing the StatusStrip. But this will also happen when you start the new process with Process.Start() from another process and the new process opens behind the window of another process.
I found a much better solution than the one proposed by Microsoft.
First I tried with
statusStrip.Invalidate();
but it does not work. So we need a stronger way to force Windows to redraw the StatusStrip. Important: The redrawing must happen when the Form with the StatusStrip is ALREADY in foreground! This is so easy that I don't understand why Microsoft does not suggest this method.
Timer mi_StatusTimer = new Timer();
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
mi_StatusTimer.Interval = 500;
mi_StatusTimer.Tick += new EventHandler(OnTimerBugFix);
}
protected override void OnActivated(EventArgs e)
{
base.OnActivated(e);
mi_StatusTimer.Start();
}
void OnTimerBugFix(object sender, EventArgs e)
{
mi_StatusTimer.Stop();
statusStrip.Hide();
Application.DoEvents();
statusStrip.Show();
}

Display window over full screen application

I'm working on a .Net (WPF/C#) application, the application displays notifications (similar to Growl notifications on OS X) at different times, I would like the notifications to display above all other windows, including when there is a full screened app (like a PowerPoint presentation).
Is there anyway to display a Window over a full screened app?
Did you try to set TopMost = true parameter of this window?
also check this thread:
Form top most?
or you can use Popup instead, it will on top of any window or control.
WPF.
private void Window_Deactivated(object sender, EventArgs e)
{
Thread.Sleep(2000);
this.Topmost = true;
}
But this is not the best option.
In full screen mode there is exclusive access to the display, and you can only display on top of this if you are allowed to implement it if it's a game in OpenGL, DirectX and BackBuffer to impose your data.

C# WinForms Wait on form to proceed

I'm tired and hungry, so I might of missed it, but from what I can see no existing post covers this...
I'm writing a plugin for an application. My plugin loads a form to get some data specifically, it uses the webcam to scan for a barcode. Once it's found a barcode, the form hides itself (incase it's needed again later). This is how I currently call the form that does the barcode work:
string readData = null;
if (eye == null)
{
System.Windows.Forms.Application.EnableVisualStyles();
eye = new CamView();
}
eye.Show();
if (eye.found)
{
readData = eye.readData;
}
return readData;
So, my problem is that eye.show() doesn't block. It makes the form appear and carries right on before there's a chance for the barcode to appear. I imagine I need to use some form of threading or locking, but my crude attempts to do so have just frozen the interface completely.
The "eye" form is basically just a viewfinder for the webcam, and relies on the camera_OnImageCapture event to make it do it's image checks for the barcode.
Is there an elegant way to make the application calling the plugin wait for the form to finish? Or do I just need to add an accept button to the "eye form?"
Cheers. And humble apologies if this is in anyway a repost.
.ShowDialog();
http://msdn.microsoft.com/en-us/library/c7ykbedk.aspx
"You can use this method to display a modal dialog box in your application. When this method is called, the code following it is not executed until after the dialog box is closed."
You are on the right track. You change the code to show CamView as a modal dialog but do no add an Accept button. Instead change camera_OnImageCapture to close the dialog.

Force NotifyIcon to appear in system tray

I have a NotifyIcon that appears in the system tray and I want to show a balloon tip the first time stuff the application is idle (As suggested here: C# execute code after application.run() ) but the Idle event happens before the Icon appears in the System tray, causing the balloon to not appear. How can I force the NotifyIcon to appear before I call ShowBalloonTip?
This is a fairly fundamental race, it is another process that takes care of the icon. Windows Explorer. You can't tell when it took care of things. Calling Thread.Sleep(500) after setting Visible = true ought to improve the odds significantly.
Do consider displaying the icon when your program starts.
Why not set a flag on idle and then check the state of the flag after setting the notify icon to visible:
// Application has become idle
firstTimeIdle = true;
Then:
// Show notify icon
notifyIcon.Visible = true;
if (firstTimeIdle && !shownBalloon)
{
notifyIcon.ShowBalloonTip(timeout, title, text, icon);
shownBalloon = true;
}

Creating a Popup Balloon like Windows Messenger or AVG

How can I create a Popup balloon like you would see from Windows Messenger or AVG or Norton or whomever?
I want it to show the information, and then slide away after a few seconds.
Edit: It needs to be blocking like Form.ShowDialog() because the program exits after displaying the notification
You can use the notifyIcon control that's part of .NET 2.0 System.Windows.Forms. That allows you to place an icon for your application in the System Tray. Then, you can call the ShowBalloonTip(int timeOut) method on that. Be sure however to first set the text, and icon properties on the notifyIcon for it to work. Small code sample:
private void button1_Click(object sender, EventArgs e)
{
this.notifyIcon1.BalloonTipText = "Whatever";
this.notifyIcon1.BalloonTipTitle = "Title";
this.notifyIcon1.Icon = new Icon("icon.ico");
this.notifyIcon1.Visible = true;
this.notifyIcon1.ShowBalloonTip(3);
}
EDIT: Ok, so notifyIcon won't work for you. My second suggestion would then be to create your own control for this. Actually, I would use a form. A simple form, with no borders, and no control box and just have a timer running so you can set the Opacity for fade in/out. Then, you can easily get the bottom right of the screen using the Rectangle Screen.PrimaryScreen.WorkingArea. Then just show your form at that position.
Don't create a modal (blocking) balloon. Please. A big part of the design of these UIs is that they are not dialogs: they're transient, potentially non-interactive elements, intended to provide incidental information to a user without necessarily interrupting their workflow. A balloon that steals focus and blocks user input would be irritating at best - if you need a dialog, then use a dialog.
The .NET 1.1 Visual Basic Power Pack had a toaster control.

Categories