A first stab at wcstod().
[wine/hacks.git] / programs / winecfg / main.c
blobc328bf8bd139bb7d51524c06f2b51d840788884c
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #define NONAMELESSUNION
25 #define NONAMELESSSTRUCT
27 #include <windows.h>
28 #include <commctrl.h>
29 #include <stdlib.h>
30 #include <stdio.h>
31 #include <wine/debug.h>
33 #include "properties.h"
34 #include "resource.h"
35 #include "winecfg.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
39 void 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;
58 void
59 initGeneralDlg (HWND hDlg)
61 int i;
62 const VERSION_DESC *pVer = NULL;
63 char *curWinVer = getConfigValue("Version", "Windows", "win98");
64 char *curDOSVer = getConfigValue("Version", "DOS", "6.22");
65 char *curWineLook = getConfigValue("Tweak.Layout", "WineLook", "win95");
67 /* normalize the version strings */
68 if (!strcmp(curWinVer, "win2000") || !strcmp(curWinVer, "nt2k") || !strcmp(curWinVer, "nt2000")) {
69 free(curWinVer);
70 curWinVer = strdup("win2k");
73 if (!strcmp(curWinVer, "win2k3")) {
74 free(curWinVer);
75 curWinVer = strdup("win2003");
78 if ((pVer = getWinVersions ()))
80 for (i = 0; *pVer->szVersion; i++, pVer++)
82 SendDlgItemMessage (hDlg, IDC_WINVER, CB_ADDSTRING,
83 0, (LPARAM) pVer->szDescription);
84 if (!strcmp (pVer->szVersion, curWinVer))
85 SendDlgItemMessage (hDlg, IDC_WINVER, CB_SETCURSEL,
86 (WPARAM) i, 0);
89 if ((pVer = getDOSVersions ()))
91 for (i = 0; *pVer->szVersion; i++, pVer++)
93 SendDlgItemMessage (hDlg, IDC_DOSVER, CB_ADDSTRING,
94 0, (LPARAM) pVer->szDescription);
95 if (!strcmp (pVer->szVersion, curDOSVer))
96 SendDlgItemMessage (hDlg, IDC_DOSVER, CB_SETCURSEL,
97 (WPARAM) i, 0);
100 if ((pVer = getWinelook ()))
102 for (i = 0; *pVer->szVersion; i++, pVer++)
104 SendDlgItemMessage (hDlg, IDC_WINELOOK, CB_ADDSTRING,
105 0, (LPARAM) pVer->szDescription);
106 if (!strcmp (pVer->szVersion, curWineLook))
107 SendDlgItemMessage (hDlg, IDC_WINELOOK, CB_SETCURSEL,
108 (WPARAM) i, 0);
112 free(curWinVer);
113 free(curDOSVer);
114 free(curWineLook);
117 INT_PTR CALLBACK
118 GeneralDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
120 switch (uMsg) {
122 case WM_INITDIALOG:
123 initGeneralDlg (hDlg);
124 break;
126 case WM_COMMAND:
127 switch (LOWORD(wParam)) {
128 case IDC_WINVER: if (HIWORD(wParam) == CBN_SELCHANGE) {
129 /* user changed the wine version combobox */
130 int selection = SendDlgItemMessage( hDlg, IDC_WINVER, CB_GETCURSEL, 0, 0);
131 VERSION_DESC *desc = getWinVersions();
133 while (selection > 0) {
134 desc++; selection--;
136 addTransaction("Version", "Windows", ACTION_SET, desc->szVersion);
138 break;
140 break;
142 default:
143 break;
146 return FALSE;
150 INT_PTR CALLBACK
151 DllDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
153 switch (uMsg)
155 case WM_COMMAND:
156 break;
158 default:
159 break;
161 return FALSE;
165 INT_PTR CALLBACK
166 AppDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
168 switch (uMsg)
170 case WM_COMMAND:
171 break;
173 default:
174 break;
176 return FALSE;
179 #define NUM_PROPERTY_PAGES 5
180 INT_PTR
181 doPropertySheet (HINSTANCE hInstance, HWND hOwner)
183 PROPSHEETPAGE psp[NUM_PROPERTY_PAGES];
184 PROPSHEETHEADER psh;
187 * Fill out the (General) PROPSHEETPAGE data structure
188 * for the property sheet
190 psp[0].dwSize = sizeof (PROPSHEETPAGE);
191 psp[0].dwFlags = PSP_USETITLE;
192 psp[0].hInstance = hInstance;
193 psp[0].u.pszTemplate = MAKEINTRESOURCE (IDD_GENERALCFG);
194 psp[0].u2.pszIcon = NULL;
195 psp[0].pfnDlgProc = GeneralDlgProc;
196 psp[0].pszTitle = "General";
197 psp[0].lParam = 0;
200 * Fill out the (Libraries) PROPSHEETPAGE data structure
201 * for the property sheet
203 psp[1].dwSize = sizeof (PROPSHEETPAGE);
204 psp[1].dwFlags = PSP_USETITLE;
205 psp[1].hInstance = hInstance;
206 psp[1].u.pszTemplate = MAKEINTRESOURCE (IDD_DLLCFG);
207 psp[1].u2.pszIcon = NULL;
208 psp[1].pfnDlgProc = DllDlgProc;
209 psp[1].pszTitle = "Libraries";
210 psp[1].lParam = 0;
213 * Fill out the (Applications) PROPSHEETPAGE data structure
214 * for the property sheet
216 psp[2].dwSize = sizeof (PROPSHEETPAGE);
217 psp[2].dwFlags = PSP_USETITLE;
218 psp[2].hInstance = hInstance;
219 psp[2].u.pszTemplate = MAKEINTRESOURCE (IDD_APPCFG);
220 psp[2].u2.pszIcon = NULL;
221 psp[2].pfnDlgProc = AppDlgProc;
222 psp[2].pszTitle = "Applications";
223 psp[2].lParam = 0;
226 * Fill out the (X11Drv) PROPSHEETPAGE data structure
227 * for the property sheet
229 psp[3].dwSize = sizeof (PROPSHEETPAGE);
230 psp[3].dwFlags = PSP_USETITLE;
231 psp[3].hInstance = hInstance;
232 psp[3].u.pszTemplate = MAKEINTRESOURCE (IDD_X11DRVCFG);
233 psp[3].u2.pszIcon = NULL;
234 psp[3].pfnDlgProc = X11DrvDlgProc;
235 psp[3].pszTitle = "X11 Driver";
236 psp[3].lParam = 0;
238 psp[4].dwSize = sizeof (PROPSHEETPAGE);
239 psp[4].dwFlags = PSP_USETITLE;
240 psp[4].hInstance = hInstance;
241 psp[4].u.pszTemplate = MAKEINTRESOURCE (IDD_DRIVECFG);
242 psp[4].u2.pszIcon = NULL;
243 psp[4].pfnDlgProc = DriveDlgProc;
244 psp[4].pszTitle = "Drives";
245 psp[4].lParam = 0;
248 * Fill out the PROPSHEETHEADER
250 psh.dwSize = sizeof (PROPSHEETHEADER);
251 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
252 psh.hwndParent = hOwner;
253 psh.hInstance = hInstance;
254 psh.u.pszIcon = NULL;
255 psh.pszCaption = "Wine Configuration";
256 psh.nPages = NUM_PROPERTY_PAGES;
257 psh.u3.ppsp = (LPCPROPSHEETPAGE) & psp;
258 psh.pfnCallback = (PFNPROPSHEETCALLBACK) PropSheetCallback;
261 * Display the modal property sheet
263 return PropertySheet (&psh);
267 /*****************************************************************************
268 * Name : WinMain
269 * Description: Main windows entry point
270 * Parameters : hInstance
271 * hPrev
272 * szCmdLine
273 * nShow
274 * Returns : Program exit code
276 int WINAPI
277 WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
280 /* Until winecfg is fully functional, warn users that it is incomplete and doesn't do anything */
281 WINE_FIXME("The winecfg tool is not yet complete, and does not actually alter your configuration.\n");
282 WINE_FIXME("If you want to alter the way Wine works, look in the ~/.wine/config file for more information.\n");
284 if (initialize() != 0) {
285 WINE_ERR("initialization failed, aborting\n");
286 ExitProcess(1);
290 * The next 3 lines should be all that is needed
291 * for the Wine Configuration property sheet
293 InitCommonControls ();
294 if (doPropertySheet (hInstance, NULL) > 0) {
295 WINE_TRACE("OK\n");
296 } else
297 WINE_TRACE("Cancel\n");
299 ExitProcess (0);
301 return 0;