main.c 7.04 KB
Newer Older
1 2 3 4 5
/*
 * WineCfg main entry point
 *
 * Copyright 2002 Jaco Greeff
 * Copyright 2003 Dimitrie O. Paun
6
 * Copyright 2003 Mike Hearn
7 8 9 10 11 12 13 14 15 16 17 18 19
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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
21 22 23
 *
 */

24
#define WIN32_LEAN_AND_MEAN
25

26 27 28
#define NONAMELESSUNION
#define NONAMELESSSTRUCT

29
#include <windows.h>
30
#include <commctrl.h>
31
#include <objbase.h>
32 33
#include <wine/debug.h>

34 35 36 37
#include "properties.h"
#include "resource.h"
#include "winecfg.h"

38 39
WINE_DEFAULT_DEBUG_CHANNEL(winecfg);

40
static INT CALLBACK
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
PropSheetCallback (HWND hWnd, UINT uMsg, LPARAM lParam)
{
    switch (uMsg)
    {
	/*
	 * hWnd = NULL, lParam == dialog resource
	 */
    case PSCB_PRECREATE:
	break;

    case PSCB_INITIALIZED:
	break;

    default:
	break;
    }
57
    return 0;
58 59
}

60
static INT_PTR CALLBACK
61
AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
62
{
63
    switch (uMsg) {
64 65 66 67

	case WM_NOTIFY:
	    if (((LPNMHDR)lParam)->code != PSN_SETACTIVE) break;
	    /* otherwise fall through, we want to refresh the page as well */
68 69 70 71 72 73 74 75 76
	case WM_INITDIALOG:
	    break;

	case WM_COMMAND:
	    break;
	    
	default:
	    break;
	    
77 78 79 80
    }
    return FALSE;
}

81
#define NUM_PROPERTY_PAGES 7
82

83
static INT_PTR
84 85
doPropertySheet (HINSTANCE hInstance, HWND hOwner)
{
86 87
    PROPSHEETPAGEW psp[NUM_PROPERTY_PAGES];
    PROPSHEETHEADERW psh;
88
    int pg = 0; /* start with page 0 */
89 90

    /*
91
     * Fill out the (Applications) PROPSHEETPAGE data structure 
92 93
     * for the property sheet
     */
94
    psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
95 96
    psp[pg].dwFlags = PSP_USETITLE;
    psp[pg].hInstance = hInstance;
97
    psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_APPCFG);
98 99
    psp[pg].u2.pszIcon = NULL;
    psp[pg].pfnDlgProc = AppDlgProc;
100
    psp[pg].pszTitle = load_string (IDS_TAB_APPLICATIONS);
101 102
    psp[pg].lParam = 0;
    pg++;
103 104

    /*
105
     * Fill out the (Libraries) PROPSHEETPAGE data structure 
106 107
     * for the property sheet
     */
108
    psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
109 110
    psp[pg].dwFlags = PSP_USETITLE;
    psp[pg].hInstance = hInstance;
111
    psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DLLCFG);
112 113
    psp[pg].u2.pszIcon = NULL;
    psp[pg].pfnDlgProc = LibrariesDlgProc;
114
    psp[pg].pszTitle = load_string (IDS_TAB_DLLS);
115 116
    psp[pg].lParam = 0;
    pg++;
117
    
118 119 120 121
    /*
     * Fill out the (X11Drv) PROPSHEETPAGE data structure 
     * for the property sheet
     */
122
    psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
123 124
    psp[pg].dwFlags = PSP_USETITLE;
    psp[pg].hInstance = hInstance;
125
    psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_GRAPHCFG);
126
    psp[pg].u2.pszIcon = NULL;
127
    psp[pg].pfnDlgProc = GraphDlgProc;
128
    psp[pg].pszTitle =  load_string (IDS_TAB_GRAPHICS);
129 130 131
    psp[pg].lParam = 0;
    pg++;

132
    psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
133 134
    psp[pg].dwFlags = PSP_USETITLE;
    psp[pg].hInstance = hInstance;
135
    psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DESKTOP_INTEGRATION);
136 137
    psp[pg].u2.pszIcon = NULL;
    psp[pg].pfnDlgProc = ThemeDlgProc;
138
    psp[pg].pszTitle =  load_string (IDS_TAB_DESKTOP_INTEGRATION);
139 140 141
    psp[pg].lParam = 0;
    pg++;

