Add some missing HeapFree's and one missing free.
[wine/wine-kai.git] / programs / winecfg / main.c
blob15ce2b861270a8a9c7d7cd5bff0bf53b09079be0
1 /*
2 * WineCfg main entry point
4 * Copyright 2002 Jaco Greeff
5 * Copyright 2003 Dimitrie O. Paun
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #define NONAMELESSUNION
24 #define NONAMELESSSTRUCT
26 #include <windows.h>
27 #include <commctrl.h>
28 #include <stdlib.h>
29 #include <stdio.h>
31 #include "properties.h"
32 #include "resource.h"
33 #include "winecfg.h"
35 WINECFG_DESC sCfg;
37 void CALLBACK
38 PropSheetCallback (HWND hWnd, UINT uMsg, LPARAM lParam)
40 switch (uMsg)
43 * hWnd = NULL, lParam == dialog resource
45 case PSCB_PRECREATE:
46 break;
48 case PSCB_INITIALIZED:
49 break;
51 default:
52 break;
56 void
57 initGeneralDlg (HWND hDlg)
59 int i;
60 const VERSION_DESC *pVer = NULL;
62 if ((pVer = getWinVersions ()))
64 for (i = 0; *pVer->szVersion; i++, pVer++)
66 SendDlgItemMessage (hDlg, IDC_WINVER, CB_ADDSTRING,
67 0, (LPARAM) pVer->szDescription);
68 if (!strcmp (pVer->szVersion, sCfg.szWinVer))
69 SendDlgItemMessage (hDlg, IDC_WINVER, CB_SETCURSEL,
70 (WPARAM) i, 0);
73 if ((pVer = getDOSVersions ()))
75 for (i = 0; *pVer->szVersion; i++, pVer++)
77 SendDlgItemMessage (hDlg, IDC_DOSVER, CB_ADDSTRING,
78 0, (LPARAM) pVer->szDescription);
79 if (!strcmp (pVer->szVersion, sCfg.szDOSVer))
80 SendDlgItemMessage (hDlg, IDC_DOSVER, CB_SETCURSEL,
81 (WPARAM) i, 0);
84 if ((pVer = getWinelook ()))
86 for (i = 0; *pVer->szVersion; i++, pVer++)
88 SendDlgItemMessage (hDlg, IDC_WINELOOK, CB_ADDSTRING,
89 0, (LPARAM) pVer->szDescription);
90 if (!strcmp (pVer->szVersion, sCfg.szWinLook))
91 SendDlgItemMessage (hDlg, IDC_WINELOOK, CB_SETCURSEL,
92 (WPARAM) i, 0);
97 INT_PTR CALLBACK
98 GeneralDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
100 switch (uMsg)
102 case WM_INITDIALOG:
103 initGeneralDlg (hDlg);
104 break;
106 case WM_COMMAND:
107 break;
109 default:
110 break;
112 return FALSE;
116 INT_PTR CALLBACK
117 DllDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
119 switch (uMsg)
121 case WM_COMMAND:
122 break;
124 default:
125 break;
127 return FALSE;
131 INT_PTR CALLBACK
132 AppDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
134 switch (uMsg)
136 case WM_COMMAND:
137 break;
139 default:
140 break;
142 return FALSE;
145 void
146 initX11DrvDlg (HWND hDlg)
148 char szBuf[20];
150 sprintf (szBuf, "%d", sCfg.sX11Drv.nSysColors);
151 SendDlgItemMessage (hDlg, IDC_SYSCOLORS, WM_SETTEXT, 0, (LPARAM) szBuf);
152 sprintf (szBuf, "%d", sCfg.sX11Drv.nDesktopSizeX);
153 SendDlgItemMessage (hDlg, IDC_DESKTOP_WIDTH, WM_SETTEXT, 0,
154 (LPARAM) szBuf);
155 sprintf (szBuf, "%d", sCfg.sX11Drv.nDesktopSizeY);
156 SendDlgItemMessage (hDlg, IDC_DESKTOP_HEIGHT, WM_SETTEXT, 0,
157 (LPARAM) szBuf);
160 INT_PTR CALLBACK
161 X11DrvDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
163 switch (uMsg)
165 case WM_INITDIALOG:
166 initX11DrvDlg (hDlg);
167 break;
169 case WM_COMMAND:
170 break;
172 default:
173 break;
175 return FALSE;
178 #define NUM_PROPERTY_PAGES 4
179 INT_PTR
180 doPropertySheet (HINSTANCE hInstance, HWND hOwner)
182 PROPSHEETPAGE psp[NUM_PROPERTY_PAGES];
183 PROPSHEETHEADER psh;
186 * Fill out the (General) PROPSHEETPAGE data structure
187 * for the property sheet
189 psp[0].dwSize = sizeof (PROPSHEETPAGE);
190 psp[0].dwFlags = PSP_USETITLE;
191 psp[0].hInstance = hInstance;
192 psp[0].u.pszTemplate = MAKEINTRESOURCE (IDD_GENERALCFG);
193 psp[0].u2.pszIcon = NULL;
194 psp[0].pfnDlgProc = GeneralDlgProc;
195 psp[0].pszTitle = "General";
196 psp[0].lParam = 0;
199 * Fill out the (Libraries) PROPSHEETPAGE data structure
200 * for the property sheet
202 psp[1].dwSize = sizeof (PROPSHEETPAGE);
203 psp[1].dwFlags = PSP_USETITLE;
204 psp[1].hInstance = hInstance;
205 psp[1].u.pszTemplate = MAKEINTRESOURCE (IDD_DLLCFG);
206 psp[1].u2.pszIcon = NULL;
207 psp[1].pfnDlgProc = DllDlgProc;
208 psp[1].pszTitle = "Libraries";
209 psp[1].lParam = 0;
212 * Fill out the (Applications) PROPSHEETPAGE data structure
213 * for the property sheet
215 psp[2].dwSize = sizeof (PROPSHEETPAGE);
216 psp[2].dwFlags = PSP_USETITLE;
217 psp[2].hInstance = hInstance;
218 psp[2].u.pszTemplate = MAKEINTRESOURCE (IDD_APPCFG);
219 psp[2].u2.pszIcon = NULL;
220 psp[2].pfnDlgProc = AppDlgProc;
221 psp[2].pszTitle = "Applications";
222 psp[2].lParam = 0;
225 * Fill out the (X11Drv) PROPSHEETPAGE data structure
226 * for the property sheet
228 psp[3].dwSize = sizeof (PROPSHEETPAGE);
229 psp[3].dwFlags = PSP_USETITLE;
230 psp[3].hInstance = hInstance;
231 psp[3].u.pszTemplate = MAKEINTRESOURCE (IDD_X11DRVCFG);
232 psp[3].u2.pszIcon = NULL;
233 psp[3].pfnDlgProc = X11DrvDlgProc;
234 psp[3].pszTitle = "X11 Driver";
235 psp[3].lParam = 0;
238 * Fill out the PROPSHEETHEADER
240 psh.dwSize = sizeof (PROPSHEETHEADER);
241 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
242 psh.hwndParent = hOwner;
243 psh.hInstance = hInstance;
244 psh.u.pszIcon = NULL;
245 psh.pszCaption = "Wine Configuration";
246 psh.nPages = NUM_PROPERTY_PAGES;
247 psh.u3.ppsp = (LPCPROPSHEETPAGE) & psp;
248 psh.pfnCallback = (PFNPROPSHEETCALLBACK) PropSheetCallback;
251 * Display the modal property sheet
253 return PropertySheet (&psh);
257 /*****************************************************************************
258 * Name : WinMain
259 * Description: Main windows entry point
260 * Paramaters : hInstance
261 * hPrev
262 * szCmdLine
263 * nShow
264 * Returns : Program exit code
266 int WINAPI
267 WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
270 * Load the configuration from registry
272 loadConfig (&sCfg);
275 * The next 3 lines should be all that is needed
276 * for the Wine Configuration property sheet
278 InitCommonControls ();
279 doPropertySheet (hInstance, NULL);
280 ExitProcess (0);
282 return 0;