Flush current work
[desktopswitcher.git] / switcher.cpp
blobf4f9329a6e1717411417d691869b140b5d8049a2
1 // $Id: switcher.cpp,v 1.3 2002/06/29 16:00:28 nedko Exp $
2 //
3 // Desktop Switcher
4 // Copyright (C) 2000,2001,2002 Nedko Arnaudov <nedko@users.sourceforge.net>
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "ph.h"
22 #include "switcher.h"
23 #include "DesktopSwitcher.h"
24 #include "png.h"
26 CComModule _Module;
27 CPNGImage g_Image;
29 BEGIN_OBJECT_MAP(ObjectMap)
30 END_OBJECT_MAP()
32 int CALLBACK WinMain(HINSTANCE hInstance,
33 HINSTANCE hPrevInstance,
34 LPSTR lpCmdLine,
35 int nCmdShow)
37 _Module.Init(ObjectMap,hInstance);
38 int cThreads; // number of desktops
40 // parse command line to determine number of desktops
41 // Assume 9 threads
43 cThreads = 12;
44 lpCmdLine = GetCommandLineA();
47 // Get past .exe name
49 while (*lpCmdLine != ' ' && *lpCmdLine != 0)
50 lpCmdLine++;
53 // Find the parameters
55 while (*lpCmdLine != 0)
58 // Eat white space
60 if (*lpCmdLine == ' ')
62 lpCmdLine++;
63 continue;
67 // Do we have a dash? If not, just exit the loop
69 if (*lpCmdLine++ != '-')
70 break;
72 switch (*lpCmdLine++)
74 case 't':
75 case 'T':
77 // How many threads?
80 while (*lpCmdLine == ' ')
81 lpCmdLine++;
83 if (*lpCmdLine == 0 || *lpCmdLine == '-')
84 continue;
86 cThreads = 0;
87 while (*lpCmdLine >= '0' && *lpCmdLine <= '9')
88 cThreads = cThreads * 10 + (*lpCmdLine++ - 0x30);
90 break;
95 g_Image.LoadPNGImage("C:\\topka.png");
97 CDesktopSwitcher TheSwitcher;
98 HRESULT hr = TheSwitcher.Go(cThreads);
99 if (FAILED(hr))
101 char Buffer[256];
102 sprintf(Buffer,"Failed to initialize. Error is 0x%X",hr);
103 ::MessageBox(NULL,Buffer,"Desktop Switcher",MB_OK|MB_ICONSTOP);
106 return 0;