Replace CURSORICON_CreateFromResource by CreateIconFromResourceEx.
[wine/hacks.git] / programs / winecfg / main.c
blob8d0324b7c253420ab31f974623da600469cd3d6f
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 #include "config.h"
26 #include <stdlib.h>
27 #include <stdio.h>
28 #include <stdarg.h>
29 #ifdef HAVE_UNISTD_H
30 #include <unistd.h>
31 #endif
33 #define NONAMELESSUNION
34 #define NONAMELESSSTRUCT
36 #include <windef.h>
37 #include <winbase.h>
38 #include <winuser.h>
39 #include <commctrl.h>
40 #include <objbase.h>
41 #include <wine/debug.h>
43 #include "properties.h"
44 #include "resource.h"
45 #include "winecfg.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
49 static void CALLBACK
50 PropSheetCallback (HWND hWnd, UINT uMsg, LPARAM lParam)
52 switch (uMsg)
55 * hWnd = NULL, lParam == dialog resource
57 case PSCB_PRECREATE:
58 break;
60 case PSCB_INITIALIZED:
61 break;
63 default:
64 break;
68 static INT_PTR CALLBACK
69 AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
71 switch (uMsg) {
73 case WM_NOTIFY:
74 if (((LPNMHDR)lParam)->code != PSN_SETACTIVE) break;
75 /* otherwise fall through, we want to refresh the page as well */
76 case WM_INITDIALOG:
77 break;
79 case WM_COMMAND:
80 break;
82 default:
83 break;
86 return FALSE;
89 #define NUM_PROPERTY_PAGES 6
91 static INT_PTR
92 doPropertySheet (HINSTANCE hInstance, HWND hOwner)
94 PROPSHEETPAGE psp[NUM_PROPERTY_PAGES];
95 PROPSHEETHEADER psh;
96 int pg = 0; /* start with page 0 */
99 * Fill out the (Applications) PROPSHEETPAGE data structure
100 * for the property sheet
102 psp[pg].dwSize = sizeof (PROPSHEETPAGE);
103 psp[pg].dwFlags = PSP_USETITLE;
104 psp[pg].hInstance = hInstance;
105 psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_APPCFG);
106 psp[pg].u2.pszIcon = NULL;
107 psp[pg].pfnDlgProc = AppDlgProc;
108 psp[pg].pszTitle = "Applications";
109 psp[pg].lParam = 0;
110 pg++;
113 * Fill out the (Libraries) PROPSHEETPAGE data structure
114 * for the property sheet
116 psp[pg].dwSize = sizeof (PROPSHEETPAGE);
117 psp[pg].dwFlags = PSP_USETITLE;
118 psp[pg].hInstance = hInstance;
119 psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_DLLCFG);
120 psp[pg].u2.pszIcon = NULL;
121 psp[pg].pfnDlgProc = LibrariesDlgProc;
122 psp[pg].pszTitle = "Libraries";
123 psp[pg].lParam = 0;
124 pg++;
127 * Fill out the (X11Drv) PROPSHEETPAGE data structure
128 * for the property sheet
130 psp[pg].dwSize = sizeof (PROPSHEETPAGE);
131 psp[pg].dwFlags = PSP_USETITLE;
132 psp[pg].hInstance = hInstance;
133 psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_GRAPHCFG);
134 psp[pg].u2.pszIcon = NULL;
135 psp[pg].pfnDlgProc = GraphDlgProc;
136 psp[pg].pszTitle = "Graphics";
137 psp[pg].lParam = 0;
138 pg++;
140 psp[pg].dwSize = sizeof (PROPSHEETPAGE);
141 psp[pg].dwFlags = PSP_USETITLE;
142 psp[pg].hInstance = hInstance;
143 psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_DRIVECFG);
144 psp[pg].u2.pszIcon = NULL;
145 psp[pg].pfnDlgProc = DriveDlgProc;
146 psp[pg].pszTitle = "Drives";
147 psp[pg].lParam = 0;
148 pg++;
150 psp[pg].dwSize = sizeof (PROPSHEETPAGE);
151 psp[pg].dwFlags = PSP_USETITLE;
152 psp[pg].hInstance = hInstance;
153 psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_AUDIOCFG);
154 psp[pg].u2.pszIcon = NULL;
155 psp[pg].pfnDlgProc = AudioDlgProc;
156 psp[pg].pszTitle = "Audio";
157 psp[pg].lParam = 0;
158 pg++;
161 * Fill out the (General) PROPSHEETPAGE data structure
162 * for the property sheet
164 psp[pg].dwSize = sizeof (PROPSHEETPAGE);
165 psp[pg].dwFlags = PSP_USETITLE;
166 psp[pg].hInstance = hInstance;
167 psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_ABOUTCFG);
168 psp[pg].u2.pszIcon = NULL;
169 psp[pg].pfnDlgProc = AboutDlgProc;
170 psp[pg].pszTitle = "About";
171 psp[pg].lParam = 0;
172 pg++;
175 * Fill out the PROPSHEETHEADER
177 psh.dwSize = sizeof (PROPSHEETHEADER);
178 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
179 psh.hwndParent = hOwner;
180 psh.hInstance = hInstance;
181 psh.u.pszIcon = NULL;
182 psh.pszCaption = "Wine Configuration";
183 psh.nPages = NUM_PROPERTY_PAGES;
184 psh.u3.ppsp = (LPCPROPSHEETPAGE) & psp;
185 psh.pfnCallback = (PFNPROPSHEETCALLBACK) PropSheetCallback;
186 psh.u2.nStartPage = 0;
189 * Display the modal property sheet
191 return PropertySheet (&psh);
194 /******************************************************************************
195 * Name : ProcessCmdLine
196 * Description: Checks command line parameters for 'autodetect drives' option
197 * Parameters : lpCmdLine - the command line
198 * Returns : TRUE - if '/D' was found. Drive autodetection was carried out.
199 * FALSE - no '/D' option found in command line
200 * Notes : This is a very simple implementation, which only works
201 * correctly if the one and only cmd line option is '/D' or
202 * no option at all. Has to be reworked, if more options are to
203 * be supported.
205 static BOOL
206 ProcessCmdLine(LPSTR lpCmdLine)
208 if ((lpCmdLine[0] == '/' || lpCmdLine[0] == '-') &&
209 (lpCmdLine[1] == 'D' || lpCmdLine[1] == 'd'))
211 gui_mode = FALSE;
212 if (autodetect_drives()) {
213 apply_drive_changes();
215 return TRUE;
218 return FALSE;
221 /*****************************************************************************
222 * Name : WinMain
223 * Description: Main windows entry point
224 * Parameters : hInstance
225 * hPrev
226 * szCmdLine
227 * nShow
228 * Returns : Program exit code
230 int WINAPI
231 WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
233 if (ProcessCmdLine(szCmdLine)) {
234 return 0;
237 if (initialize() != 0) {
238 WINE_ERR("initialization failed, aborting\n");
239 ExitProcess(1);
243 * The next 9 lines should be all that is needed
244 * for the Wine Configuration property sheet
246 InitCommonControls ();
247 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
248 if (doPropertySheet (hInstance, NULL) > 0) {
249 WINE_TRACE("OK\n");
250 } else {
251 WINE_TRACE("Cancel\n");
253 CoUninitialize();
254 ExitProcess (0);
256 return 0;