void CDialogDeleteProgress::SetCurrentFile(LPCTSTR file) { if ( file ) PathSetDlgItemPath(GetSafeHwnd(), IDC_LBL_DELETING, file); else SetDlgItemText(IDC_LBL_DELETING, _T("")); }
void CFilePath::SetDlgItem( HWND hDlgWnd, UINT dwCtrlID, DWORD dwEPPFlags) { CString sCleanPath = GetStr(dwEPPFlags); PathSetDlgItemPath(hDlgWnd, dwCtrlID, sCleanPath); }
void CExportLogDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CExportLogDlg) DDX_Control(pDX, IDC_RANGE, m_cRange); DDX_Control(pDX, IDC_EXPORT_SELECTION, m_cExportSelection); DDX_Control(pDX, IDC_EXPORT_RANGE, m_cExportRange); DDX_Control(pDX, IDC_EXPORT_ALL, m_cExportAll); DDX_Control(pDX, IDC_FORMAT, m_cFormat); DDX_Control(pDX, IDC_FILENAME, m_cFilename); DDX_Check(pDX, IDC_EXPORT_ALL, m_bExportAll); DDX_Check(pDX, IDC_EXPORT_RANGE, m_bExportRange); DDX_Check(pDX, IDC_EXPORT_SELECTION, m_bExportSelection); DDX_Text(pDX, IDC_RANGE, m_sRange); //}}AFX_DATA_MAP if(!pDX->m_bSaveAndValidate) { PathSetDlgItemPath(GetSafeHwnd(), IDC_FILENAME, m_sFilename); } }
BOOL OnInitDialog ( HWND hwnd, LPARAM lParam ) { PROPSHEETPAGE* ppsp = (PROPSHEETPAGE*) lParam; LPCTSTR szFile = (LPCTSTR) ppsp->lParam; HANDLE hFind; WIN32_FIND_DATA rFind; // Store the filename in this window's user data area, for later use. SetWindowLong ( hwnd, GWL_USERDATA, (LONG) szFile ); // Let FindFirstFile() do the work of retrieving the created, modified, // and last accessed times. hFind = FindFirstFile ( szFile, &rFind ); if ( INVALID_HANDLE_VALUE != hFind ) { // Initialize the DTP controls. SetCombinedDateTime ( hwnd, IDC_MODIFIED_DATE, IDC_MODIFIED_TIME, &rFind.ftLastWriteTime ); SetCombinedDateTime ( hwnd, IDC_ACCESSED_DATE, 0, &rFind.ftLastAccessTime ); SetCombinedDateTime ( hwnd, IDC_CREATED_DATE, IDC_CREATED_TIME, &rFind.ftCreationTime ); FindClose ( hFind ); } // Display the full path in the top static control. PathSetDlgItemPath ( hwnd, IDC_FILENAME, szFile ); return FALSE; // Take the default focus handling. }
void CDialogManage::CTabSkins::ReadSkin() { HWND item = GetDlgItem(m_Window, IDC_MANAGESKINS_FILE_TEXT); SetWindowText(item, m_SkinFileName.c_str()); PathSetDlgItemPath(m_Window, IDC_MANAGESKINS_CONFIG_TEXT, m_SkinFolderPath.c_str()); item = GetDlgItem(m_Window, IDC_MANAGESKINS_EDIT_BUTTON); EnableWindow(item, TRUE); std::wstring file = Rainmeter->GetSkinPath() + m_SkinFolderPath; file += L'\\'; file += m_SkinFileName; m_SkinWindow = Rainmeter->GetMeterWindowByINI(file); if (!m_SkinWindow) { DisableControls(); } SetControls(); WCHAR* buffer = new WCHAR[MAX_LINE_LENGTH]; item = GetDlgItem(m_Window, IDC_MANAGESKINS_AUTHOR_TEXT); GetPrivateProfileString(L"Rainmeter", L"Author", NULL, buffer, MAX_LINE_LENGTH, file.c_str()); SetWindowText(item, buffer); item = GetDlgItem(m_Window, IDC_MANAGESKINS_ADDMETADATA_LINK); if (GetPrivateProfileSection(L"Metadata", buffer, 8, file.c_str()) > 0) { ShowWindow(item, SW_HIDE); // Set metadata item = GetDlgItem(m_Window, IDC_MANAGESKINS_VERSION_TEXT); GetPrivateProfileString(L"Metadata", L"Version", NULL, buffer, MAX_LINE_LENGTH, file.c_str()); SetWindowText(item, buffer); item = GetDlgItem(m_Window, IDC_MANAGESKINS_LICENSE_TEXT); GetPrivateProfileString(L"Metadata", L"License", NULL, buffer, MAX_LINE_LENGTH, file.c_str()); SetWindowText(item, buffer); item = GetDlgItem(m_Window, IDC_MANAGESKINS_DESCRIPTION_TEXT); std::wstring text; if (GetPrivateProfileString(L"Metadata", L"Information", NULL, buffer, MAX_LINE_LENGTH, file.c_str()) > 0) { text = buffer; } else { // For backwards compatibility GetPrivateProfileString(L"Metadata", L"Description", NULL, buffer, MAX_LINE_LENGTH, file.c_str()); text = buffer; if (GetPrivateProfileString(L"Metadata", L"Instructions", NULL, buffer, MAX_LINE_LENGTH, file.c_str()) > 0) { text += L"\r\n\r\n"; text += buffer; } } // Replace | with newline std::wstring::size_type pos; while ((pos = text.find_first_of(L'|')) != std::wstring::npos) { size_t count = (pos + 1 < text.length() && text[pos + 1] == L' ') ? 2 : 1; if (text[pos - 1] == L' ') { --pos; count += 1; } text.replace(pos, count, L"\r\n"); } SetWindowText(item, text.c_str()); int lines = Edit_GetLineCount(item); ShowScrollBar(item, SB_VERT, (BOOL)(lines > 6)); } else { ShowWindow(item, SW_SHOWNORMAL); item = GetDlgItem(m_Window, IDC_MANAGESKINS_VERSION_TEXT); SetWindowText(item, L""); item = GetDlgItem(m_Window, IDC_MANAGESKINS_LICENSE_TEXT); SetWindowText(item, L""); item = GetDlgItem(m_Window, IDC_MANAGESKINS_DESCRIPTION_TEXT); SetWindowText(item, L""); ShowScrollBar(item, SB_VERT, FALSE); } delete [] buffer; }
INT_PTR CALLBACK CDialogPackage::SelectPluginDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: { EnableThemeDialogTexture(hWnd, ETDT_ENABLETAB); c_Dialog->SetDialogFont(hWnd); auto plugins = (std::pair<std::wstring, std::wstring>*)lParam; SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)plugins); } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_PACKAGESELECTPLUGIN_32BITBROWSE_BUTTON: case IDC_PACKAGESELECTPLUGIN_64BITBROWSE_BUTTON: { WCHAR buffer[MAX_PATH]; buffer[0] = L'\0'; OPENFILENAME ofn = { sizeof(OPENFILENAME) }; ofn.Flags = OFN_FILEMUSTEXIST; ofn.lpstrFilter = L"Plugins (.dll)\0*.dll"; ofn.lpstrTitle = L"Select plugin file"; ofn.lpstrDefExt = L"dll"; ofn.nFilterIndex = 0; ofn.lpstrFile = buffer; ofn.nMaxFile = _countof(buffer); ofn.hwndOwner = c_Dialog->GetWindow(); if (!GetOpenFileName(&ofn)) { break; } bool x32 = LOWORD(wParam) == IDC_PACKAGESELECTPLUGIN_32BITBROWSE_BUTTON; LOADED_IMAGE* loadedImage = ImageLoad(StringUtil::NarrowUTF8(buffer).c_str(), NULL); if (loadedImage) { WORD machine = loadedImage->FileHeader->FileHeader.Machine; ImageUnload(loadedImage); if ((x32 && machine == IMAGE_FILE_MACHINE_I386) || (!x32 && machine == IMAGE_FILE_MACHINE_AMD64)) { // Check if same name as other DLL auto plugins = (std::pair<std::wstring, std::wstring>*)GetWindowLongPtr(hWnd, GWLP_USERDATA); const WCHAR* otherName = PathFindFileName(x32 ? plugins->second.c_str() : plugins->first.c_str()); if (*otherName && _wcsicmp(otherName, PathFindFileName(buffer)) != 0) { MessageBox(hWnd, L"Plugins must have same name.", L"Rainmeter Skin Packager", MB_OK | MB_TOPMOST); break; } PathSetDlgItemPath(hWnd, x32 ? IDC_PACKAGESELECTPLUGIN_32BIT_EDIT : IDC_PACKAGESELECTPLUGIN_64BIT_EDIT, buffer); (x32 ? plugins->first : plugins->second) = buffer; if (!plugins->first.empty() && !plugins->second.empty()) { // Enable Add button if both plugins have been selected EnableWindow(GetDlgItem(hWnd, IDOK), TRUE); } break; } } MessageBox(hWnd, L"Invalid plugin.", L"Rainmeter Skin Packager", MB_OK | MB_TOPMOST); } break; case IDOK: EndDialog(hWnd, 1); break; } break; case WM_CLOSE: EndDialog(hWnd, 0); break; default: return FALSE; } return TRUE; }
// on callback message. LRESULT PageProgress::OnCallback(WPARAM wParam, LPARAM lParam) { // Process the next callback lockListData.Lock(); SmartPtr<CallbackData> data; if (!listData.IsEmpty()) data = listData.RemoveHead(); lockListData.Unlock(); if (!data) return 0; // Call the callback function if valid switch (data->type) { case started: { // Record the start time timeStart = CTime::GetCurrentTime(); // Set the progress bars Progress(data->engine, data->status); // Display a description of the operation CString description; switch (data->status.state) { case DFUEngine::reconfigure: description.Format(IDS_PROGRESS_OPERATION_RECONFIGURE); break; case DFUEngine::upload: animateProgress.Open(IDR_AVI_UPLOAD); description.Format(IDS_PROGRESS_OPERATION_UPLOAD); break; case DFUEngine::download: animateProgress.Open(IDR_AVI_DOWNLOAD); description.Format(IDS_PROGRESS_OPERATION_DOWNLOAD, fileDownload); break; case DFUEngine::manifest: animateProgress.Open(IDR_AVI_MANIFEST); description.Format(IDS_PROGRESS_OPERATION_MANIFEST); break; } PathSetDlgItemPath(m_hWnd, IDC_PAGE_PROGRESS_SUB_STATIC, description); } break; case progress: { // Set the progress bar for the whole procedure int start = ProgressTime((DFUEngine::State) (data->status.state - 1)); int end = ProgressTime(data->status.state); int total = ProgressTime(DFUEngine::manifest); progressMain.SetPos((start * 100 + (end - start) * data->status.percent) / total); // Set the progress bar for this operation progressSub.SetPos(data->status.percent); // Set the comment staticComment.SetWindowText(data->status.activity()); } break; case complete: { // Record the end time timeEnd = CTime::GetCurrentTime(); timeTotal += timeEnd - timeStart; timeTakenTotal.Format(IDS_RESULTS_MSG_TIME, (int)timeTotal.GetTotalMinutes(), (int)timeTotal.GetSeconds()); // Special case if failed to upload due to corrupt firmware bool ignoreResult = false; if ((data->status.state == DFUEngine::upload) && ((data->status.result.GetCode() == DFUEngine::fail_dfu_firmware) || (data->status.result.GetCode() == DFUEngine::fail_no_upload))) { // Check if the user wants to skip the upload and download anyway int result = AfxMessageBox(data->status.result.GetCode() == DFUEngine::fail_dfu_firmware ? IDP_SKIP_UPLOAD_CORRUPT_QUERY : IDP_SKIP_UPLOAD_UNSUPPORTED_QUERY, MB_YESNO | MB_ICONQUESTION); // Continue with the download if required if (result == IDYES) { GetSheet()->pageAction.valueAction = PageAction::download; fileUpload.Empty(); ignoreResult = true; } } // Set the progress bars if (!ignoreResult) Progress(data->engine, data->status); // Action depends on whether the operation was successful if (data->status.result || ignoreResult) CompleteSuccess(data->status); else CompleteFail(data->status); } break; } return 0; }