Custom (XP-like) QuickLaunch - CodeProject
Custom (XP-like) QuickLaunch - CodeProject
articles quick answers discussions features community Search for articles, questions, tips
help
Custom (XP-like)
QuickLaunch
Adam Wojnar Rate me: 4.33/5 (2 votes)
Introduction
In times of Windows XP I liked having my desktop just for the data I
worked with and my application launchers (lots of them) separately
at the right side of the screen.
Since Windows Vista (AFAIK), there is no way how to drag the "quick
launch" out of the taskbar and drop it elsewhere. First, I tried to
search for any freeware/shareware that would simulate the XP "quick
launch" behaviour. I haven't found anything similar (just taskbar-
bound gadgets or floating panels with animations which I didn't like).
So I decided to write one. I don't include a complete downloadable
application, just a framework how to create it in a very easy way.
4. Switch to the code. Put this code into the constructor of the
Form1.
C# Shrink ▲
public Form1()
{
InitializeComponent();
int iIdx = 0;
// feed the listView1
foreach (string file in files)
{
// display just the filename
string fileName =
Path.GetFileNameWithoutExtension(file);
ListViewItem item = new ListViewItem(fileName);
// store the complete path
item.Tag = file;
listView1.Items.Add(item);
// set the index of the icon
item.ImageIndex = iIdx++;
}
}
/// <summary>
/// Extracts the shell icon of the executable, shortcut,
document...
/// </summary>
/// <param name="filePath">Path</param>
/// <returns>An Icon instance</returns>
private Icon IconFromFilePath(string filePath)
{
Icon result = null;
try
{
result = Icon.ExtractAssociatedIcon(filePath);
}
catch { }
return result;
}
/// <summary>
/// Prevent the window from unwanted closing
/// (Form1 FormClosing event handler)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form1_FormClosing(object sender,
FormClosingEventArgs e)
{
if (MessageBox.Show("Really quit?", "Confirm",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question) !=
System.Windows.Forms.DialogResult.Yes)
e.Cancel = true;
}
/// <summary>
/// Launch the shortcut (or executable, document...)
/// (listView1 ItemActivate event handler)
/// (the same code can handle listView1 DoubleClick
event, if preferred)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void listView1_ItemActivate(object sender,
EventArgs e)
{
ListViewItem lvi = listView1.SelectedItems[0];
Process proc = new Process();
License
This article, along with any associated source code and files, is
licensed under The Code Project Open License (CPOL)
Written By
Adam Wojnar
Software Developer (Senior)
Czech Republic
Search Comments