- 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;
+ SendDlgItemMessage(hwnd, IDC_INSTALL_PATH, WM_SETTEXT, 0, (LPARAM)install_path);
+ return 0;
+
+ }
+ else if((wParam&0xffff) == IDC_ALLUSERS) {
+ config_forAllUsers = 1;
+ SendDlgItemMessage(hwnd, IDC_ALLUSERS, BM_SETCHECK, config_forAllUsers, 0);
+ SendDlgItemMessage(hwnd, IDC_CURRENTUSER, BM_SETCHECK, config_forAllUsers^1, 0);
+ }
+ else if((wParam&0xffff) == IDC_CURRENTUSER) {
+ config_forAllUsers = 0;
+ SendDlgItemMessage(hwnd, IDC_ALLUSERS, BM_SETCHECK, config_forAllUsers, 0);
+ SendDlgItemMessage(hwnd, IDC_CURRENTUSER, BM_SETCHECK, config_forAllUsers^1, 0);
+ }
+ else if((wParam&0xffff) == IDC_INSTALL_PATH) {
+ SendDlgItemMessage(hwnd, IDC_INSTALL_PATH, WM_GETTEXT, sizeof(pathBuf), (LPARAM)&(pathBuf[0]));
+ if(pathBuf[0]) {
+ install_path = pathBuf;
+ int l = strlen(install_path);
+ while(l && install_path[l-1]=='\\') {
+ install_path[--l]=0;
+ }
+ }
+ return 0;
+ }
+ }
+ if(message == WM_NOTIFY && (((LPNMHDR)lParam)->code == PSN_SETACTIVE)) {
+ if(!elevated && !has_full_access) {
+ OSVERSIONINFO winverinfo;
+ memset(&winverinfo, 0, sizeof(OSVERSIONINFO));
+ winverinfo.dwOSVersionInfoSize = sizeof(winverinfo);
+ if (GetVersionEx(&winverinfo) && winverinfo.dwMajorVersion >= 5) {
+ /* we're on Vista, were asked to install for all users, but don't have
+ priviledges to do so. Ask to spawn the process elevated. */
+ char exename[MAX_PATH];
+ GetModuleFileName(NULL, exename, sizeof(exename));
+ if((int)ShellExecute(0, "runas", exename, "elevated", NULL, SW_SHOWNORMAL)>32) {
+ /* that worked- the second process will do the work */
+ exit(0);
+ }
+ }
+ }
+ }
+ return PropertySheetFuncCommon(hwnd, message, wParam, lParam, PSWIZB_BACK|PSWIZB_NEXT);
+}
+HWND statuswnd;
+static int progress_pos = 0;
+
+void PropertyArchiveError(char*text)
+{
+ while(1) {
+ int ret = MessageBox(0, text, "Error", MB_RETRYCANCEL|MB_ICONERROR);
+ if(ret==IDRETRY) continue;
+ else break;
+ }
+}
+
+void PropertyArchive_NewFile(char*filename)
+{
+ addFile(filename);
+ processMessages();
+}
+void PropertyArchive_NewDirectory(char*filename)
+{
+ addDir(filename);
+ processMessages();
+}
+
+static int lastlen = 0;
+void PropertyArchiveStatus(int pos, int len)
+{
+ if(len!=lastlen) {
+ SendDlgItemMessage(statuswnd, IDC_PROGRESS, PBM_SETRANGE, 0, (LPARAM)MAKELONG(0,len));
+ lastlen = len;
+ }
+ SendDlgItemMessage(statuswnd, IDC_PROGRESS, PBM_SETPOS, pos, 0);
+ processMessages();
+ Sleep(30);
+}
+void PropertyArchiveMessage(char*text)
+{
+ if(text && text[0]=='[') {
+ return;
+ }
+ SetDlgItemText(statuswnd, IDC_INFO, strdup(text));
+ processMessages();
+}
+
+void print_space(char*dest, char*msg, ULONGLONG size)
+{
+ if(size < 1024)
+ sprintf(dest, "%s%d Bytes", msg, size);
+ else if(size < 1048576l)
+ sprintf(dest, "%s%.2f Kb", msg, size/1024.0);
+ else if(size < 1073741824l)
+ sprintf(dest, "%s%.2f Mb", msg, size/1048576.0);
+ else if(size < 1099511627776ll)
+ sprintf(dest, "%s%.2f Gb", msg, size/1073741824.0);
+ else
+ sprintf(dest, "%s%.2f Tb", msg, size/1125899906842624.0);
+}
+
+BOOL CALLBACK PropertySheetFunc3(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
+ HWND dialog = GetParent(hwnd);
+ if(message == WM_INITDIALOG) {
+ SetDlgItemText(hwnd, IDC_INFO, "Ready to install");
+
+ char buf[256];
+ print_space(buf, "Space required: ", crn_decompressed_size);
+ SetDlgItemText(hwnd, IDC_SPACE1, buf);
+ ULARGE_INTEGER available,total,totalfree;
+ available.QuadPart=0;
+ total.QuadPart=0;
+ totalfree.QuadPart=0;
+ if(GetDiskFreeSpaceEx(install_path, &available, &total, &totalfree)) {
+ print_space(buf, "Space available: ", available.QuadPart);
+ } else {
+ sprintf(buf, "Space available: [Error %d]", GetLastError());
+ if((GetLastError() == ERROR_FILE_NOT_FOUND || GetLastError() == ERROR_PATH_NOT_FOUND)
+ && install_path[0] && install_path[1]==':') {
+ /* installation directory does not yet exist */
+ char path[3]={'c',':',0};
+ path[0] = install_path[0];
+ if(GetDiskFreeSpaceEx(path, &available, &total, &totalfree)) {
+ print_space(buf, "Space available: ", available.QuadPart);