0% found this document useful (0 votes)
9 views

Custom (XP-like) QuickLaunch - CodeProject

Uploaded by

Chad Dole
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Custom (XP-like) QuickLaunch - CodeProject

Uploaded by

Chad Dole
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

15,878,430 members Sign in

articles quick answers discussions features community Search for articles, questions, tips

help

Articles / Programming Languages / C#

Vista C# Windows Win7

Custom (XP-like)
QuickLaunch
Adam Wojnar Rate me: 4.33/5 (2 votes)

4 Oct 2013 CPOL 1 min read 11.1K 7 1

An easy implementation of the taskbar-independent "quick launch"

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.

Using the code


1. Sort your desktop icons according to the type and move the
shortcuts (.lnk files) to a folder (e.g., C:\Users\John
Doe\Documents\Panel).
2. Create Windows forms application. I suggest these Form1
properties:
C#
FormBorderStyle = FixedToolWindow
StartPosition = Manual
MaximizeBox = False
MinimizeBox = False
ShowInTaskbar = False

Set the Text, Size, and Location according to your needs.

3. Drop a ListView onto a form and dock it to fill it. I suggest


these listView1 properties:
C#
HeaderStyle = None
Dock = Fill
HoverSelection = True
HotTracking = True
Activation = OneClick

Set the BackColor, Font, and ForeColor according to your


needs.

4. Switch to the code. Put this code into the constructor of the
Form1.
C# Shrink ▲

public Form1()
{
InitializeComponent();

// needed for displaying View.Details


listView1.Columns.Add("Shortcut", -2);

// get collection of the shortcut paths


string[] files = Directory.GetFiles(@"C:\Users\John
Doe\Documents\Panel");
ImageList ilSmall = new ImageList();

// extract the shorcut icons


foreach (string fp in files)
{
ilSmall.Images.Add(IconFromFilePath(fp));
}
listView1.SmallImageList = ilSmall;
listView1.View = View.Details;

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++;
}
}

5. Implement some more methods/handlers.


C# Shrink ▲

/// <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();

// If the application does not start, check the


shortcut.
// There could be Program Files (x86) issue, the
incorrect executable path set.
try
{
// extract the stored file path
proc.StartInfo.FileName = (string)lvi.Tag;
proc.Start();
}
catch { }
}

6. Compile the application and put the executable to your Startup


folder. Log off, log on and enjoy!

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

This member has not yet provided a Biography. Assume it's


interesting and varied, and probably something to do with
programming.
Comments and Discussions

You must Sign in to use this message board.

Search Comments

Spacing Relaxed Layout Normal Per page 25 Update

First Prev Next

Download link Adam Wojnar 3-Oct-13 3:21

Last Visit: 31-Dec-99 18:00 Last Update: 15-Apr-24 5:04 Refresh 1

General News Suggestion Question Bug Answer


Joke Praise Rant Admin

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads,


Ctrl+Shift+Left/Right to switch pages.

Permalink Layout: fixed | fluid Article Copyright 2013 by Adam Wojnar


Advertise Everything else Copyright © CodeProject,
Privacy Posted 2 Oct 2013 1999-2024
Cookies
Terms of Use Web01 2.8:2024-04-02:1

You might also like