142
    psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
143 144
    psp[pg].dwFlags = PSP_USETITLE;
    psp[pg].hInstance = hInstance;
145
    psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DRIVECFG);
146 147
    psp[pg].u2.pszIcon = NULL;
    psp[pg].pfnDlgProc = DriveDlgProc;
148
    psp[pg].pszTitle =  load_string (IDS_TAB_DRIVES);
149 150 151
    psp[pg].lParam = 0;
    pg++;

152
    psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
153 154
    psp[pg].dwFlags = PSP_USETITLE;
    psp[pg].hInstance = hInstance;
155
    psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_AUDIOCFG);
156 157
    psp[pg].u2.pszIcon = NULL;
    psp[pg].pfnDlgProc = AudioDlgProc;
158
    psp[pg].pszTitle =  load_string (IDS_TAB_AUDIO);
159 160
    psp[pg].lParam = 0;
    pg++;
161

162 163 164 165
    /*
     * Fill out the (General) PROPSHEETPAGE data structure 
     * for the property sheet
     */
166
    psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
167 168
    psp[pg].dwFlags = PSP_USETITLE;
    psp[pg].hInstance = hInstance;
169
    psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_ABOUTCFG);
170 171
    psp[pg].u2.pszIcon = NULL;
    psp[pg].pfnDlgProc = AboutDlgProc;
172
    psp[pg].pszTitle =  load_string (IDS_TAB_ABOUT);
173 174
    psp[pg].lParam = 0;
    pg++;
175

176 177 178
    /*
     * Fill out the PROPSHEETHEADER
     */
179
    psh.dwSize = sizeof (PROPSHEETHEADERW);
180 181 182 183
    psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
    psh.hwndParent = hOwner;
    psh.hInstance = hInstance;
    psh.u.pszIcon = NULL;
184
    psh.pszCaption =  load_string (IDS_WINECFG_TITLE);
185
    psh.nPages = NUM_PROPERTY_PAGES;
186 187
    psh.u3.ppsp = psp;
    psh.pfnCallback = PropSheetCallback;
188
    psh.u2.nStartPage = 0;
189 190 191 192

    /*
     * Display the modal property sheet
     */
193
    return PropertySheetW (&psh);
194 195
}

196 197 198 199 200 201 202 203 204 205 206
/******************************************************************************
 * Name       : ProcessCmdLine
 * Description: Checks command line parameters for 'autodetect drives' option
 * Parameters : lpCmdLine - the command line
 * Returns    : TRUE - if '/D' was found. Drive autodetection was carried out.
 *              FALSE - no '/D' option found in command line
 * Notes      : This is a very simple implementation, which only works 
 *              correctly if the one and only cmd line option is '/D' or
 *              no option at all. Has to be reworked, if more options are to
 *              be supported.
 */
207
static BOOL
208 209 210 211 212 213 214 215 216 217 218 219 220 221
ProcessCmdLine(LPSTR lpCmdLine)
{
    if ((lpCmdLine[0] == '/' || lpCmdLine[0] == '-') && 
        (lpCmdLine[1] == 'D' || lpCmdLine[1] == 'd')) 
    {
        gui_mode = FALSE;
        if (autodetect_drives()) {
            apply_drive_changes();
        }
        return TRUE;
    }

    return FALSE;
}
222 223 224 225

/*****************************************************************************
 * Name       : WinMain
 * Description: Main windows entry point
Francois Gouget's avatar
Francois Gouget committed
226
 * Parameters : hInstance
227 228 229 230 231 232 233 234
 *              hPrev
 *              szCmdLine
 *              nShow
 * Returns    : Program exit code
 */
int WINAPI
WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
{
235 236 237
    if (ProcessCmdLine(szCmdLine)) {
        return 0;
    }
238

239
    if (initialize(hInstance) != 0) {
240 241 242 243
	WINE_ERR("initialization failed, aborting\n");
	ExitProcess(1);
    }
    
244
    /*
245
     * The next 9 lines should be all that is needed
246 247 248
     * for the Wine Configuration property sheet
     */
    InitCommonControls ();
249
    CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
250
    if (doPropertySheet (hInstance, NULL) > 0) {
251
	WINE_TRACE("OK\n");
252
    } else {
253
	WINE_TRACE("Cancel\n");
254
    }
255
    CoUninitialize(); 
256 257 258 259
    ExitProcess (0);

    return 0;
}