473,320 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Taskbar behavior and appearance

(1) By setting an icon in my Windows Form properties, I successfully
display my custom icon when my application is executed. However, as soon
as I open the Options form in my application--now having two windows
open--they are grouped on the taskbar, but with a generic icon. Both my
main form and my Option form are using the same icon. How can I use my
custom icon instead of the generic icon in a .Net 2.0 C# application?

(2) A standard Windows behavior is that TaskBar items will flash when
requesting user attention. How do I create this behavior (make it flash)?
Apr 21 '06 #1
5 9441
Hi Michael,
Thank you for posting.
My answers to your two questions are in the below.
(1) In order to use your custom icon in a winform, you should set the icon
property of each winform to your custom icon separately. There isn't a
global property for a winform project to set winform icon to your custom
icon.

(2) There're two WinAPI functions you can use to enable a Taskbar item
flash when requesting user attention. They are GetForgroundWindow and
FlashWindow.
The GetForegroundWindow function returns the handle to the foreground
window ¡ª the window with which the user is currently working.And the
FlashWindow function flashes the specified window one time. It does not
change the active state of the window.

The syntax of GetForegroundWindow function is:
HWND GetForegroundWindow(VOID);
The return value is a handle to the foreground window.

And the syntax of FlashWindow function is:
BOOL FlashWindow( HWND hWnd, BOOL bInvert);
Parameters:
hWnd
Handle to the window to be flashed. The window can be either open or
minimized.
bInvert
If this parameter is TRUE, the window is flashed from one state to the
other. If it is FALSE, the window is returned to its original state (either
active or inactive).

Return Values:
The return value specifies the window's state before the call to the
FlashWindow function. If the window caption was drawn as active before the
call, the return value is nonzero. Otherwise, the return value is zero.

Since the specified window flashes only once using FlashWindow function,
you should call this function in a timer's tick event handling method in
the specified window.
The following is a sample.
// state the two API functions in Class1
public class Class1
{
[DllImport("user32.dll")]
public extern static bool FlashWindow(IntPtr hwnd,bool bInvert);
[DllImport("user32.dll")]
public extern static IntPtr GetForegroundWindow();
}

public class Form1
{
private System.Windows.Forms.Timer timer1;
public Form1()
{
this.timer1 = new
System.Windows.Forms.Timer(this.components);
this.timer1.Interval = 1000;
this.timer1.Tick += new
System.EventHandler(this.timer1_Tick);
}

private void Form1_Load(object sender, System.EventArgs e)
{
this.timer1.Start();
}
private void timer1_Tick(object sender, System.EventArgs e)
{
IntPtr foregroundWin = Class1.GetForegroundWindow();
// if the current foreground window isn't
this window, flash this window in task bar once every 1 second
if (foregroundWin != this.Handle)
{
Class1.FlashWindow(this.Handle,true);
}
// if this window is the current foreground
window, stop the timer and don't flash this window any more
else
{
this.timer1.Stop();
}
}
}

I hope this is helpful to you.
If you have any other concerns or need anything else, please don't hesitate
to tell me.
Sincerely,
Linda Liu
Microsoft Online Community Support

================================================== ==
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
================================================== ==

Apr 24 '06 #2
You misunderstood my first question. Let me restate it. I know that each
winform must have the icon property set and I have done that. Let me
itemize what works and what does not in my application. I have a main
winform and a child winform (as in an Options window):

In the winforms themselves:
Main winform -- icon OK
Child winform -- icon OK

On the taskbar
Main winform by itself -- icon OK
Main winform and child winform open, but not grouped on taskbar -- icon OK
on both
Main winform and child winform open, grouped on taskbar -- icon BAD (i.e.
generic icon for the group), but clicking on the group icon opens a
"dropdown" showing the individual winforms, both of which have the correct
icon

On Mon, 24 Apr 2006 05:03:07 -0700, Linda Liu [MSFT]
<v-****@online.microsoft.com> wrote:
(1) In order to use your custom icon in a winform, you should set the
icon
property of each winform to your custom icon separately. There isn't a
global property for a winform project to set winform icon to your custom
icon.

Apr 24 '06 #3
Hi Michael,

Thank you for your reply. I am sorry that I misunderstood your first
question.Now I see.

If the main form and the child form open and are grouped on taskbar, the
group icon displayed in the taskbar is the icon of the project.
You can set the project icon using the following steps.
1. Open the project property pages(To open the property pages, select the
menu Project and Properties item, or right-click the project in the
Solution Explorer and select Properties item)
2. Select Common Properties in the left panel and select General item.
There's a Application Icon item in Application group in the right panel.
You can set the Application Icon to your custom icon.

Hope this is helpful to you.
If you have any other concerns or need anything else, please don't hesitate
to tell me.
Sincerely,
Linda Liu
Microsoft Online Community Support

================================================== ==
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
================================================== ==

Apr 25 '06 #4
Thanks for the information--that was what I needed.
May 4 '06 #5
Hi Michael,

You're welcome! It is always our pleasure to be of assistance.
Sincerely,
Linda Liu
Microsoft Online Community Support

================================================== ==
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
================================================== ==

May 5 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dave | last post by:
Hi all, To repro the problem I am having: 1. Create a class that derives from System.Windows.Forms.Form 2. Add some controls such as buttons and labels (wherever you want). The default values...
4
by: DaKoadMunky | last post by:
<CODE> #include <iostream> using namespace std; int Foo(int x,int y) { int result = x; result*=y; result+=y;
5
by: Quoner | last post by:
With XP's default theme (Windows XP style / Default (blue) on the Display Properties/Appearance tab), the taskbar clock foreground color is white. Change that to Windows XP style / Olive Green, and...
3
by: Maka Sili | last post by:
Hi, My VC++ application does not have a titlebar (and therefore no System menu, no minimize, no maximize and no close button). We have a custom button for minimize and close. When the app...
2
by: JohnProgrammer | last post by:
I know I can fill the screen in VB.NET by starting my window maximized and without a border. My question is; in VB.NET is there a way to enable/disable the taskbar much like doing the "always on...
2
by: Geoff Jones | last post by:
Hiya Can anybody help me with the following question? I have an application which has a maximised main form. At startup, the form is maximised but the taskbar is still visible at the bottom of...
2
by: Rain | last post by:
Does anyone know the code in C# or snippet or API so i can hide and show the windows taskbar? Many people have suggested using ShowWindow and FindWindow or the ABM_SETSTATE but i am having problem...
7
by: =?Utf-8?B?bGpsZXZlbmQy?= | last post by:
I've noticed that a form will cover the taskbar when it is maximized if its ControlBox property is set to false (even if the "Keep the taskbar on top of other windows" option is selected). You can...
10
by: Mark Rae [MVP] | last post by:
Hi, This is really just a theoretical question for my own interest, and not for any nefarious purpose... :-) Say we have three applications running - Notepad, Wordpad and Excel - and each...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.