wininet: Update Lithuanian translation.
[wine.git] / programs / winecfg / main.c
blobe363bb7487012964c54179b9d0e35fff71272f4e
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 char *owner, *org;
64 switch (uMsg) {
66 case WM_NOTIFY:
67 switch(((LPNMHDR)lParam)->code)
69 case PSN_APPLY:
70 /*save registration info to registry */
71 owner = get_text(hDlg, IDC_ABT_OWNER);
72 org = get_text(hDlg, IDC_ABT_ORG);
74 set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion",
75 "RegisteredOwner", owner ? owner : "");
76 set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion",
77 "RegisteredOrganization", org ? org : "");
78 set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
79 "RegisteredOwner", owner ? owner : "");
80 set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
81 "RegisteredOrganization", org ? org : "");
82 apply();
84 HeapFree(GetProcessHeap(), 0, owner);
85 HeapFree(GetProcessHeap(), 0, org);
86 break;
88 break;
90 case WM_INITDIALOG:
91 /* read owner and organization info from registry, load it into text box */
92 owner = get_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
93 "RegisteredOwner", "");
94 org = get_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
95 "RegisteredOrganization", "");
97 SetDlgItemText(hDlg, IDC_ABT_OWNER, owner);
98 SetDlgItemText(hDlg, IDC_ABT_ORG, org);
100 SendMessage(GetParent(hDlg), PSM_UNCHANGED, 0, 0);
102 HeapFree(GetProcessHeap(), 0, owner);
103 HeapFree(GetProcessHeap(), 0, org);
104 break;
106 case WM_COMMAND:
107 switch(HIWORD(wParam))
109 case EN_CHANGE:
110 /* enable apply button */
111 SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
112 break;
114 break;
116 return FALSE;
119 #define NUM_PROPERTY_PAGES 7
121 static INT_PTR
122 doPropertySheet (HINSTANCE hInstance, HWND hOwner)
124 PROPSHEETPAGEW psp[NUM_PROPERTY_PAGES];
125 PROPSHEETHEADERW psh;
126 int pg = 0; /* start with page 0 */
129 * Fill out the (Applications) PROPSHEETPAGE data structure
130 * for the property sheet
132 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
133 psp[pg].dwFlags = PSP_USETITLE;
134 psp[pg].hInstance = hInstance;
135 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_APPCFG);
136 psp[pg].u2.pszIcon = NULL;
137 psp[pg].pfnDlgProc = AppDlgProc;
138 psp[pg].pszTitle = load_string (IDS_TAB_APPLICATIONS);
139 psp[pg].lParam = 0;
140 pg++;
143 * Fill out the (Libraries) PROPSHEETPAGE data structure
144 * for the property sheet
146 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
147 psp[pg].dwFlags = PSP_USETITLE;
148 psp[pg].hInstance = hInstance;
149 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DLLCFG);
150 psp[pg].u2.pszIcon = NULL;
151 psp[pg].pfnDlgProc = LibrariesDlgProc;
152 psp[pg].pszTitle = load_string (IDS_TAB_DLLS);
153 psp[pg].lParam = 0;
154 pg++;
157 * Fill out the (X11Drv) PROPSHEETPAGE data structure
158 * for the property sheet
160 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
161 psp[pg].dwFlags = PSP_USETITLE;
162 psp[pg].hInstance = hInstance;
163 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_GRAPHCFG);
164 psp[pg].u2.pszIcon = NULL;
165 psp[pg].pfnDlgProc = GraphDlgProc;
166 psp[pg].pszTitle = load_string (IDS_TAB_GRAPHICS);
167 psp[pg].lParam = 0;
168 pg++;
170 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
171 psp[pg].dwFlags = PSP_USETITLE;
172 psp[pg].hInstance = hInstance;
173 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DESKTOP_INTEGRATION);
174 psp[pg].u2.pszIcon = NULL;
175 psp[pg].pfnDlgProc = ThemeDlgProc;
176 psp[pg].pszTitle = load_string (IDS_TAB_DESKTOP_INTEGRATION);
177 psp[pg].lParam = 0;
178 pg++;
180 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
181 psp[pg].dwFlags = PSP_USETITLE;
182 psp[pg].hInstance = hInstance;
183 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DRIVECFG);
184 psp[pg].u2.pszIcon = NULL;
185 psp[pg].pfnDlgProc = DriveDlgProc;
186 psp[pg].pszTitle = load_string (IDS_TAB_DRIVES);
187 psp[pg].lParam = 0;
188 pg++;
190 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
191 psp[pg].dwFlags = PSP_USETITLE;
192 psp[pg].hInstance = hInstance;
193 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_AUDIOCFG);
194 psp[pg].u2.pszIcon = NULL;
195 psp[pg].pfnDlgProc = AudioDlgProc;
196 psp[pg].pszTitle = load_string (IDS_TAB_AUDIO);
197 psp[pg].lParam = 0;
198 pg++;
201 * Fill out the (General) PROPSHEETPAGE data structure
202 * for the property sheet
204 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
205 psp[pg].dwFlags = PSP_USETITLE;
206 psp[pg].hInstance = hInstance;
207 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_ABOUTCFG);
208 psp[pg].u2.pszIcon = NULL;
209 psp[pg].pfnDlgProc = AboutDlgProc;
210 psp[pg].pszTitle = load_string (IDS_TAB_ABOUT);
211 psp[pg].lParam = 0;
212 pg++;
215 * Fill out the PROPSHEETHEADER
217 psh.dwSize = sizeof (PROPSHEETHEADERW);
218 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
219 psh.hwndParent = hOwner;
220 psh.hInstance = hInstance;
221 psh.u.pszIcon = NULL;
222 psh.pszCaption = load_string (IDS_WINECFG_TITLE);
223 psh.nPages = NUM_PROPERTY_PAGES;
224 psh.u3.ppsp = psp;
225 psh.pfnCallback = PropSheetCallback;
226 psh.u2.nStartPage = 0;
229 * Display the modal property sheet
231 return PropertySheetW (&psh);
234 /******************************************************************************
235 * Name : ProcessCmdLine
236 * Description: Checks command line parameters for 'autodetect drives' option
237 * Parameters : lpCmdLine - the command line
238 * Returns : TRUE - if '/D' was found. Drive autodetection was carried out.
239 * FALSE - no '/D' option found in command line
240 * Notes : This is a very simple implementation, which only works
241 * correctly if the one and only cmd line option is '/D' or
242 * no option at all. Has to be reworked, if more options are to
243 * be supported.
245 static BOOL
246 ProcessCmdLine(LPSTR lpCmdLine)
248 if ((lpCmdLine[0] == '/' || lpCmdLine[0] == '-') &&
249 (lpCmdLine[1] == 'D' || lpCmdLine[1] == 'd'))
251 gui_mode = FALSE;
252 if (autodetect_drives()) {
253 apply_drive_changes();
255 return TRUE;
258 return FALSE;
261 /*****************************************************************************
262 * Name : WinMain
263 * Description: Main windows entry point
264 * Parameters : hInstance
265 * hPrev
266 * szCmdLine
267 * nShow
268 * Returns : Program exit code
270 int WINAPI
271 WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
273 if (ProcessCmdLine(szCmdLine)) {
274 return 0;
277 if (initialize(hInstance) != 0) {
278 WINE_ERR("initialization failed, aborting\n");
279 ExitProcess(1);
283 * The next 9 lines should be all that is needed
284 * for the Wine Configuration property sheet
286 InitCommonControls ();
287 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
288 if (doPropertySheet (hInstance, NULL) > 0) {
289 WINE_TRACE("OK\n");
290 } else {
291 WINE_TRACE("Cancel\n");
293 CoUninitialize();
294 ExitProcess (0);
296 return 0;