Click here to Skip to main content
15,889,116 members
Articles / Desktop Programming / MFC

Switch to and create new desktops under Win2K, WinXP

Rate me:
Please Sign up or sign in to vote.
4.85/5 (21 votes)
31 Oct 2003CPOL 110.1K   1.9K   66   27
Description and sample program on how to switch to and create new desktops under Windows2K and WindowsXP systems.

Sample Image - Desktop_Switcher.jpg

Introduction

After working with systems like Linux, I was surprised about the missing feature of virtual desktops under Windows systems.

Nevertheless they ARE supported by MS, but there is currently no tool to work with them. All tools (like Stardocks tools, NVidia tools) are limited by one very important feature: if an application on an active screen is blocking, the whole switch is impossible. So I wrote a little program to handle virtual desktops. There is also a configuration dialog, used to configure the default shell of a desktop. Normally this is the explorer.exe, but you can also define other programs. Just select the executable and possible parameters used on startup of the shell process.

The main class handling all the related stuff is encapsulated in CMFDeskTopHelper.

Also, there are some helper classes for:

  • creating single input window,
  • processing the registry,
  • parsing input keys and
  • getting hotkey values.

Comment

The sources are not well documented (and not completely new, the Platform SDK also provides a similar program, btw), and also full of crappy code. But you can use it as a base code to develop your own application.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Business Analyst UPC AT B2B customers
Austria Austria
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralNew version Pin
MikeTheDwarf23-May-08 8:27
MikeTheDwarf23-May-08 8:27 
QuestionAbout Change Desktop --help? Pin
anti_ftn16-Dec-04 16:17
anti_ftn16-Dec-04 16:17 
AnswerRe: About Change Desktop --help? Pin
MikeTheDwarf16-Dec-04 20:50
MikeTheDwarf16-Dec-04 20:50 
AnswerRe: About Change Desktop --help? Pin
MikeTheDwarf14-Feb-09 8:46
MikeTheDwarf14-Feb-09 8:46 
QuestionHow to add hot-key to default desktop Pin
u85265054-Dec-03 19:01
u85265054-Dec-03 19:01 
AnswerRe: How to add hot-key to default desktop Pin
MikeTheDwarf15-Nov-04 20:34
MikeTheDwarf15-Nov-04 20:34 
GeneralMy system halt after opening Acrobat Reader in different desktop Pin
Anonymous2-Dec-03 22:19
Anonymous2-Dec-03 22:19 
GeneralRe: My system halt after opening Acrobat Reader in different desktop Pin
MikeTheDwarf3-Dec-03 22:03
MikeTheDwarf3-Dec-03 22:03 
GeneralYou need to go for... Pin
Daniel Turini6-Nov-03 2:48
Daniel Turini6-Nov-03 2:48 
QuestionUser and desktop? Pin
valtech_answer6-Nov-03 2:15
valtech_answer6-Nov-03 2:15 
Generalwhat's about deleting Pin
captain-blaubaer4-Nov-03 19:09
captain-blaubaer4-Nov-03 19:09 
GeneralRe: what's about deleting Pin
alpu4-Nov-03 19:34
alpu4-Nov-03 19:34 
GeneralRe: what's about deleting Pin
MikeTheDwarf4-Nov-03 20:35
MikeTheDwarf4-Nov-03 20:35 
GeneralRe: what's about deleting Pin
captain-blaubaer5-Nov-03 2:56
captain-blaubaer5-Nov-03 2:56 
GeneralRe: what's about deleting Pin
MikeTheDwarf5-Nov-03 3:13
MikeTheDwarf5-Nov-03 3:13 
Generalhope you're aware that... Pin
gaamoa1-Nov-03 20:56
gaamoa1-Nov-03 20:56 
GeneralRe: hope you're aware that... Pin
MikeTheDwarf2-Nov-03 1:53
MikeTheDwarf2-Nov-03 1:53 
GeneralRe: hope you're aware that... Pin
Blake Coverett2-Nov-03 4:53
Blake Coverett2-Nov-03 4:53 
GeneralRe: hope you're aware that... Pin
valtech_answer6-Nov-03 2:21
valtech_answer6-Nov-03 2:21 
GeneralWindows explorer in new desktop Pin
rromerot1-Nov-03 14:58
rromerot1-Nov-03 14:58 
GeneralRe: Windows explorer in new desktop Pin
Blake Coverett1-Nov-03 15:28
Blake Coverett1-Nov-03 15:28 
GeneralVarious Notes Pin
Blake Coverett1-Nov-03 9:23
Blake Coverett1-Nov-03 9:23 
Glad to see there are a few others who use the real desktop support in the NT based versions of Windows. I keep meaning to post an article about the tool I wrote do to this back around the NT 3.51 era; I can't stand using a machine without it.

Some feedback, in no particular order:

~ There is no need to run an instance of your application on every desktop. A process is bound to a specific WindowStation, but each thread can be attached to a different desktop. It would be both more efficient, and easier to code, if you just created a thread per desktop instead of a whole process.
~ You shouldn't use an 'sz' hungarian prefix on both LPTSTRs and CStrings.
~ Seems you missed the API function ExpandEnvironmentStrings(), no need to reimplement it.
~ Why force a big heavy shell on each new desktop? You are already hooking hotkeys, how about letting them launch apps that way. (Explorer used to have some issues with being run in multiple instances, btw, it likely still does.)
~ I'm unclear why you are wrapping a mutex around your desktop enumeration. What purpose does this serve?

regards,
-Blake
GeneralRe: Various Notes Pin
MikeTheDwarf2-Nov-03 1:52
MikeTheDwarf2-Nov-03 1:52 
GeneralRe: Various Notes Pin
MikeTheDwarf7-Apr-09 1:27
MikeTheDwarf7-Apr-09 1:27 
GeneralDoes Not Build Pin
Bill Gates Antimatter Particle1-Nov-03 7:20
Bill Gates Antimatter Particle1-Nov-03 7:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

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