Every application has an AppID which is automatically generated for it from the name of the executable and path + some metadata. You might choose that your application shows as different icons based on different criteria ? say parameters from a shortcut or application launch buttons. To do this all you need to do is change the AppID for the running app. You can also do the reverse: have two different apps to combine under a single icon by using the same AppID in both ? say in an application suite launcher.
To do this in our sample app, drop in a button and in the click event add the following:
private void btnAppID_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start(Application.ExecutablePath, "Random"); }
This basically starts up the same app with a command line argument of 'Random.' You should also add the following in the form's constructor:
public Form1() {InitializeComponent(); String[] AppID = System.Environment.GetCommandLineArgs(); if (AppID.Count() > 1) Taskbar.AppId = AppID[1]; }
This code checks whether the application had a startup argument and if it did, the application ID is changed to this new value. When you run the application normally, it will group the windows under the same icon. However, if you use the button you created above to launch a new window you will see a new icon appear on the Taskbar. You can use combinations of these to get the effect you want quite nicely.
Progress status icons The next feature we'll take a look at is the ability for icons on the taskbar to display progress bars. For instance, when you copy a file to a different folder or download a file using IE, you will be able to see the progress bar in the icon itself.
To add this in your application, first drop a ComboBox, Button and ProgressBar control on the form. Add the values: ?Normal?, ?Error?, ?Paused?, ?Indeterminate? and ?NoProgress? to the ComboBox. Now add the following in the button's click event:
private void btnProgress_Click(object sender, EventArgs e) { if (progressBar1.Value > progressBar1.Maximum) progressBar1.Value = progressBar1.Minimum; progressBar1.Increment(10); switch (comboBox1.SelectedItem.ToString()) { case "Normal": Taskbar.ProgressBar.State = TaskbarButtonProgressState.Normal; break; case "Error": Taskbar.ProgressBar.State = TaskbarButtonProgressState.Error; break; case "Paused": Taskbar.ProgressBar.State = TaskbarButtonProgressState.Paused; break; case "Indeterminate": Taskbar.ProgressBar.State = TaskbarButtonProgressState.Indeterminate; break; case "NoProgress": Taskbar.ProgressBar.State = TaskbarButtonProgressState.NoProgress; break; default: Taskbar.ProgressBar.State = TaskbarButtonProgressState.Normal; break; } Taskbar.ProgressBar.CurrentValue = progressBar1.Value; }
Get most out of your technology infrastructure investments with Dell
About CIOL | Media Kit | Site Map | Contact Us | Help | Write to us | Jobs@CyberMedia | Privacy Policy
Copyright © CyberMedia India Online Ltd. All rights reserved. Usage of content from web site is subject to Terms and Conditions.