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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 #define NONAMELESSUNION
34 #define NONAMELESSSTRUCT
41 #include <wine/debug.h>
43 #include "properties.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
50 PropSheetCallback (HWND hWnd, UINT uMsg, LPARAM lParam)
55 * hWnd = NULL, lParam == dialog resource
60 case PSCB_INITIALIZED:
68 static INT_PTR CALLBACK
69 AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
74 if (((LPNMHDR)lParam)->code != PSN_SETACTIVE) break;
75 /* otherwise fall through, we want to refresh the page as well */
89 static WCHAR* load_string (UINT id)
95 LoadStringW (GetModuleHandle (NULL), id, buf, sizeof(buf)/sizeof(buf[0]));
98 newStr = HeapAlloc (GetProcessHeap(), 0, (len + 1) * sizeof (WCHAR));
99 memcpy (newStr, buf, len * sizeof (WCHAR));
104 #define NUM_PROPERTY_PAGES 7
107 doPropertySheet (HINSTANCE hInstance, HWND hOwner)
109 PROPSHEETPAGEW psp[NUM_PROPERTY_PAGES];
110 PROPSHEETHEADERW psh;
111 int pg = 0; /* start with page 0 */
114 * Fill out the (Applications) PROPSHEETPAGE data structure
115 * for the property sheet
117 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
118 psp[pg].dwFlags = PSP_USETITLE;
119 psp[pg].hInstance = hInstance;
120 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_APPCFG);
121 psp[pg].u2.pszIcon = NULL;
122 psp[pg].pfnDlgProc = AppDlgProc;
123 psp[pg].pszTitle = load_string (IDS_TAB_APPLICATIONS);
128 * Fill out the (Libraries) PROPSHEETPAGE data structure
129 * for the property sheet
131 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
132 psp[pg].dwFlags = PSP_USETITLE;
133 psp[pg].hInstance = hInstance;
134 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DLLCFG);
135 psp[pg].u2.pszIcon = NULL;
136 psp[pg].pfnDlgProc = LibrariesDlgProc;
137 psp[pg].pszTitle = load_string (IDS_TAB_DLLS);
142 * Fill out the (X11Drv) PROPSHEETPAGE data structure
143 * for the property sheet
145 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
146 psp[pg].dwFlags = PSP_USETITLE;
147 psp[pg].hInstance = hInstance;
148 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_GRAPHCFG);
149 psp[pg].u2.pszIcon = NULL;
150 psp[pg].pfnDlgProc = GraphDlgProc;
151 psp[pg].pszTitle = load_string (IDS_TAB_GRAPHICS);
155 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
156 psp[pg].dwFlags = PSP_USETITLE;
157 psp[pg].hInstance = hInstance;
158 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_APPEARANCE);
159 psp[pg].u2.pszIcon = NULL;
160 psp[pg].pfnDlgProc = ThemeDlgProc;
161 psp[pg].pszTitle = load_string (IDS_TAB_APPEARANCE);
165 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
166 psp[pg].dwFlags = PSP_USETITLE;
167 psp[pg].hInstance = hInstance;
168 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DRIVECFG);
169 psp[pg].u2.pszIcon = NULL;
170 psp[pg].pfnDlgProc = DriveDlgProc;
171 psp[pg].pszTitle = load_string (IDS_TAB_DRIVES);
175 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
176 psp[pg].dwFlags = PSP_USETITLE;
177 psp[pg].hInstance = hInstance;
178 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_AUDIOCFG);
179 psp[pg].u2.pszIcon = NULL;
180 psp[pg].pfnDlgProc = AudioDlgProc;
181 psp[pg].pszTitle = load_string (IDS_TAB_AUDIO);
186 * Fill out the (General) PROPSHEETPAGE data structure
187 * for the property sheet
189 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
190 psp[pg].dwFlags = PSP_USETITLE;
191 psp[pg].hInstance = hInstance;
192 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_ABOUTCFG);
193 psp[pg].u2.pszIcon = NULL;
194 psp[pg].pfnDlgProc = AboutDlgProc;
195 psp[pg].pszTitle = load_string (IDS_TAB_ABOUT);
200 * Fill out the PROPSHEETHEADER
202 psh.dwSize = sizeof (PROPSHEETHEADERW);
203 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
204 psh.hwndParent = hOwner;
205 psh.hInstance = hInstance;
206 psh.u.pszIcon = NULL;
207 psh.pszCaption = load_string (IDS_WINECFG_TITLE);
208 psh.nPages = NUM_PROPERTY_PAGES;
209 psh.u3.ppsp = (LPCPROPSHEETPAGEW) & psp;
210 psh.pfnCallback = (PFNPROPSHEETCALLBACK) PropSheetCallback;
211 psh.u2.nStartPage = 0;
214 * Display the modal property sheet
216 return PropertySheetW (&psh);
219 /******************************************************************************
220 * Name : ProcessCmdLine
221 * Description: Checks command line parameters for 'autodetect drives' option
222 * Parameters : lpCmdLine - the command line
223 * Returns : TRUE - if '/D' was found. Drive autodetection was carried out.
224 * FALSE - no '/D' option found in command line
225 * Notes : This is a very simple implementation, which only works
226 * correctly if the one and only cmd line option is '/D' or
227 * no option at all. Has to be reworked, if more options are to
231 ProcessCmdLine(LPSTR lpCmdLine)
233 if ((lpCmdLine[0] == '/' || lpCmdLine[0] == '-') &&
234 (lpCmdLine[1] == 'D' || lpCmdLine[1] == 'd'))
237 if (autodetect_drives()) {
238 apply_drive_changes();
246 /*****************************************************************************
248 * Description: Main windows entry point
249 * Parameters : hInstance
253 * Returns : Program exit code
256 WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
258 if (ProcessCmdLine(szCmdLine)) {
262 if (initialize() != 0) {
263 WINE_ERR("initialization failed, aborting\n");
268 * The next 9 lines should be all that is needed
269 * for the Wine Configuration property sheet
271 InitCommonControls ();
272 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
273 if (doPropertySheet (hInstance, NULL) > 0) {
276 WINE_TRACE("Cancel\n");