/* * OnInitDialog() */ BOOL id_OnInitDialog(HWND importDlg, HWND focusCtrl, LPARAM lParam) { /* * Set the "Open" button text. */ CommDlg_OpenSave_SetControlText(GetParent(importDlg), IDOK, _T("Import")); /* * Initialize the check boxes. */ if ((Prog_importOptions & IO_BOTH) == IO_BOTH) { CheckRadioButton(importDlg, IDC_VMEM_RDO, IDC_BOTH_RDO, IDC_BOTH_RDO); } else if (Prog_importOptions & IO_PMEMS) { CheckRadioButton(importDlg, IDC_VMEM_RDO, IDC_BOTH_RDO, IDC_PMEM_RDO); } else { CheckRadioButton(importDlg, IDC_VMEM_RDO, IDC_BOTH_RDO, IDC_VMEM_RDO); } if (Prog_importOptions & IO_NO_DUPLICATES) { CheckDlgButton(importDlg, IDC_NO_DUPLICATES_CHK, BST_CHECKED); } if (Prog_importOptions & IO_UNIQUE_NAMES) { CheckDlgButton(importDlg, IDC_UNIQUE_NAMES_CHK, BST_CHECKED); } if (Prog_importOptions & IO_CHECK_EVERY_POS) { CheckDlgButton(importDlg, IDC_CHECK_EVERY_POS_CHK, BST_CHECKED); } return TRUE; }
UINT_PTR CALLBACK OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) { LPOFNOTIFY notify; if(uiMsg==WM_NOTIFY) { notify = (LPOFNOTIFY)lParam; if(notify->hdr.code==CDN_INITDONE) { CommDlg_OpenSave_SetControlText(GetParent(hdlg),chx1,TEXT("Reparent SFV/MD5")); } } return 0; }
void CFECFileDialog::OnInitDone() { // Set the text of the IDOK button on an // Explorer style dialog to 'OK' CString szOkButton; #if defined FEC_NORESOURCESTRINGS szOkButton = FEC_IDS_OKBUTTON; #else szOkButton.LoadString(FEC_IDS_OKBUTTON); #endif CommDlg_OpenSave_SetControlText(GetParent()->m_hWnd, IDOK, (LPCTSTR)szOkButton); }
void CGetFileNameDialog::OnInitDone() { CString sText; VERIFY(sText.LoadString(IDS_DDX_GF_OK)); LPTSTR pszBuffer = sText.GetBuffer(sText.GetLength()); //modify the text on the IDOK button to ok CommDlg_OpenSave_SetControlText(GetParent()->m_hWnd, IDOK, pszBuffer); sText.ReleaseBuffer(); }
static UINT CALLBACK SaveHook(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if ( uMsg == WM_COMMAND ) { HANDLE_WM_COMMAND(hWnd, wParam, lParam, SaveOnCommand); } #if defined(WIN32) && defined(WINVER) && WINVER >= 0x0400 else if ( uMsg == WM_NOTIFY ) { if ( ((LPOFNOTIFY)lParam)->hdr.code == CDN_TYPECHANGE ) { char szFilename[_MAX_PATH + 1]; char szType[128]; LPOPENFILENAME lpofn = ((LPOFNOTIFY)lParam)->lpOFN; LPCSTR psz; UINT i; psz = lpofn->lpstrFilter; for ( i = 1 /* 1-based index */ ; *psz != '\0' && i < lpofn->nFilterIndex; i++ ) { psz += strlen(psz) + 1; psz += strlen(psz) + 1; } strcpy(szType, psz); assert(szType[0] != '\0'); if ( CommDlg_OpenSave_GetSpec( GetParent(hWnd), szFilename, sizeof(szFilename)) > 1 && szType[0] != '\0' ) { SaveOnTypeSelChange(szType, szFilename); CommDlg_OpenSave_SetControlText(GetParent(hWnd), edt1, szFilename); } else { /* else it's the null string or an error */ if ( szType[0] == '\0' ) { ErrorMessage(STYLE_ERROR, IDS_SAVEINTERNAL2); } } } } #endif return ( 0 ); }
UINT_PTR CALLBACK CTortoiseMergeApp::CreatePatchFileOpenHook(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM /*lParam*/) { if(uiMsg == WM_COMMAND && LOWORD(wParam) == IDC_PATCH_TO_CLIPBOARD) { HWND hFileDialog = GetParent(hDlg); // if there's a patchfile in the clipboard, we save it // to a temporary file and tell TortoiseMerge to use that one std::wstring sTempFile; if (TrySavePatchFromClipboard(sTempFile)) { CommDlg_OpenSave_SetControlText(hFileDialog, edt1, sTempFile.c_str()); PostMessage(hFileDialog, WM_COMMAND, MAKEWPARAM(IDOK, BM_CLICK), (LPARAM)(GetDlgItem(hDlg, IDOK))); } } return 0; }
UINT_PTR CALLBACK CTortoiseMergeApp::CreatePatchFileOpenHook(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM /*lParam*/) { if(uiMsg == WM_COMMAND && LOWORD(wParam) == IDC_PATCH_TO_CLIPBOARD) { HWND hFileDialog = GetParent(hDlg); // if there's a patchfile in the clipboard, we save it // to a temporary file and tell TortoiseMerge to use that one UINT cFormat = RegisterClipboardFormat(_T("TSVN_UNIFIEDDIFF")); if ((cFormat)&&(OpenClipboard(NULL))) { HGLOBAL hglb = GetClipboardData(cFormat); LPCSTR lpstr = (LPCSTR)GlobalLock(hglb); DWORD len = GetTempPath(0, NULL); TCHAR * path = new TCHAR[len+1]; TCHAR * tempF = new TCHAR[len+100]; GetTempPath (len+1, path); GetTempFileName (path, TEXT("tsm"), 0, tempF); std::wstring sTempFile = std::wstring(tempF); delete [] path; delete [] tempF; FILE * outFile; size_t patchlen = strlen(lpstr); _tfopen_s(&outFile, sTempFile.c_str(), _T("wb")); if(outFile) { size_t size = fwrite(lpstr, sizeof(char), patchlen, outFile); if (size == patchlen) { CommDlg_OpenSave_SetControlText(hFileDialog, edt1, sTempFile.c_str()); PostMessage(hFileDialog, WM_COMMAND, MAKEWPARAM(IDOK, BM_CLICK), (LPARAM)(GetDlgItem(hDlg, IDOK))); } fclose(outFile); } GlobalUnlock(hglb); CloseClipboard(); } } return 0; }
/* ** Name: LocSelHookProc ** ** Description: ** Hook Procedure for GetFileNameOpen() common dialog box */ static UINT CALLBACK LocSelHookProc(HWND hDlg, UINT messg, WPARAM wParam, LPARAM lParam) { BOOL rc; CWnd Parent; rc=TRUE; switch (messg) { case WM_INITDIALOG: /* Set Default Values for Entry Fields */ Parent.Attach(::GetParent(hDlg)); Parent.CenterWindow(); Parent.Detach(); CommDlg_OpenSave_SetControlText(::GetParent(hDlg), IDOK, "OK"); rc=TRUE; break; default: rc=FALSE; break; } return rc; }
UINT_PTR APIENTRY FileDialogHookFunction(HWND hDlg, UINT iMsg, WPARAM WXUNUSED(wParam), LPARAM lParam) { HWND hwndDialog; hwndDialog = ::GetParent( hDlg ); switch (iMsg) { case WM_INITDIALOG: { #ifdef _WIN64 SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam); #else SetWindowLong(hDlg, GWL_USERDATA, lParam); #endif } case WM_DESTROY: { RECT dlgRect; GetWindowRect( hwndDialog, & dlgRect ); gs_rectDialog.x = dlgRect.left; gs_rectDialog.y = dlgRect.top; gs_rectDialog.width = dlgRect.right - dlgRect.left; gs_rectDialog.height = dlgRect.bottom - dlgRect.top; break; } case WM_NOTIFY: { OFNOTIFY * pNotifyCode; pNotifyCode = (LPOFNOTIFY) lParam; if (CDN_INITDONE == (pNotifyCode->hdr).code) { SetWindowPos( hwndDialog, HWND_TOP, gs_rectDialog.x, gs_rectDialog.y, gs_rectDialog.width, gs_rectDialog.height, SWP_NOZORDER|SWP_NOSIZE); OPENFILENAME *ofn = (OPENFILENAME *) GetWindowLongPtr(hDlg, GWLP_USERDATA); FileDialog *me = (FileDialog *) ofn->lCustData; if (!me->m_buttonlabel.IsEmpty()) { CommDlg_OpenSave_SetControlText( hwndDialog, pshHelp, (LPTSTR)me->m_buttonlabel.c_str()); } } else if (CDN_HELP == (pNotifyCode->hdr).code) { OPENFILENAME *ofn = (OPENFILENAME *) GetWindowLongPtr(hDlg, GWLP_USERDATA); FileDialog *me = (FileDialog *) ofn->lCustData; HWND w = GetFocus(); int index = SendDlgItemMessage(hwndDialog, cmb1, CB_GETCURSEL, 0, 0); me->ClickButton(index); SetFocus(w); } else if (CDN_SELCHANGE == (pNotifyCode->hdr).code) { OPENFILENAME *ofn = (OPENFILENAME *) GetWindowLongPtr(hDlg, GWLP_USERDATA); FileDialog *me = (FileDialog *) ofn->lCustData; me->FilterFiles(hDlg); } else if (CDN_TYPECHANGE == (pNotifyCode->hdr).code) { OPENFILENAME *ofn = (OPENFILENAME *) GetWindowLongPtr(hDlg, GWLP_USERDATA); FileDialog *me = (FileDialog *) ofn->lCustData; me->ParseFilter(ofn->nFilterIndex); me->FilterFiles(hDlg); } break; } } // do the default processing return 0; }