mshtml: Better timer handling.
[wine/wine-jacek.git] / programs / winecfg / main.c
blobf9f561dbe8754862b6ef039f9a87958a711988e6
1 /*
2 * WineCfg main entry point
4 * Copyright 2002 Jaco Greeff
5 * Copyright 2003 Dimitrie O. Paun
6 * Copyright 2003 Mike Hearn
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define WIN32_LEAN_AND_MEAN
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
29 #include <windows.h>
30 #include <commctrl.h>
31 #include <objbase.h>
32 #include <wine/debug.h>
34 #include "resource.h"
35 #include "winecfg.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
39 static INT CALLBACK
40 PropSheetCallback (HWND hWnd, UINT uMsg, LPARAM lParam)
42 switch (uMsg)
45 * hWnd = NULL, lParam == dialog resource
47 case PSCB_PRECREATE:
48 break;
50 case PSCB_INITIALIZED:
51 break;
53 default:
54 break;
56 return 0;
59 static INT_PTR CALLBACK
60 AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
62 switch (uMsg) {
64 case WM_NOTIFY:
65 if (((LPNMHDR)lParam)->code != PSN_SETACTIVE) break;
66 /* otherwise fall through, we want to refresh the page as well */
67 case WM_INITDIALOG:
68 break;
70 case WM_COMMAND:
71 break;
73 default:
74 break;
77 return FALSE;
80 #define NUM_PROPERTY_PAGES 7
82 static INT_PTR
83 doPropertySheet (HINSTANCE hInstance, HWND hOwner)
85 PROPSHEETPAGEW psp[NUM_PROPERTY_PAGES];
86 PROPSHEETHEADERW psh;
87 int pg = 0; /* start with page 0 */
90 * Fill out the (Applications) PROPSHEETPAGE data structure
91 * for the property sheet
93 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
94 psp[pg].dwFlags = PSP_USETITLE;
95 psp[pg].hInstance = hInstance;
96 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_APPCFG);
97 psp[pg].u2.pszIcon = NULL;
98 psp[pg].pfnDlgProc = AppDlgProc;
99 psp[pg].pszTitle = load_string (IDS_TAB_APPLICATIONS);
100 psp[pg].lParam = 0;
101 pg++;
104 * Fill out the (Libraries) PROPSHEETPAGE data structure
105 * for the property sheet
107 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
108 psp[pg].dwFlags = PSP_USETITLE;
109 psp[pg].hInstance = hInstance;
110 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DLLCFG);
111 psp[pg].u2.pszIcon = NULL;
112 psp[pg].pfnDlgProc = LibrariesDlgProc;
113 psp[pg].pszTitle = load_string (IDS_TAB_DLLS);
114 psp[pg].lParam = 0;
115 pg++;
118 * Fill out the (X11Drv) PROPSHEETPAGE data structure
119 * for the property sheet
121 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
122 psp[pg].dwFlags = PSP_USETITLE;
123 psp[pg].hInstance = hInstance;
124 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_GRAPHCFG);
125 psp[pg].u2.pszIcon = NULL;
126 psp[pg].pfnDlgProc = GraphDlgProc;
127 psp[pg].pszTitle = load_string (IDS_TAB_GRAPHICS);
128 psp[pg].lParam = 0;
129 pg++;
131 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
132 psp[pg].dwFlags = PSP_USETITLE;
133 psp[pg].hInstance = hInstance;
134 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DESKTOP_INTEGRATION);
135 psp[pg].u2.pszIcon = NULL;
136 psp[pg].pfnDlgProc = ThemeDlgProc;
137 psp[pg].pszTitle = load_string (IDS_TAB_DESKTOP_INTEGRATION);
138 psp[pg].lParam = 0;
139 pg++;
141 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
142 psp[pg].dwFlags = PSP_USETITLE;
143 psp[pg].hInstance = hInstance;
144 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DRIVECFG);
145 psp[pg].u2.pszIcon = NULL;
146 psp[pg].pfnDlgProc = DriveDlgProc;
147 psp[pg].pszTitle = load_string (IDS_TAB_DRIVES);
148 psp[pg].lParam = 0;
149 pg++;
151 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
152 psp[pg].dwFlags = PSP_USETITLE;
153 psp[pg].hInstance = hInstance;
154 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_AUDIOCFG);
155 psp[pg].u2.pszIcon = NULL;
156 psp[pg].pfnDlgProc = AudioDlgProc;
157 psp[pg].pszTitle = load_string (IDS_TAB_AUDIO);
158 psp[pg].lParam = 0;
159 pg++;
162 * Fill out the (General) PROPSHEETPAGE data structure
163 * for the property sheet
165 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
166 psp[pg].dwFlags = PSP_USETITLE;
167 psp[pg].hInstance = hInstance;
168 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_ABOUTCFG);
169 psp[pg].u2.pszIcon = NULL;
170 psp[pg].pfnDlgProc = AboutDlgProc;
171 psp[pg].pszTitle = load_string (IDS_TAB_ABOUT);
172 psp[pg].lParam = 0;
173 pg++;
176 * Fill out the PROPSHEETHEADER
178 psh.dwSize = sizeof (PROPSHEETHEADERW);
179 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
180 psh.hwndParent = hOwner;
181 psh.hInstance = hInstance;
182 psh.u.pszIcon = NULL;
183 psh.pszCaption = load_string (IDS_WINECFG_TITLE);
184 psh.nPages = NUM_PROPERTY_PAGES;
185 psh.u3.ppsp = psp;
186 psh.pfnCallback = PropSheetCallback;
187 psh.u2.nStartPage = 0;
190 * Display the modal property sheet
192 return PropertySheetW (&psh);
195 /******************************************************************************
196 * Name : ProcessCmdLine
197 * Description: Checks command line parameters for 'autodetect drives' option
198 * Parameters : lpCmdLine - the command line
199 * Returns : TRUE - if '/D' was found. Drive autodetection was carried out.
200 * FALSE - no '/D' option found in command line
201 * Notes : This is a very simple implementation, which only works
202 * correctly if the one and only cmd line option is '/D' or
203 * no option at all. Has to be reworked, if more options are to
204 * be supported.
206 static BOOL
207 ProcessCmdLine(LPSTR lpCmdLine)
209 if ((lpCmdLine[0] == '/' || lpCmdLine[0] == '-') &&
210 (lpCmdLine[1] == 'D' || lpCmdLine[1] == 'd'))
212 gui_mode = FALSE;
213 if (autodetect_drives()) {
214 apply_drive_changes();
216 return TRUE;
219 return FALSE;
222 /*****************************************************************************
223 * Name : WinMain
224 * Description: Main windows entry point
225 * Parameters : hInstance
226 * hPrev
227 * szCmdLine
228 * nShow
229 * Returns : Program exit code
231 int WINAPI
232 WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
234 if (ProcessCmdLine(szCmdLine)) {
235 return 0;
238 if (initialize(hInstance) != 0) {
239 WINE_ERR("initialization failed, aborting\n");
240 ExitProcess(1);
244 * The next 9 lines should be all that is needed
245 * for the Wine Configuration property sheet
247 InitCommonControls ();
248 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
249 if (doPropertySheet (hInstance, NULL) > 0) {
250 WINE_TRACE("OK\n");
251 } else {
252 WINE_TRACE("Cancel\n");
254 CoUninitialize();
255 ExitProcess (0);
257 return 0;