/* * Main BrowseInfo callback to set the initial directory and populate the edit control */ INT CALLBACK BrowseInfoCallback(HWND hDlg, UINT message, LPARAM lParam, LPARAM pData) { char dir[MAX_PATH]; wchar_t* wpath; LPITEMIDLIST pidl; switch(message) { case BFFM_INITIALIZED: pOrgBrowseWndproc = (WNDPROC)SetWindowLongPtr(hDlg, GWLP_WNDPROC, (LONG_PTR)BrowseDlgCallback); // Windows hides the full path in the edit box by default, which is bull. // Get a handle to the edit control to fix that hBrowseEdit = FindWindowExA(hDlg, NULL, "Edit", NULL); SetWindowTextU(hBrowseEdit, szFolderPath); SetDialogFocus(hDlg, hBrowseEdit); // On Windows 7, MinGW only properly selects the specified folder when using a pidl wpath = utf8_to_wchar(szFolderPath); pidl = SHSimpleIDListFromPath(wpath); safe_free(wpath); // NB: see http://connect.microsoft.com/VisualStudio/feedback/details/518103/bffm-setselection-does-not-work-with-shbrowseforfolder-on-windows-7 // for details as to why we send BFFM_SETSELECTION twice. SendMessageW(hDlg, BFFM_SETSELECTION, (WPARAM)FALSE, (LPARAM)pidl); Sleep(100); PostMessageW(hDlg, BFFM_SETSELECTION, (WPARAM)FALSE, (LPARAM)pidl); break; case BFFM_SELCHANGED: // Update the status if (SHGetPathFromIDListU((LPITEMIDLIST)lParam, dir)) { SendMessageLU(hDlg, BFFM_SETSTATUSTEXT, 0, dir); SetWindowTextU(hBrowseEdit, dir); } break; } return 0; }
void PrintStatus(unsigned int duration, BOOL debug, const char *format, ...) { char *p = szStatusMessage; va_list args; int n; va_start(args, format); n = safe_vsnprintf(p, sizeof(szStatusMessage)-1, format, args); // room for NUL va_end(args); p += (n < 0)?sizeof(szStatusMessage)-1:n; while((p>szStatusMessage) && (isspace(p[-1]))) *--p = '\0'; *p = '\0'; if (debug) uprintf("%s\n", szStatusMessage); if ((duration) || (!bStatusTimerArmed)) { SendMessageLU(GetDlgItem(hMainDialog, IDC_STATUS), SB_SETTEXTA, SBT_OWNERDRAW | 0, szStatusMessage); } if (duration) { SetTimer(hMainDialog, TID_MESSAGE, duration, PrintStatusTimeout); bStatusTimerArmed = TRUE; } }
static void CALLBACK PrintStatusTimeout(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) { bStatusTimerArmed = FALSE; // potentially display lower priority message that was overridden SendMessageLU(GetDlgItem(hMainDialog, IDC_STATUS), SB_SETTEXTW, SBT_OWNERDRAW | 0, szStatusMessage); KillTimer(hMainDialog, TID_MESSAGE); }
void PrintStatus(unsigned int duration, BOOL debug, const char* message) { if (message == NULL) return; safe_strcpy(szStatusMessage, sizeof(szStatusMessage), message); if (debug) uprintf("%s\n", szStatusMessage); if ((duration) || (!bStatusTimerArmed)) { SendMessageLU(GetDlgItem(hMainDialog, IDC_STATUS), SB_SETTEXTA, SBT_OWNERDRAW | 0, szStatusMessage); } if (duration) { SetTimer(hMainDialog, TID_MESSAGE, duration, PrintStatusTimeout); bStatusTimerArmed = TRUE; } }
static void print_extracted_file(char* psz_fullpath, int64_t i_file_length) { size_t i, nul_pos; if (psz_fullpath == NULL) return; // Replace slashes with backslashes and append the size to the path for UI display nul_pos = strlen(psz_fullpath); for (i=0; i<nul_pos; i++) if (psz_fullpath[i] == '/') psz_fullpath[i] = '\\'; safe_sprintf(&psz_fullpath[nul_pos], 24, " (%s)", SizeToHumanReadable(i_file_length, TRUE, FALSE)); uprintf("Extracting: %s\n", psz_fullpath); safe_sprintf(&psz_fullpath[nul_pos], 24, " (%s)", SizeToHumanReadable(i_file_length, FALSE, FALSE)); // TODO: I don't think we need both of these... SendMessageLU(GetDlgItem(hMainDialog, IDC_STATUS), SB_SETTEXTW, SBT_OWNERDRAW, psz_fullpath); PrintStatus(0, MSG_000, psz_fullpath); // MSG_000 is "%s" // ISO9660 cannot handle backslashes for (i=0; i<nul_pos; i++) if (psz_fullpath[i] == '\\') psz_fullpath[i] = '/'; // Remove the appended size for extraction psz_fullpath[nul_pos] = 0; }