| 91 | } |
| 92 | |
| 93 | INT_PTR ProgressDialog::DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 94 | { |
| 95 | switch (uMsg) |
| 96 | { |
| 97 | case WM_INITDIALOG: { |
| 98 | SetWindowText(hWnd, TmGetTString(m_bDirection ? IDS_FILE_UPLOAD : IDS_FILE_DOWNLOAD)); |
| 99 | |
| 100 | LONG_PTR lp = GetWindowLongPtr(hWnd, GWLP_WNDPROC); |
| 101 | SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)&WndProc); |
| 102 | SetWindowLongPtr(hWnd, GWLP_USERDATA, lp); |
| 103 | m_hwnd = hWnd; |
| 104 | |
| 105 | LPTSTR fileName = ConvertCppStringToTString(m_fileName); |
| 106 | SetDlgItemText(hWnd, IDC_UPLOADING_FILENAME, fileName); |
| 107 | free(fileName); |
| 108 | |
| 109 | SetDlgItemText(hWnd, IDC_UPLOADING_ETA, TmGetTString(IDS_CALCULATING)); |
| 110 | SetDlgItemText(hWnd, IDC_UPLOADING_ACTION, TmGetTString(m_bDirection ? IDS_UPLOADING : IDS_DOWNLOADING)); |
| 111 | |
| 112 | SendMessage(GetDlgItem(hWnd, IDC_UPLOADING_PROGRESS), PBM_SETRANGE, 0, MAKELPARAM(0, 1000)); |
| 113 | SendMessage(GetDlgItem(hWnd, IDC_UPLOADING_PROGRESS), PBM_SETPOS, 0, 0); |
| 114 | |
| 115 | HDC hdc = GetDC(hWnd); |
| 116 | int bpp = GetDeviceCaps(hdc, BITSPIXEL); |
| 117 | ReleaseDC(hWnd, hdc); |
| 118 | |
| 119 | int res; |
| 120 | bool isHighColor = bpp > 8; |
| 121 | |
| 122 | if (m_bDirection) { |
| 123 | res = isHighColor ? IDR_AVI_UPLOAD_HC : IDR_AVI_UPLOAD_LC; |
| 124 | } |
| 125 | else { |
| 126 | res = isHighColor ? IDR_AVI_DOWNLOAD_HC : IDR_AVI_DOWNLOAD_LC; |
| 127 | } |
| 128 | |
| 129 | Animate_Open(GetDlgItem(hWnd, IDC_PROGRESS_ANIMATE), MAKEINTRESOURCE(res)); |
| 130 | |
| 131 | CenterWindow(hWnd, g_Hwnd); |
| 132 | break; |
| 133 | } |
| 134 | |
| 135 | case WM_DESTROY: |
| 136 | if (m_hwnd != hWnd) |
| 137 | break; |
| 138 | |
| 139 | m_hwnd = NULL; |
| 140 | m_key = 0; |
| 141 | m_fileName.clear(); |
| 142 | m_offset = m_length = 0; |
| 143 | m_bCanceling = false; |
| 144 | break; |
| 145 | |
| 146 | case WM_UPDATEUPLOADING: { |
| 147 | if (m_bCanceling) |
| 148 | break; |
| 149 | |
| 150 | std::string strProgress = std::to_string(m_offset / 1024) + " of " + std::to_string(m_length / 1024) + " KB"; |
nothing calls this directly
no test coverage detected