(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)? 5 9458
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 GetForgroundWin dow and
FlashWindow.
The GetForegroundWi ndow 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 GetForegroundWi ndow function is:
HWND GetForegroundWi ndow(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("user 32.dll")]
public extern static bool FlashWindow(Int Ptr hwnd,bool bInvert);
[DllImport("user 32.dll")]
public extern static IntPtr GetForegroundWi ndow();
}
public class Form1
{
private System.Windows. Forms.Timer timer1;
public Form1()
{
this.timer1 = new
System.Windows. Forms.Timer(thi s.components);
this.timer1.Int erval = 1000;
this.timer1.Tic k += new
System.EventHan dler(this.timer 1_Tick);
}
private void Form1_Load(obje ct sender, System.EventArg s e)
{
this.timer1.Sta rt();
}
private void timer1_Tick(obj ect sender, System.EventArg s e)
{
IntPtr foregroundWin = Class1.GetForeg roundWindow();
// if the current foreground window isn't
this window, flash this window in task bar once every 1 second
if (foregroundWin != this.Handle)
{
Class1.FlashWin dow(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.Sto p();
}
}
}
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.
=============== =============== =============== =======
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.mic rosoft.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.
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.
=============== =============== =============== =======
Thanks for the information--that was what I needed.
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.
=============== =============== =============== ======= This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 must be set appropriately.
3. Add some public properties to the form that directly adjust the exposed private Control properties:
public class...
|
by: DaKoadMunky |
last post by:
<CODE>
#include <iostream>
using namespace std;
int Foo(int x,int y)
{
int result = x;
result*=y;
result+=y;
|
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 that taskbar clock
foreground changes to black.
So my question is, how do I get that color programmatically?
Thanks!
|
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 is in normal/maximized view, clickinng on the taskbar entry
does not minimize the
application. Normally (with apps with titlebar), the application...
|
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 top" feature? I would like my program to
automatically "hide" the taskbar when running.
Thanks.
John
| |
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 the screen.
However, if the form is minimised, and then maximised, the taskbar is
covered by the form; even though the taskbar is locked.
Can...
|
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 with the code. Cant seem to make
it work. Would really appreciate any code given.. Thank you so much! I really
need this one. Thank you in advance....
|
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 reproduce this by showing the
following form:
Public Class Form1
Inherits Windows.Forms.Form
Public Sub New()
MyBase.New()
Me.ControlBox =...
|
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 window is in its "normal" state i.e. not maximised, and not minimised
to the taskbar.
We click each of the three taskbar buttons in turn and, of...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |