comdlg32: Fix some alignment issues in the Dutch translation.
[wine/hramrach.git] / programs / winecfg / main.c
blob83a5f05b6385a64f775fc1e5bc6f598c29b95544
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 /* Set the window icon */
52 SendMessageW( hWnd, WM_SETICON, ICON_BIG,
53 (LPARAM)LoadIconW( (HINSTANCE)GetWindowLongPtrW(hWnd, GWLP_HINSTANCE),
54 MAKEINTRESOURCEW(IDI_WINECFG) ));
55 break;
57 default:
58 break;
60 return 0;
63 static INT_PTR CALLBACK
64 AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
66 char *owner, *org;
68 switch (uMsg) {
70 case WM_NOTIFY:
71 switch(((LPNMHDR)lParam)->code)
73 case PSN_APPLY:
74 /*save registration info to registry */
75 owner = get_text(hDlg, IDC_ABT_OWNER);
76 org = get_text(hDlg, IDC_ABT_ORG);
78 set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion",
79 "RegisteredOwner", owner ? owner : "");
80 set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion",
81 "RegisteredOrganization", org ? org : "");
82 set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
83 "RegisteredOwner", owner ? owner : "");
84 set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
85 "RegisteredOrganization", org ? org : "");
86 apply();
88 HeapFree(GetProcessHeap(), 0, owner);
89 HeapFree(GetProcessHeap(), 0, org);
90 break;
92 break;
94 case WM_INITDIALOG:
95 /* read owner and organization info from registry, load it into text box */
96 owner = get_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
97 "RegisteredOwner", "");
98 org = get_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
99 "RegisteredOrganization", "");
101 SetDlgItemText(hDlg, IDC_ABT_OWNER, owner);
102 SetDlgItemText(hDlg, IDC_ABT_ORG, org);
104 SendMessage(GetParent(hDlg), PSM_UNCHANGED, 0, 0);
106 HeapFree(GetProcessHeap(), 0, owner);
107 HeapFree(GetProcessHeap(), 0, org);
108 break;
110 case WM_COMMAND:
111 switch(HIWORD(wParam))
113 case EN_CHANGE:
114 /* enable apply button */
115 SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
116 break;
118 break;
120 return FALSE;
123 #define NUM_PROPERTY_PAGES 7
125 static INT_PTR
126 doPropertySheet (HINSTANCE hInstance, HWND hOwner)
128 PROPSHEETPAGEW psp[NUM_PROPERTY_PAGES];
129 PROPSHEETHEADERW psh;
130 int pg = 0; /* start with page 0 */
133 * Fill out the (Applications) PROPSHEETPAGE data structure
134 * for the property sheet
136 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
137 psp[pg].dwFlags = PSP_USETITLE;
138 psp[pg].hInstance = hInstance;
139 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_APPCFG);
140 psp[pg].u2.pszIcon = NULL;
141 psp[pg].pfnDlgProc = AppDlgProc;
142 psp[pg].pszTitle = load_string (IDS_TAB_APPLICATIONS);
143 psp[pg].lParam = 0;
144 pg++;
147 * Fill out the (Libraries) PROPSHEETPAGE data structure
148 * for the property sheet
150 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
151 psp[pg].dwFlags = PSP_USETITLE;
152 psp[pg].hInstance = hInstance;
153 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DLLCFG);
154 psp[pg].u2.pszIcon = NULL;
155 psp[pg].pfnDlgProc = LibrariesDlgProc;
156 psp[pg].pszTitle = load_string (IDS_TAB_DLLS);
157 psp[pg].lParam = 0;
158 pg++;
161 * Fill out the (X11Drv) PROPSHEETPAGE data structure
162 * for the property sheet
164 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
165 psp[pg].dwFlags = PSP_USETITLE;
166 psp[pg].hInstance = hInstance;
167 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_GRAPHCFG);
168 psp[pg].u2.pszIcon = NULL;
169 psp[pg].pfnDlgProc = GraphDlgProc;
170 psp[pg].pszTitle = load_string (IDS_TAB_GRAPHICS);
171 psp[pg].lParam = 0;
172 pg++;
174 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
175 psp[pg].dwFlags = PSP_USETITLE;
176 psp[pg].hInstance = hInstance;
177 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DESKTOP_INTEGRATION);
178 psp[pg].u2.pszIcon = NULL;
179 psp[pg].pfnDlgProc = ThemeDlgProc;
180 psp[pg].pszTitle = load_string (IDS_TAB_DESKTOP_INTEGRATION);
181 psp[pg].lParam = 0;
182 pg++;
184 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
185 psp[pg].dwFlags = PSP_USETITLE;
186 psp[pg].hInstance = hInstance;
187 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DRIVECFG);
188 psp[pg].u2.pszIcon = NULL;
189 psp[pg].pfnDlgProc = DriveDlgProc;
190 psp[pg].pszTitle = load_string (IDS_TAB_DRIVES);
191 psp[pg].lParam = 0;
192 pg++;
194 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
195 psp[pg].dwFlags = PSP_USETITLE;
196 psp[pg].hInstance = hInstance;
197 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_AUDIOCFG);
198 psp[pg].u2.pszIcon = NULL;
199 psp[pg].pfnDlgProc = AudioDlgProc;
200 psp[pg].pszTitle = load_string (IDS_TAB_AUDIO);
201 psp[pg].lParam = 0;
202 pg++;
205 * Fill out the (General) PROPSHEETPAGE data structure
206 * for the property sheet
208 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
209 psp[pg].dwFlags = PSP_USETITLE;
210 psp[pg].hInstance = hInstance;
211 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_ABOUTCFG);
212 psp[pg].u2.pszIcon = NULL;
213 psp[pg].pfnDlgProc = AboutDlgProc;
214 psp[pg].pszTitle = load_string (IDS_TAB_ABOUT);
215 psp[pg].lParam = 0;
216 pg++;
219 * Fill out the PROPSHEETHEADER
221 psh.dwSize = sizeof (PROPSHEETHEADERW);
222 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
223 psh.hwndParent = hOwner;
224 psh.hInstance = hInstance;
225 psh.u.pszIcon = MAKEINTRESOURCEW (IDI_WINECFG);
226 psh.pszCaption = load_string (IDS_WINECFG_TITLE);
227 psh.nPages = NUM_PROPERTY_PAGES;
228 psh.u3.ppsp = psp;
229 psh.pfnCallback = PropSheetCallback;
230 psh.u2.nStartPage = 0;
233 * Display the modal property sheet
235 return PropertySheetW (&psh);
238 /******************************************************************************
239 * Name : ProcessCmdLine
240 * Description: Checks command line parameters for 'autodetect drives' option
241 * Parameters : lpCmdLine - the command line
242 * Returns : TRUE - if '/D' was found. Drive autodetection was carried out.
243 * FALSE - no '/D' option found in command line
244 * Notes : This is a very simple implementation, which only works
245 * correctly if the one and only cmd line option is '/D' or
246 * no option at all. Has to be reworked, if more options are to
247 * be supported.
249 static BOOL
250 ProcessCmdLine(LPSTR lpCmdLine)
252 if ((lpCmdLine[0] == '/' || lpCmdLine[0] == '-') &&
253 (lpCmdLine[1] == 'D' || lpCmdLine[1] == 'd'))
255 gui_mode = FALSE;
256 if (autodetect_drives()) {
257 apply_drive_changes();
259 return TRUE;
262 return FALSE;
265 /*****************************************************************************
266 * Name : WinMain
267 * Description: Main windows entry point
268 * Parameters : hInstance
269 * hPrev
270 * szCmdLine
271 * nShow
272 * Returns : Program exit code
274 int WINAPI
275 WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
277 if (ProcessCmdLine(szCmdLine)) {
278 return 0;
281 if (initialize(hInstance) != 0) {
282 WINE_ERR("initialization failed, aborting\n");
283 ExitProcess(1);
287 * The next 9 lines should be all that is needed
288 * for the Wine Configuration property sheet
290 InitCommonControls ();
291 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
292 if (doPropertySheet (hInstance, NULL) > 0) {
293 WINE_TRACE("OK\n");
294 } else {
295 WINE_TRACE("Cancel\n");
297 CoUninitialize();
298 ExitProcess (0);
300 return 0;