tools/installer/InstallerMain.cpp
changeset 1651 077571ea8942
child 1722 2c16f160f5dd
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/installer/InstallerMain.cpp	Sun Oct 28 20:15:51 2007 +0000
     1.3 @@ -0,0 +1,112 @@
     1.4 +#include "InstallerMain.h"
     1.5 +#include "Welcome.h"
     1.6 +
     1.7 +#define WMU_INIT_INSTALLER		WM_USER+1
     1.8 +
     1.9 +HINSTANCE g_hInstance;
    1.10 +NEXT_DIALOG next_dialog = DisplayWelcome;
    1.11 +
    1.12 +LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    1.13 +{
    1.14 +	switch (message)
    1.15 +	{
    1.16 +	case WMU_INIT_INSTALLER:
    1.17 +		{
    1.18 +			while (next_dialog != NULL)
    1.19 +			{
    1.20 +				next_dialog = (NEXT_DIALOG)next_dialog(hWnd);
    1.21 +			}
    1.22 +			PostQuitMessage(0);
    1.23 +			break;
    1.24 +		}
    1.25 +	case WM_DESTROY:
    1.26 +		{
    1.27 +			PostQuitMessage(0);
    1.28 +			break;
    1.29 +		}
    1.30 +	default:
    1.31 +		{
    1.32 +			return DefWindowProc(hWnd, message, wParam, lParam);
    1.33 +		}
    1.34 +	}
    1.35 +
    1.36 +	return 0;
    1.37 +}
    1.38 +
    1.39 +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
    1.40 +{
    1.41 +	WNDCLASSEX wcex;
    1.42 +	BOOL bRet;
    1.43 +
    1.44 +	wcex.cbSize			= sizeof(wcex);
    1.45 +	wcex.style			= CS_HREDRAW | CS_VREDRAW;
    1.46 +	wcex.lpfnWndProc	= MainWndProc;
    1.47 +	wcex.cbClsExtra		= 0;
    1.48 +	wcex.cbWndExtra		= 0;
    1.49 +	wcex.hInstance		= hInstance;
    1.50 +	wcex.hIcon			= LoadIcon(hInstance, MAKEINTRESOURCE(IDI_INSTALLER));
    1.51 +	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
    1.52 +	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
    1.53 +	wcex.lpszMenuName	= _T("InstallerMenu");
    1.54 +	wcex.lpszClassName	= _T("Installer");
    1.55 +	wcex.hIconSm		= LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
    1.56 +
    1.57 +	if (!RegisterClassEx(&wcex))
    1.58 +	{
    1.59 +		return 1;
    1.60 +	}
    1.61 +
    1.62 +	INITCOMMONCONTROLSEX ccex;
    1.63 +	ccex.dwSize = sizeof(ccex);
    1.64 +	ccex.dwICC = ICC_BAR_CLASSES
    1.65 +		|ICC_HOTKEY_CLASS
    1.66 +		|ICC_LISTVIEW_CLASSES
    1.67 +		|ICC_PROGRESS_CLASS
    1.68 +		|ICC_WIN95_CLASSES
    1.69 +		|ICC_TAB_CLASSES;
    1.70 +
    1.71 +	if (!InitCommonControlsEx(&ccex))
    1.72 +	{
    1.73 +		return 1;
    1.74 +	}
    1.75 +
    1.76 +	g_hInstance = hInstance;
    1.77 +
    1.78 +	HWND hWnd = CreateWindow(
    1.79 +		_T("Installer"),
    1.80 +		_T("InstallerMain"),
    1.81 +		WS_OVERLAPPEDWINDOW,
    1.82 +		CW_USEDEFAULT,
    1.83 +		CW_USEDEFAULT,
    1.84 +		CW_USEDEFAULT,
    1.85 +		CW_USEDEFAULT,
    1.86 +		(HWND)NULL,
    1.87 +		(HMENU)NULL,
    1.88 +		hInstance,
    1.89 +		NULL);
    1.90 +	if (hWnd == NULL)
    1.91 +	{
    1.92 +		return 1;
    1.93 +	}
    1.94 +
    1.95 +	ShowWindow(hWnd, SW_HIDE);
    1.96 +	UpdateWindow(hWnd);
    1.97 +
    1.98 +	PostMessage(hWnd, WMU_INIT_INSTALLER, 0, 0);
    1.99 +
   1.100 +	MSG msg;
   1.101 +	while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0)
   1.102 +	{
   1.103 +		if (bRet == -1)
   1.104 +		{
   1.105 +			return 1;
   1.106 +		}
   1.107 +		else
   1.108 +		{
   1.109 +			TranslateMessage(&msg);
   1.110 +			DispatchMessage(&msg);
   1.111 +		}
   1.112 +	}
   1.113 +
   1.114 +	return (int)msg.wParam;
   1.115 +}