Removed redundant LANGUAGE statements.
[wine] / programs / winecfg / main.c
1 /*
2  * WineCfg main entry point
3  *
4  * Copyright 2002 Jaco Greeff
5  * Copyright 2003 Dimitrie O. Paun
6  *
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.
11  *
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.
16  *
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
20  *
21  */
22
23 #define NONAMELESSUNION
24 #define NONAMELESSSTRUCT
25
26 #include <windows.h>
27 #include <commctrl.h>
28 #include <stdlib.h>
29 #include <stdio.h>
30
31 #include "properties.h"
32 #include "resource.h"
33 #include "winecfg.h"
34
35 WINECFG_DESC sCfg;
36
37 void CALLBACK
38 PropSheetCallback (HWND hWnd, UINT uMsg, LPARAM lParam)
39 {
40     switch (uMsg)
41     {
42         /*
43          * hWnd = NULL, lParam == dialog resource
44          */
45     case PSCB_PRECREATE:
46         break;
47
48     case PSCB_INITIALIZED:
49         break;
50
51     default:
52         break;
53     }
54 }
55
56 void
57 initGeneralDlg (HWND hDlg)
58 {
59     int i;
60     const VERSION_DESC *pVer = NULL;
61
62     if ((pVer = getWinVersions ()))
63     {
64         for (i = 0; *pVer->szVersion; i++, pVer++)
65         {
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);
71         }
72     }
73     if ((pVer = getDOSVersions ()))
74     {
75         for (i = 0; *pVer->szVersion; i++, pVer++)
76         {
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);
82         }
83     }
84     if ((pVer = getWinelook ()))
85     {
86         for (i = 0; *pVer->szVersion; i++, pVer++)
87         {
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);
93         }
94     }
95 }
96
97 INT_PTR CALLBACK
98 GeneralDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
99 {
100     switch (uMsg)
101     {
102     case WM_INITDIALOG:
103         initGeneralDlg (hDlg);
104         break;
105
106     case WM_COMMAND:
107         break;
108
109     default:
110         break;
111     }
112     return FALSE;
113 }
114
115
116 INT_PTR CALLBACK
117 DllDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
118 {
119     switch (uMsg)
120     {
121     case WM_COMMAND:
122         break;
123
124     default:
125         break;
126     }
127     return FALSE;
128 }
129
130
131 INT_PTR CALLBACK
132 AppDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
133 {
134     switch (uMsg)
135     {
136     case WM_COMMAND:
137         break;
138
139     default:
140         break;
141     }
142     return FALSE;
143 }
144
145 void
146 initX11DrvDlg (HWND hDlg)
147 {
148     char szBuf[20];
149
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);
158 }
159
160 INT_PTR CALLBACK
161 X11DrvDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
162 {
163     switch (uMsg)
164     {
165     case WM_INITDIALOG:
166         initX11DrvDlg (hDlg);
167         break;
168
169     case WM_COMMAND:
170         break;
171
172     default:
173         break;
174     }
175     return FALSE;
176 }
177
178 #define NUM_PROPERTY_PAGES 4
179 INT_PTR
180 doPropertySheet (HINSTANCE hInstance, HWND hOwner)
181 {
182     PROPSHEETPAGE psp[NUM_PROPERTY_PAGES];
183     PROPSHEETHEADER psh;
184
185     /*
186      * Fill out the (General) PROPSHEETPAGE data structure 
187      * for the property sheet
188      */
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;
197
198     /*
199      * Fill out the (Libraries) PROPSHEETPAGE data structure 
200      * for the property sheet
201      */
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;
210
211     /*
212      * Fill out the (Applications) PROPSHEETPAGE data structure 
213      * for the property sheet
214      */
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;
223
224     /*
225      * Fill out the (X11Drv) PROPSHEETPAGE data structure 
226      * for the property sheet
227      */
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;
236
237     /*
238      * Fill out the PROPSHEETHEADER
239      */
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;
249
250     /*
251      * Display the modal property sheet
252      */
253     return PropertySheet (&psh);
254 }
255
256
257 /*****************************************************************************
258  * Name       : WinMain
259  * Description: Main windows entry point
260  * Paramaters : hInstance
261  *              hPrev
262  *              szCmdLine
263  *              nShow
264  * Returns    : Program exit code
265  */
266 int WINAPI
267 WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
268 {
269     /*
270      * Load the configuration from registry
271      */
272     loadConfig (&sCfg);
273
274     /*
275      * The next 3 lines should be all that is needed
276      * for the Wine Configuration property sheet
277      */
278     InitCommonControls ();
279     doPropertySheet (hInstance, NULL);
280     ExitProcess (0);
281
282     return 0;
283 }