| 1 |
// ui.cpp : Defines the entry point for the application. |
| 2 |
// |
| 3 |
// Unicode support by Jim Park -- 08/10/2007 |
| 4 |
|
| 5 |
#include "../../Source/Platform.h" |
| 6 |
#include <windows.h> |
| 7 |
#include <commctrl.h> |
| 8 |
#include "resource.h" |
| 9 |
|
| 10 |
HINSTANCE g_hInstance; |
| 11 |
HWND m_curwnd; |
| 12 |
|
| 13 |
const TCHAR* windows[] = { |
| 14 |
MAKEINTRESOURCE(IDD_LICENSE), |
| 15 |
MAKEINTRESOURCE(IDD_SELCOM), |
| 16 |
MAKEINTRESOURCE(IDD_DIR), |
| 17 |
MAKEINTRESOURCE(IDD_INSTFILES), |
| 18 |
MAKEINTRESOURCE(IDD_UNINST) |
| 19 |
}; |
| 20 |
|
| 21 |
INT_PTR CALLBACK GenericProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { |
| 22 |
static LOGBRUSH b = {BS_SOLID, RGB(255,0,0), 0}; |
| 23 |
static HBRUSH red; |
| 24 |
|
| 25 |
if (!red) |
| 26 |
red = CreateBrushIndirect(&b); |
| 27 |
|
| 28 |
switch (uMsg) { |
| 29 |
case WM_CTLCOLORSTATIC: |
| 30 |
return (INT_PTR)red; |
| 31 |
} |
| 32 |
return FALSE; |
| 33 |
} |
| 34 |
|
| 35 |
INT_PTR CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { |
| 36 |
static int i = -1; |
| 37 |
switch (uMsg) { |
| 38 |
case WM_INITDIALOG: |
| 39 |
SetWindowText(hwndDlg, _T("NSIS User Interface - Testing")); |
| 40 |
SetWindowText(GetDlgItem(hwndDlg, IDC_VERSTR), _T("NSIS version")); |
| 41 |
SetWindowText(GetDlgItem(hwndDlg, IDC_BACK), _T("< Back")); |
| 42 |
SetWindowText(GetDlgItem(hwndDlg, IDOK), _T("Next >")); |
| 43 |
SetWindowText(GetDlgItem(hwndDlg, IDCANCEL), _T("Cancel")); |
| 44 |
ShowWindow(GetDlgItem(hwndDlg, IDC_BACK), SW_SHOW); |
| 45 |
ShowWindow(GetDlgItem(hwndDlg, IDC_CHILDRECT), SW_SHOW); |
| 46 |
SendMessage(hwndDlg, WM_COMMAND, MAKEWORD(IDOK, 0), 0); |
| 47 |
ShowWindow(hwndDlg, SW_SHOW); |
| 48 |
break; |
| 49 |
case WM_COMMAND: |
| 50 |
switch (LOWORD(wParam)) { |
| 51 |
case IDOK: |
| 52 |
case IDC_BACK: |
| 53 |
i+=(LOWORD(wParam)==IDOK)?1:-1; |
| 54 |
if (i < 0) { |
| 55 |
i++; |
| 56 |
break; |
| 57 |
} |
| 58 |
if (i >= (int)sizeof(windows)/sizeof(TCHAR*)) { |
| 59 |
i--; |
| 60 |
break; |
| 61 |
} |
| 62 |
if (m_curwnd) DestroyWindow(m_curwnd); |
| 63 |
m_curwnd=CreateDialog(g_hInstance,windows[i],hwndDlg,GenericProc); |
| 64 |
if (m_curwnd) |
| 65 |
{ |
| 66 |
RECT r; |
| 67 |
GetWindowRect(GetDlgItem(hwndDlg,IDC_CHILDRECT),&r); |
| 68 |
ScreenToClient(hwndDlg,(LPPOINT)&r); |
| 69 |
SetWindowPos(m_curwnd,0,r.left,r.top,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER); |
| 70 |
ShowWindow(m_curwnd,SW_SHOWNA); |
| 71 |
} |
| 72 |
break; |
| 73 |
default: |
| 74 |
EndDialog(hwndDlg, 0); |
| 75 |
PostQuitMessage(0); |
| 76 |
break; |
| 77 |
} |
| 78 |
break; |
| 79 |
} |
| 80 |
return FALSE; |
| 81 |
} |
| 82 |
|
| 83 |
NSIS_ENTRYPOINT_SIMPLEGUI |
| 84 |
int WINAPI _tWinMain(HINSTANCE hInst,HINSTANCE hOldInst,LPTSTR CmdLineParams,int ShowCmd) |
| 85 |
{ |
| 86 |
InitCommonControls(); |
| 87 |
g_hInstance = hInst; |
| 88 |
LoadLibrary(_T("RichEd32.dll")); |
| 89 |
return (int) DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_INST),0,DialogProc); |
| 90 |
} |
| 91 |
|