-
- if(hwnd == 0) {
- return DefWindowProc(hwnd, message, wParam, lParam);
- } else if(hwnd == wnd_progress) {
- static struct progress_data data;
-
- switch(message)
- {
- case USER_SETMESSAGE:
- data.text3 = (char*)wParam;
- SendMessage(data.wnd_text3, WM_SETTEXT, 0, (LPARAM)data.text3);
- return 0;
- case WM_CREATE: {
- memset(&data, 0, sizeof(data));
- data.text1 = "Installing SWFTools";
- data.text2 = (char*)malloc(strlen(install_path)+250);
- sprintf(data.text2, "to %s", install_path);
- data.pos = 0;
- data.step = 1;
-
- CREATESTRUCT*cs = ((LPCREATESTRUCT)lParam);
- RECT rc;
- GetClientRect (hwnd, &rc);
- data.width = rc.right - rc.left;
- data.height = rc.bottom - rc.top;
- data.bar_width = cs->cx - 17;
- data.bar_height= 16;
- data.bar_posx = (data.width -data.bar_width)/2;
- data.bar_posy = 56;
- data.range = 50;
-
- data.hwndButton = CreateWindow (
- PROGRESS_CLASS,
- "Progress",
- WS_CHILD | WS_VISIBLE,
- data.bar_posx,
- data.bar_posy,
- data.bar_width,
- data.bar_height,
- hwnd, /* Parent */
- (HMENU)1,
- cs->hInstance,
- NULL
- );
-
- data.wnd_text3 = CreateWindow (
- WC_STATIC,
- "text3",
- WS_CHILD | WS_VISIBLE,
- data.bar_posx,
- 72,
- (rc.right - rc.left - data.bar_posx*2),
- 20,
- hwnd, /* Parent */
- (HMENU)1,
- cs->hInstance,
- NULL
- );
- SendMessage(data.wnd_text3, WM_SETTEXT, 0, (LPARAM)"");
-
- SendMessage(data.hwndButton, PBM_SETRANGE, 0, (LPARAM) MAKELONG(0,data.range));
- SendMessage(data.hwndButton, PBM_SETSTEP, (WPARAM) data.step, 0);
- return 0;
- }
- case PBM_STEPIT: {
- if(data.pos+data.step < data.range) {
- data.pos += data.step;
- SendMessage(data.hwndButton, PBM_STEPIT, wParam, lParam);
- }
- }
- case WM_PAINT: {
- TEXTMETRIC tm;
- HDC hdc; /* A device context used for drawing */
- PAINTSTRUCT ps; /* Also used during window drawing */
- RECT rc; /* A rectangle used during drawing */
-
- hdc = GetDC(hwnd);
- SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT));
- GetTextMetrics(hdc, &tm);
- ReleaseDC(hwnd, hdc);
-
- hdc = BeginPaint (hwnd, &ps);
-
- /*
- // draw logo
- HDC memDc=CreateCompatibleDC(hdc);
- SelectObject(memDc,logo);
- BitBlt(hdc,0,0,406,93,memDc,0,0,SRCCOPY);
- DeleteDC(memDc);
- // /
- */
-
- SetBkMode(hdc, TRANSPARENT);
-
- rc.top = 8; rc.left= 0; rc.right = data.width; rc.bottom = 24;
- DrawText(hdc, data.text1, -1, &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
-
- char buf[256];
- char*text = data.text2;
- if(tm.tmAveCharWidth * strlen(text) > data.width) {
- int chars = (data.width / tm.tmAveCharWidth)-8;
- if(chars>240) chars=240;
- strncpy(buf, text, chars);
- strcpy(&buf[chars],"...");
- text = buf;
- }
-
- rc.top = 32; rc.left= 0; rc.right = data.width; rc.bottom = 48;
- DrawText(hdc, text, -1, &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
-
- EndPaint (hwnd, &ps);
- return 0;
- }
- case WM_DESTROY:
- wnd_progress = 0;
- return DefWindowProc(hwnd, message, wParam, lParam);
- default:
- return DefWindowProc(hwnd, message, wParam, lParam);
- }
- } else if(hwnd == wnd_params) {
- static struct params_data data;
- switch(message)
- {
- case WM_CREATE: {
- memset(&data, 0, sizeof(data));
- CREATESTRUCT*cs = ((LPCREATESTRUCT)lParam);
- RECT rc;
- GetClientRect (hwnd, &rc);
- data.width = rc.right - rc.left;
- data.height = rc.bottom - rc.top;
-
- //EDITTEXT IDD_EDIT,68,8,72,12, ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP
- HWND text = CreateWindow(
- WC_STATIC,
- "Select Installation Directory:",
- WS_CHILD | WS_VISIBLE,
- 32,
- 16,
- data.width-32*2,
- 20,
- hwnd, /* Parent */
- 0,
- cs->hInstance,
- NULL
- );
-
- data.edit = CreateWindow (
- WC_EDIT,
- "EditPath",
- WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_AUTOHSCROLL,
- 32,
- 48,
- (data.width-64)-32*2,
- 20,
- hwnd, /* Parent */
- (HMENU)0x1234,
- cs->hInstance,
- NULL
- );
-
- data.explore = CreateWindow (
- WC_BUTTON,
- "Browse",
- WS_CHILD | WS_VISIBLE | WS_TABSTOP,
- data.width-32-64,
- 48,
- 64,
- 20,
- hwnd, /* Parent */
- (HMENU)0x9999,
- cs->hInstance,
- NULL
- );
-
- data.installButton = CreateWindow (
- WC_BUTTON,
- "Install",
- WS_CHILD | WS_VISIBLE | WS_TABSTOP,
- (data.width - 80)/2,
- data.height - 32*2,
- 80,
- 32,
- hwnd, /* Parent */
- (HMENU)0xabcd,
- cs->hInstance,
- NULL
- );
-
- SendMessage(data.edit, WM_SETTEXT, 0, (LPARAM)install_path);
- return 0;
- }
- case USER_SETMESSAGE: {
- //install_path = (char*)lParam;
- SendMessage(data.edit, WM_SETTEXT, 0, (LPARAM)install_path);
- printf("Setting path to %s\n", install_path);
- return 0;
- }
- case WM_PAINT: {
- return DefWindowProc(hwnd, message, wParam, lParam);
- }
- case WM_COMMAND: {
- if((wParam&0xffff) == 0x9999) {
- BROWSEINFOA browse;
- memset(&browse, 0, sizeof(browse));
- browse.ulFlags = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_USENEWUI;// | BIF_RETURNONLYFSDIRS; //BIF_VALIDATE
- browse.pszDisplayName = (CHAR*)malloc(MAX_PATH);
- memset(browse.pszDisplayName, 0, MAX_PATH);
- browse.lpszTitle = "Select installation directory";
- /*browse.pidlRoot = (ITEMIDLIST*)malloc(sizeof(ITEMIDLIST)*200);
- memset((void*)browse.pidlRoot, 0, sizeof(ITEMIDLIST)*200);*/
- printf("Start browsing %s\n", browse.pszDisplayName);
- //SHGetDesktopFolder
- //ParseDisplayName(install_path,0,&browse.pidlRoot,0,0);
- //SHParseDisplayName(install_path,0,&browse.pidlRoot,0,0);
- //SHBrowseForFolderA(&browse);
- browse.pidlRoot = SHBrowseForFolder(&browse);
- printf("Browsing returns %s / %08x\n", browse.pszDisplayName, browse.pidlRoot);
- if(browse.pszDisplayName) {
- if(SHGetPathFromIDList(browse.pidlRoot, browse.pszDisplayName)) {
- printf("Path is %s\n", browse.pszDisplayName);
- install_path = browse.pszDisplayName;
- }
- }
- SendMessage(data.edit, WM_SETTEXT, 0, (LPARAM)install_path);
- return 0;
- } else if((wParam&0xffff) == 0xabcd) {
- data.ok = 1;
- DestroyWindow(wnd_params);
- return 0;
- } else if((wParam&0xffff) == 0x1234) {
- SendMessage(data.edit, WM_GETTEXT, sizeof(pathBuf), (LPARAM)&(pathBuf[0]));
- if(pathBuf[0]) {
- install_path = pathBuf;
- printf("Path edited: now \"%s\"\n", install_path);
- }
- return 0;
- }
- return DefWindowProc(hwnd, message, wParam, lParam);
- }
- case WM_KEYDOWN: {
- if(wParam == 0x49) {
- DestroyWindow(wnd_params);
- }
- return 0;
- }
- case WM_DESTROY:
- if(!data.ok) {
- do_abort = 1;
- PostQuitMessage (0);
- }
- wnd_params = 0;
- return DefWindowProc(hwnd, message, wParam, lParam);
- default:
- return DefWindowProc(hwnd, message, wParam, lParam);
- }
- } else if(hwnd == wnd_finish) {
- static struct finish_data data;
- switch(message)
- {
- case WM_CREATE: {
-
- /* TODO:
-
- "swftools has been installed into directory %s
- successfully"
-
- [x] Create Desktop Shortcut
- [x] Create Start Menu Entry
-
- */
-
- RECT rc;
- CREATESTRUCT*cs = ((LPCREATESTRUCT)lParam);
- GetClientRect (hwnd, &rc);
- data.width = rc.right - rc.left;
- data.height = rc.bottom - rc.top;
-
- data.installButton = CreateWindow (
- WC_BUTTON,
- "Finish",
- WS_CHILD | WS_VISIBLE | WS_TABSTOP,
- (data.width - 80)/2,
- data.height - 40,
- 80,
- 32,
- hwnd, /* Parent */
- (HMENU)0xabcd,
- cs->hInstance,
- NULL
- );
- }
- }
+ if(hwnd == wnd_background && message == WM_PAINT) {
+ HDC hdc;
+ PAINTSTRUCT ps;
+ RECT rc;
+ GetWindowRect(hwnd, &rc);
+ int width = rc.right - rc.left;
+ int height = rc.bottom - rc.top;
+
+ hdc = BeginPaint(hwnd, &ps);
+ SetBkMode(hdc, TRANSPARENT);
+
+ double s = width / 1282.0;
+
+ HPEN pen0 = CreatePen(PS_SOLID, 2, RGB(0, 32, 128));
+ HPEN oldPen = (HPEN)SelectObject(hdc, pen0);
+ tball(hdc, 0.7*width,0.2*height,s,s);
+
+ HPEN pen1 = CreatePen(PS_SOLID, 2, RGB(0, 48, 128));
+ (HPEN)SelectObject(hdc, pen1);
+ tball(hdc, 0.233*width,0.3*height,s*2,s*2);
+
+ HPEN pen2 = CreatePen(PS_SOLID, 2, RGB(0, 64, 128));
+ (HPEN)SelectObject(hdc, pen2);
+ tball(hdc, width, 1.2*height,s*3,-s*3);
+
+ SelectObject(hdc, oldPen);
+ DeleteObject(pen1);
+ DeleteObject(pen2);
+ EndPaint(hwnd, &ps);
+ return 1;