void CWizardFoldersPage::OnDownloadsBrowse() { CString strPath( BrowseForFolder( _T("Select folder for downloads:"), m_sDownloadsPath ) ); if ( strPath.IsEmpty() ) return; // Warn user about a path that's too long if ( _tcslen( strPath ) > MAX_PATH - 33 ) { MsgBox( IDS_SETTINGS_FILEPATH_TOO_LONG, MB_ICONEXCLAMATION ); return; } // Make sure download/incomplete folders aren't the same if ( _tcsicmp( strPath, m_sIncompletePath ) == 0 ) { MsgBox( IDS_SETTINGS_FILEPATH_NOT_SAME, MB_ICONEXCLAMATION ); return; } UpdateData( TRUE ); m_sDownloadsPath = strPath; m_sTorrentsPath = strPath + _T("\\Torrents"); UpdateData( FALSE ); }
void CWizardFoldersPage::OnIncompleteBrowse() { CString strPath( BrowseForFolder( _T("Select folder for incomplete files:"), m_sIncompletePath ) ); if ( strPath.IsEmpty() ) return; // Warn user about a path that's too long if ( _tcslen( strPath ) > MAX_PATH - 52 ) { MsgBox( IDS_SETTINGS_FILEPATH_TOO_LONG, MB_ICONEXCLAMATION ); return; } // Make sure download/incomplete folders aren't the same if ( _tcsicmp( strPath, m_sDownloadsPath ) == 0 ) { MsgBox( IDS_SETTINGS_FILEPATH_NOT_SAME, MB_ICONEXCLAMATION ); return; } // Warn user about an incomplete folder in the library if ( LibraryFolders.IsFolderShared( strPath ) ) { MsgBox( IDS_SETTINGS_INCOMPLETE_LIBRARY, MB_ICONEXCLAMATION ); return; } UpdateData( TRUE ); m_sIncompletePath = strPath; UpdateData( FALSE ); }
void CDownloadGroupDlg::OnBrowse() { UpdateData(); CString strPath( BrowseForFolder( _T("Select folder for downloads:"), m_sFolder ) ); if ( strPath.IsEmpty() ) return; // Make sure download/incomplete folders aren't the same if ( _tcsicmp( strPath, Settings.Downloads.IncompletePath ) == 0 ) { CString strMessage; LoadString( strMessage, IDS_SETTINGS_FILEPATH_NOT_SAME ); AfxMessageBox( strMessage, MB_ICONEXCLAMATION ); return; } // If the group folder and schema default download folders are the same, // use the default download folder CString sSchema = m_wndSchemas.GetSelectedURI(); if ( sSchema != CSchema::uriBitTorrent && sSchema != CSchema::uriCollection && ! strPath.CompareNoCase( Settings.Downloads.CompletePath ) ) m_sFolder.Empty(); else m_sFolder = strPath; UpdateData( FALSE ); }
bool BrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath) { if (g_IsNT) return BrowseForFolder(owner, title, BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS // | BIF_STATUSTEXT // This flag is not supported when BIF_NEWDIALOGSTYLE is specified. , initialFolder, resultPath); // BIF_STATUSTEXT; BIF_USENEWUI (Version 5.0) CSysString s; bool res = BrowseForFolder(owner, GetSystemString(title), BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS // | BIF_STATUSTEXT // This flag is not supported when BIF_NEWDIALOGSTYLE is specified. , GetSystemString(initialFolder), s); resultPath = GetUnicodeString(s); return res; }
bool BrowseForFolder(HWND owner, LPCTSTR title, LPCTSTR initialFolder, CSysString &resultPath) { return BrowseForFolder(owner, title, BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT, initialFolder, resultPath); // BIF_STATUSTEXT; BIF_USENEWUI (Version 5.0) }
void CDownloadsSettingsPage::OnDownloadsBrowse() { CString strPath( BrowseForFolder( _T("Select folder for downloads:"), m_sDownloadsPath ) ); if ( strPath.IsEmpty() ) return; // Warn user about a path that's too long if ( _tcslen( strPath ) > MAX_PATH - 33 ) { CString strMessage; LoadString( strMessage, IDS_SETTINGS_FILEPATH_TOO_LONG ); AfxMessageBox( strMessage, MB_ICONEXCLAMATION ); return; } // Make sure download/incomplete folders aren't the same if ( _tcsicmp( strPath, m_sIncompletePath ) == 0 ) { CString strMessage; LoadString( strMessage, IDS_SETTINGS_FILEPATH_NOT_SAME ); AfxMessageBox( strMessage, MB_ICONEXCLAMATION ); return; } UpdateData( TRUE ); m_sDownloadsPath = strPath; m_bDownloadsChanged = TRUE; UpdateData( FALSE ); }
static void OnButtonBrowse() { ScopedMem<WCHAR> installDir(win::GetText(gHwndTextboxInstDir)); // strip a trailing "\SumatraPDF" if that directory doesn't exist (yet) if (!dir::Exists(installDir)) installDir.Set(path::GetDir(installDir)); WCHAR path[MAX_PATH]; BOOL ok = BrowseForFolder(gHwndFrame, installDir, _TR("Select the folder where SumatraPDF should be installed:"), path, dimof(path)); if (!ok) { SetFocus(gHwndButtonBrowseDir); return; } WCHAR *installPath = path; // force paths that aren't entered manually to end in ...\SumatraPDF // to prevent unintended installations into e.g. %ProgramFiles% itself if (!str::EndsWithI(path, L"\\" APP_NAME_STR)) installPath = path::Join(path, APP_NAME_STR); win::SetText(gHwndTextboxInstDir, installPath); Edit_SetSel(gHwndTextboxInstDir, 0, -1); SetFocus(gHwndTextboxInstDir); if (installPath != path) free(installPath); }
/* This function handles the ChangeDir dialog box. */ BOOL EXPORT WINAPI Amuser_ChangeDirectory( LPCHGDIR lpChgDir ) { #ifdef USE_SHELL_BROWSER if( wWinVer >= 0x35F ) return( BrowseForFolder( lpChgDir ) ); #endif return( Adm_Dialog( hLibInst, lpChgDir->hwnd, MAKEINTRESOURCE( IDDLG_CHANGEDIR ), ChangeDir, (LPARAM)lpChgDir ) ); }
void CLinkBarPropertyPage::OnLinkExportToFolder(UINT uNotifyCode, int nID, CWindow wndCtl) { CWaitCursor waitCursor; CString folder = BrowseForFolder(m_hWnd); if (folder.GetLength() > 0) { m_rLinkBarCtrl.LinkExportToFolder(folder); } }
void PageSystem2::on_output_lib_browse_clicked(HWND hWnd) { TCHAR str[1024]; str[0] = 0; if (BrowseForFolder(hWnd, TEXT("Select output Library directory"), str)) { SendMessage(GetDlgItem(hWnd, IDC_OUTPUT_LIB), WM_SETTEXT, 0, (LPARAM) str); } }
void PageSystem::on_input_include_browse_clicked(HWND hWnd) { TCHAR str[1024]; str[0] = 0; if (BrowseForFolder(hWnd, TEXT("Select input Include directory"), str)) { SendMessage(GetDlgItem(hWnd, IDC_INPUT_INCLUDE), WM_SETTEXT, 0, (LPARAM) str); } }
void CReplacePathsDlg::OnBrowseButton() { CString strPath; if (BrowseForFolder(GetResManager().LoadString(IDS_BROWSE_STRING), &strPath)) { UpdateData(TRUE); m_strDest=strPath; UpdateData(FALSE); } }
void CWizardFoldersPage::OnTorrentsBrowse() { CString strPath( BrowseForFolder( _T("Select folder for torrents:"), m_sTorrentsPath ) ); if ( strPath.IsEmpty() ) return; UpdateData( TRUE ); m_sTorrentsPath = strPath; UpdateData( FALSE ); }
void CLinkBarPropertyPage::OnLinkImportFromFolder(UINT uNotifyCode, int nID, CWindow wndCtl) { if (MessageBox(_T("インポートすると現在のリンクはすべて削除されますが、よろしいですか?"), _T("確認"), MB_YESNO) == IDNO) return ; CWaitCursor waitCursor; CString folder = BrowseForFolder(m_hWnd); if (folder.GetLength() > 0) { m_rLinkBarCtrl.LinkImportFromFolder(folder); } }
void CLibrarySettingsPage::OnCollectionsBrowse() { CString strPath( BrowseForFolder( _T("Select folder for collections:"), m_sCollectionPath ) ); if ( strPath.IsEmpty() ) return; UpdateData( TRUE ); m_sCollectionPath = strPath; //m_bCollectionsChanged = TRUE; UpdateData( FALSE ); }
void CSystemPage::OnOutputLibBrowse() { char str[1024]; UpdateData(TRUE); if (BrowseForFolder(m_hWnd, "Select Lib directory", str)) { lstrcat(str, "\\"); m_outputLib = str; } UpdateData(FALSE); }
void CSystemPage::OnTempDebugBrowse() { char str[1024]; UpdateData(TRUE); if (BrowseForFolder(m_hWnd, "Select Debug directory", str)) { lstrcat(str, "\\"); m_tempDebug = str; } UpdateData(FALSE); }
static bool BrowseForFolder(HWND owner, LPCWSTR title, UINT ulFlags, LPCWSTR initialFolder, UString &resultPath) { UString displayName; BROWSEINFOW browseInfo; browseInfo.hwndOwner = owner; browseInfo.pidlRoot = NULL; browseInfo.pszDisplayName = displayName.GetBuffer(MAX_PATH); browseInfo.lpszTitle = title; browseInfo.ulFlags = ulFlags; browseInfo.lpfn = (initialFolder != NULL) ? BrowseCallbackProc2 : NULL; browseInfo.lParam = (LPARAM)initialFolder; return BrowseForFolder(&browseInfo, resultPath); }
//=========================================================================== /// OnBnClickedButtonCreatesuperpixels /// /// The main function //=========================================================================== void CSLICSuperpixelsDlg::OnBnClickedButtonCreatesuperpixels() { PictureHandler picHand; vector<string> picvec(0); picvec.resize(0); GetPictures(picvec);//user chooses one or more pictures string saveLocation = "C:\\rktemp\\"; BrowseForFolder(saveLocation); int numPics( picvec.size() ); //if(m_spcount < 0 || m_spcount < 20) m_spcount = 20; if(m_spcount < 0) m_spcount = 200; for( int k = 0; k < numPics; k++ ) { UINT* img = NULL; int width(0); int height(0); picHand.GetPictureBuffer( picvec[k], img, width, height ); int sz = width*height; if(m_spcount > sz) AfxMessageBox(L"Number of superpixels exceeds number of pixels in the image"); int* labels = new int[sz]; int numlabels(0); SLIC slic; slic.PerformSLICO_ForGivenK(img, width, height, labels, numlabels, m_spcount, m_compactness);//for a given number K of superpixels //slic.PerformSLICO_ForGivenStepSize(img, width, height, labels, numlabels, m_stepsize, m_compactness);//for a given grid step size //slic.DrawContoursAroundSegments(img, labels, width, height, 0);//for black contours around superpixels slic.DrawContoursAroundSegmentsTwoColors(img, labels, width, height);//for black-and-white contours around superpixels slic.SaveSuperpixelLabels(labels,width,height,picvec[k],saveLocation); if(labels) delete [] labels; picHand.SavePicture(img, width, height, picvec[k], saveLocation, 1, "_SLICO");// 0 is for BMP and 1 for JPEG) if(img) delete [] img; } AfxMessageBox(L"Done!", 0, 0); }
void Cdlgcoverfile::OnButton2() { // TODO: Add your control notification handler code here UpdateData(); if (m_strSrcpath == "") { return; } // CString strFileName = _T("TestCover.avi"); // CFileDialog dlg( FALSE , _T("h264"), strFileName , OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY, // "All File(*.avi)|*.*||" , this ); // if ( dlg.DoModal() == IDOK ) // { // m_strDesPath = dlg.GetPathName(); // } CString strSaveName(""); //strSaveName.Format("c:\\record"); strSaveName = BrowseForFolder(GetSafeHwnd()) ; CString strFileName = _T("TestCover.avi"); m_strDesPath = strSaveName + _T("\\")+strFileName; UpdateData(FALSE); }
void CDKnownProcesses::OnButtonAddnew() { // TODO: Add your control notification handler code here CString title = _T("Select executable file"); CString strpath; if (BrowseForFolder(this->m_hWnd, title, strpath, TRUE, NULL)) { PWCHAR pwch = strpath.GetBuffer(strpath.GetLength() + sizeof(TCHAR)); if (pwch != NULL) { CProcessRecognizer recognizer(pwch); m_pKnownList->RegisterNewProcess(pwch, &recognizer); strpath.ReleaseBuffer(); } else { //! error during add new process } } ReloadList(); }
void CDlgCompilerPath::OnSelpath() { const char* pfld = BrowseForFolder("Select script directory", ""); if(pfld) _efPath.SetWindowText(pfld); }
INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwnd); { MCONTACT hContact = (MCONTACT)((PROPSHEETPAGE*)lParam)->lParam; SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)hContact); if (!hContact) break; /* link*/ DBVARIANT dbv; if (!db_get_ts(hContact, MODNAME, "ProgramString", &dbv)) { SetDlgItemText(hwnd, IDC_LINK, dbv.ptszVal); db_free(&dbv); } if (!db_get_ts(hContact, MODNAME, "ProgramParamsString", &dbv)) { SetDlgItemText(hwnd, IDC_PARAMS, dbv.ptszVal); db_free(&dbv); } /* group*/ TCHAR *szGroup; for (int i = 1; (szGroup = pcli->pfnGetGroupName(i, NULL)) != NULL; i++) SendDlgItemMessage(hwnd, IDC_GROUP, CB_INSERTSTRING, 0, LPARAM(szGroup)); if (!db_get_ts(hContact, "CList", "Group", &dbv)) { SetDlgItemText(hwnd, IDC_GROUP, dbv.ptszVal); db_free(&dbv); } /* icons */ CheckRadioButton(hwnd, 40072, 40080, db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE)); SetWindowLongPtr(GetDlgItem(hwnd, CHK_ONLINE), GWLP_USERDATA, (LONG_PTR)Skin_LoadProtoIcon(MODNAME, ID_STATUS_ONLINE)); g_PrevBtnWndProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwnd, CHK_ONLINE), GWLP_WNDPROC, (LONG_PTR)ButtWndProc); for (int i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { SetWindowLongPtr(GetDlgItem(hwnd, i), GWLP_USERDATA, (LONG_PTR)Skin_LoadProtoIcon(MODNAME, i)); SetWindowLongPtr(GetDlgItem(hwnd, i), GWLP_WNDPROC, (LONG_PTR)ButtWndProc); } db_free(&dbv); /* timer */ CheckDlgButton(hwnd, CHK_USE_TIMER, db_get_b(hContact, MODNAME, "UseTimer", 0) ? BST_CHECKED : BST_UNCHECKED); if (db_get_w(hContact, MODNAME, "Timer", 15)) { CheckDlgButton(hwnd, CHK_USE_TIMER, BST_CHECKED); EnableWindow(GetDlgItem(hwnd, IDC_TIMER), 1); TCHAR string[512]; SetDlgItemText(hwnd, IDC_TIMER, _itot(db_get_w(hContact, MODNAME, "Timer", 15), string, 10)); if (!db_get_w(NULL, MODNAME, "Timer", 1)) SetDlgItemText(hwnd, IDC_TIMER_INTERVAL_MSG, TranslateT("Non-IM Contact protocol timer is Disabled")); else { mir_sntprintf(string, TranslateT("Timer intervals... Non-IM Contact Protocol timer is %d seconds"), db_get_w(NULL, MODNAME, "Timer", 1)); SetDlgItemText(hwnd, IDC_TIMER_INTERVAL_MSG, string); } } /* always visible */ if (db_get_b(hContact, MODNAME, "AlwaysVisible", 0)) { CheckDlgButton(hwnd, IDC_ALWAYS_VISIBLE, BST_CHECKED); EnableWindow(GetDlgItem(hwnd, IDC_VISIBLE_UNLESS_OFFLINE), 1); CheckDlgButton(hwnd, IDC_VISIBLE_UNLESS_OFFLINE, db_get_b(hContact, MODNAME, "VisibleUnlessOffline", 1) ? BST_CHECKED : BST_UNCHECKED); } } return TRUE; case WM_COMMAND: SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); switch (LOWORD(wParam)) { case IDC_ALWAYS_VISIBLE: if (IsDlgButtonChecked(hwnd, IDC_ALWAYS_VISIBLE)) { MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA); EnableWindow(GetDlgItem(hwnd, IDC_VISIBLE_UNLESS_OFFLINE), 1); CheckDlgButton(hwnd, IDC_VISIBLE_UNLESS_OFFLINE, db_get_b(hContact, MODNAME, "VisibleUnlessOffline", 1) ? BST_CHECKED : BST_UNCHECKED); } else EnableWindow(GetDlgItem(hwnd, IDC_VISIBLE_UNLESS_OFFLINE), 0); break; case CHK_USE_TIMER: if (IsDlgButtonChecked(hwnd, CHK_USE_TIMER)) { MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA); char string[4]; EnableWindow(GetDlgItem(hwnd, IDC_TIMER), 1); SetDlgItemTextA(hwnd, IDC_TIMER, _itoa(db_get_w(hContact, MODNAME, "Timer", 15), string, 10)); } else EnableWindow(GetDlgItem(hwnd, IDC_TIMER), 0); break; case IDC_OPEN_FILE: char szFileName[512]; if (Openfile(szFileName, 1)) SetDlgItemTextA(hwnd, IDC_LINK, szFileName); break; case IDC_OPEN_FOLDER: if (BrowseForFolder(hwnd, szFileName)) { mir_snprintf(szFileName, "%s ,/e", szFileName); SetDlgItemTextA(hwnd, IDC_LINK, "explorer.exe"); SetDlgItemTextA(hwnd, IDC_PARAMS, szFileName); } } break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { case 0: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: int status = GetLCStatus(0, 0); MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA); if (GetWindowTextLength(GetDlgItem(hwnd, IDC_LINK))) { char text[512]; GetDlgItemTextA(hwnd, IDC_LINK, text, _countof(text)); db_set_s(hContact, MODNAME, "ProgramString", text); WriteSetting(hContact, MODNAME, "ProgramString", MODNAME, "Program"); } else db_unset(hContact, MODNAME, "ProgramString"); if (GetWindowTextLength(GetDlgItem(hwnd, IDC_PARAMS))) { char text[512]; GetDlgItemTextA(hwnd, IDC_PARAMS, text, _countof(text)); db_set_s(hContact, MODNAME, "ProgramParamsString", text); WriteSetting(hContact, MODNAME, "ProgramParamsString", MODNAME, "ProgramParams"); } else db_unset(hContact, MODNAME, "ProgramParamsString"); if (GetWindowTextLength(GetDlgItem(hwnd, IDC_GROUP))) { TCHAR text[512]; GetDlgItemText(hwnd, IDC_GROUP, text, _countof(text)); Clist_CreateGroup(NULL, text); db_set_ts(hContact, "CList", "Group", text); } else db_unset(hContact, "CList", "Group"); for (int i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++) if (IsDlgButtonChecked(hwnd, i)) db_set_w(hContact, MODNAME, "Icon", (WORD)i); /* set correct status */ if (status == ID_STATUS_ONLINE || status == ID_STATUS_AWAY || (status == db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE))) db_set_w(hContact, MODNAME, "Status", (WORD)db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE)); else db_set_w(hContact, MODNAME, "Status", ID_STATUS_OFFLINE); if (IsDlgButtonChecked(hwnd, CHK_USE_TIMER)) { if (GetWindowTextLength(GetDlgItem(hwnd, IDC_TIMER))) { TCHAR text[512]; GetDlgItemText(hwnd, IDC_TIMER, text, _countof(text)); db_set_w(hContact, MODNAME, "Timer", (WORD)_ttoi(text)); } else db_set_w(hContact, MODNAME, "Timer", 15); } else db_set_w(hContact, MODNAME, "Timer", 0); // always visible db_set_b(hContact, MODNAME, "AlwaysVisible", (BYTE)IsDlgButtonChecked(hwnd, IDC_ALWAYS_VISIBLE)); db_set_b(hContact, MODNAME, "VisibleUnlessOffline", (BYTE)IsDlgButtonChecked(hwnd, IDC_VISIBLE_UNLESS_OFFLINE)); } return TRUE; } break; } return FALSE; }
std::tstring Utils::BrowseForGameLocation(HWND parentWnd) { return BrowseForFolder(parentWnd, _T("Specify FFXIV folder")); }
void CRemotePlaybackDlg::OnDownloadByTime() { UpdateData(TRUE); if ( m_lSaveHandle > 0 ) { KillTimer(1); H264_DVR_StopGetFile(m_lSaveHandle); m_lSaveHandle = -1; m_progress.SetPos(0); GetDlgItem(IDC_DOWNLOAD)->SetWindowText(_CS("PlayBack.Download")); return; } CString strSaveName(""); //strSaveName.Format("c:\\record"); strSaveName = BrowseForFolder(GetSafeHwnd()) ; if ( strSaveName == _T("")) //未选择路径时退出 { return; } H264_DVR_FINDINFO info; memset(&info, 0, sizeof(info)); info.nChannelN0 = m_cmbChannel.GetCurSel(); //channel No. info.nFileType = m_cmbType.GetCurSel(); //file type info.startTime.dwYear = (WORD)m_begData.GetYear(); info.startTime.dwMonth = (WORD)m_begData.GetMonth(); info.startTime.dwDay = (WORD)m_begData.GetDay(); info.startTime.dwHour = (char)m_begTime.GetHour(); info.startTime.dwMinute = (char)m_begTime.GetMinute(); info.startTime.dwSecond = (char)m_begTime.GetSecond(); info.endTime.dwYear = (WORD)m_endData.GetYear(); info.endTime.dwMonth = (WORD)m_endData.GetMonth(); info.endTime.dwDay = (WORD)m_endData.GetDay(); info.endTime.dwHour = (char)m_endTime.GetHour(); info.endTime.dwMinute = (char)m_endTime.GetMinute(); info.endTime.dwSecond = (char)m_endTime.GetSecond(); int nRecordFileType = m_cmbType.GetCurSel(); info.nFileType = (nRecordFileType <= SDK_RECORD_MANUAL) ? nRecordFileType : (SDK_PIC_ALL + nRecordFileType - SDK_RECORD_MANUAL - 1); m_lSaveHandle = H264_DVR_GetFileByTime(m_lLoginID, &info, strSaveName.GetBuffer(0)); if(m_lSaveHandle > 0) { m_progress.SetPos(0); GetDlgItem(IDC_DOWNLOAD)->SetWindowText(_CS("PlayBack.Stop")); //update the progress control SetTimer(1,0,NULL); } else { CString sTemp; sTemp.Format("dowload fail ERROR = %d",H264_DVR_GetLastError()); AfxMessageBox(sTemp); } }
INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { struct FileDlgData *dat; dat = (struct FileDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { TCHAR szPath[450]; CLISTEVENT* cle = (CLISTEVENT*)lParam; dat = (struct FileDlgData*)mir_calloc(sizeof(struct FileDlgData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->hContact = cle->hContact; dat->hDbEvent = cle->hDbEvent; dat->hPreshutdownEvent = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, M_PRESHUTDOWN); dat->dwTicks = GetTickCount(); EnumChildWindows(hwndDlg, ClipSiblingsChildEnumProc, 0); Window_SetIcon_IcoLib(hwndDlg, SKINICON_EVENT_FILE); Button_SetIcon_IcoLib(hwndDlg, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list")); Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details")); Button_SetIcon_IcoLib(hwndDlg, IDC_HISTORY, SKINICON_OTHER_HISTORY, LPGEN("View user's history")); Button_SetIcon_IcoLib(hwndDlg, IDC_USERMENU, SKINICON_OTHER_DOWNARROW, LPGEN("User menu")); TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0); SetDlgItemText(hwndDlg, IDC_FROM, contactName); GetContactReceivedFilesDir(dat->hContact, szPath, SIZEOF(szPath), TRUE); SetDlgItemText(hwndDlg, IDC_FILEDIR, szPath); SHAutoComplete(GetWindow(GetDlgItem(hwndDlg, IDC_FILEDIR), GW_CHILD), 1); for (int i=0; i < MAX_MRU_DIRS; i++) { char idstr[32]; mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d", i); DBVARIANT dbv; if (db_get_ts(NULL, "SRFile", idstr, &dbv)) break; SendDlgItemMessage(hwndDlg, IDC_FILEDIR, CB_ADDSTRING, 0, (LPARAM)dbv.ptszVal); db_free(&dbv); } db_event_markRead(dat->hContact, dat->hDbEvent); DBEVENTINFO dbei = { sizeof(dbei) }; dbei.cbBlob = db_event_getBlobSize(dat->hDbEvent); if (dbei.cbBlob > 4 && dbei.cbBlob <= 8196) { dbei.pBlob = (PBYTE)alloca(dbei.cbBlob + 1); db_event_get(dat->hDbEvent, &dbei); dbei.pBlob[dbei.cbBlob] = 0; dat->fs = cle->lParam ? (HANDLE)cle->lParam : (HANDLE)*(PDWORD)dbei.pBlob; char *str = (char*)dbei.pBlob + 4; ptrT ptszFileName( DbGetEventStringT(&dbei, str)); SetDlgItemText(hwndDlg, IDC_FILENAMES, ptszFileName); unsigned len = (unsigned)strlen(str) + 1; if (len + 4 < dbei.cbBlob) { str += len; ptrT ptszDescription( DbGetEventStringT(&dbei, str)); SetDlgItemText(hwndDlg, IDC_MSG, ptszDescription); } } else DestroyWindow(hwndDlg); TCHAR datetimestr[64]; tmi.printTimeStamp(NULL, dbei.timestamp, _T("t d"), datetimestr, SIZEOF(datetimestr), 0); SetDlgItemText(hwndDlg, IDC_DATE, datetimestr); char* szProto = GetContactProto(dat->hContact); if (szProto) { int hasName = 0; char buf[128]; CONTACTINFO ci = { 0 }; ci.cbSize = sizeof(ci); ci.hContact = dat->hContact; ci.szProto = szProto; ci.dwFlag = CNF_UNIQUEID; if ( !CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) { switch(ci.type) { case CNFT_ASCIIZ: hasName = 1; mir_snprintf(buf, SIZEOF(buf), "%s", ci.pszVal); mir_free(ci.pszVal); break; case CNFT_DWORD: hasName = 1; mir_snprintf(buf, SIZEOF(buf), "%u", ci.dVal); break; } } if (hasName) SetDlgItemTextA(hwndDlg, IDC_NAME, buf); else SetDlgItemText(hwndDlg, IDC_NAME, contactName); } if (db_get_b(dat->hContact, "CList", "NotOnList", 0)) { RECT rcBtn1, rcBtn2, rcDateCtrl; GetWindowRect(GetDlgItem(hwndDlg, IDC_ADD), &rcBtn1); GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rcBtn2); GetWindowRect(GetDlgItem(hwndDlg, IDC_DATE), &rcDateCtrl); SetWindowPos(GetDlgItem(hwndDlg, IDC_DATE), 0, 0, 0, rcDateCtrl.right-rcDateCtrl.left-(rcBtn2.left-rcBtn1.left), rcDateCtrl.bottom-rcDateCtrl.top, SWP_NOZORDER|SWP_NOMOVE); } else if (db_get_b(NULL, "SRFile", "AutoAccept", 0)) { //don't check auto-min here to fix BUG#647620 PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDOK)); } if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); } return TRUE; case WM_MEASUREITEM: return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam); case WM_DRAWITEM: { LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam; if (dis->hwndItem == GetDlgItem(hwndDlg, IDC_PROTOCOL)) { char *szProto = GetContactProto(dat->hContact); if (szProto) { HICON hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0); if (hIcon) { DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL); DestroyIcon(hIcon); } } } } return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); case WM_COMMAND: if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact)) break; switch (LOWORD(wParam)) { case IDC_FILEDIRBROWSE: { TCHAR szDirName[MAX_PATH], szExistingDirName[MAX_PATH]; GetDlgItemText(hwndDlg, IDC_FILEDIR, szDirName, SIZEOF(szDirName)); GetLowestExistingDirName(szDirName, szExistingDirName, SIZEOF(szExistingDirName)); if (BrowseForFolder(hwndDlg, szExistingDirName)) SetDlgItemText(hwndDlg, IDC_FILEDIR, szExistingDirName); } break; case IDOK: { //most recently used directories TCHAR szRecvDir[MAX_PATH], szDefaultRecvDir[MAX_PATH]; GetDlgItemText(hwndDlg, IDC_FILEDIR, szRecvDir, SIZEOF(szRecvDir)); RemoveInvalidPathChars(szRecvDir); GetContactReceivedFilesDir(NULL, szDefaultRecvDir, SIZEOF(szDefaultRecvDir), TRUE); if (_tcsnicmp(szRecvDir, szDefaultRecvDir, lstrlen(szDefaultRecvDir))) { char idstr[32]; int i; DBVARIANT dbv; for (i = MAX_MRU_DIRS-2; i>=0; i--) { mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d", i); if (db_get_ts(NULL, "SRFile", idstr, &dbv)) continue; mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d", i+1); db_set_ts(NULL, "SRFile", idstr, dbv.ptszVal); db_free(&dbv); } db_set_ts(NULL, "SRFile", idstr, szRecvDir); } } EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAMES), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_MSG), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_FILEDIR), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_FILEDIRBROWSE), FALSE); GetDlgItemText(hwndDlg, IDC_FILEDIR, dat->szSavePath, SIZEOF(dat->szSavePath)); GetDlgItemText(hwndDlg, IDC_FILE, dat->szFilenames, SIZEOF(dat->szFilenames)); GetDlgItemText(hwndDlg, IDC_MSG, dat->szMsg, SIZEOF(dat->szMsg)); dat->hwndTransfer = FtMgr_AddTransfer(dat); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); //check for auto-minimize here to fix BUG#647620 if (db_get_b(NULL, "SRFile", "AutoAccept", 0) && db_get_b(NULL, "SRFile", "AutoMin", 0)) { ShowWindow(hwndDlg, SW_HIDE); ShowWindow(hwndDlg, SW_SHOWMINNOACTIVE); } DestroyWindow(hwndDlg); break; case IDCANCEL: if (dat->fs) CallContactService(dat->hContact, PSS_FILEDENYT, (WPARAM)dat->fs, (LPARAM)TranslateT("Canceled")); dat->fs = NULL; /* the protocol will free the handle */ DestroyWindow(hwndDlg); break; case IDC_ADD: { ADDCONTACTSTRUCT acs = {0}; acs.handle = dat->hContact; acs.handleType = HANDLE_CONTACT; acs.szProto = ""; CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); } break; case IDC_USERMENU: { RECT rc; HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); GetWindowRect((HWND)lParam, &rc); TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); } break; case IDC_DETAILS: CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->hContact, 0); break; case IDC_HISTORY: CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)dat->hContact, 0); break; } break; case WM_DESTROY: Window_FreeIcon_IcoLib(hwndDlg); Button_FreeIcon_IcoLib(hwndDlg, IDC_ADD); Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS); Button_FreeIcon_IcoLib(hwndDlg, IDC_HISTORY); Button_FreeIcon_IcoLib(hwndDlg, IDC_USERMENU); if (dat) FreeFileDlgData(dat); break; } return FALSE; }
static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { SHAutoComplete(GetDlgItem(hwndDlg, IDC_FILEDIR), SHACF_FILESYS_DIRS); TCHAR str[MAX_PATH]; GetContactReceivedFilesDir(NULL, str, _countof(str), FALSE); SetDlgItemText(hwndDlg, IDC_FILEDIR, str); CheckDlgButton(hwndDlg, IDC_AUTOACCEPT, db_get_b(NULL, "SRFile", "AutoAccept", 0) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_AUTOMIN, db_get_b(NULL, "SRFile", "AutoMin", 0) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_AUTOCLOSE, db_get_b(NULL, "SRFile", "AutoClose", 0) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_AUTOCLEAR, db_get_b(NULL, "SRFile", "AutoClear", 1) ? BST_CHECKED : BST_UNCHECKED); switch (db_get_b(NULL, "SRFile", "UseScanner", VIRUSSCAN_DISABLE)) { case VIRUSSCAN_AFTERDL: CheckDlgButton(hwndDlg, IDC_SCANAFTERDL, BST_CHECKED); break; case VIRUSSCAN_DURINGDL: CheckDlgButton(hwndDlg, IDC_SCANDURINGDL, BST_CHECKED); break; default: CheckDlgButton(hwndDlg, IDC_NOSCANNER, BST_CHECKED); break; } CheckDlgButton(hwndDlg, IDC_WARNBEFOREOPENING, db_get_b(NULL, "SRFile", "WarnBeforeOpening", 1) ? BST_CHECKED : BST_UNCHECKED); for (int i = 0; i < _countof(virusScanners); i++) { TCHAR szScanExe[MAX_PATH]; if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[i].szExeRegPath, virusScanners[i].szExeRegValue, szScanExe, _countof(szScanExe))) { int iItem = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_ADDSTRING, 0, (LPARAM)virusScanners[i].szProductName); SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETITEMDATA, iItem, i); } } if (SendDlgItemMessageA(hwndDlg, IDC_SCANCMDLINE, CB_GETCOUNT, 0, 0) == 0) { int iItem = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_ADDSTRING, 0, (LPARAM)_T("")); SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETITEMDATA, iItem, (LPARAM)-1); } DBVARIANT dbv; if (db_get_ts(NULL, "SRFile", "ScanCmdLine", &dbv) == 0) { SetDlgItemText(hwndDlg, IDC_SCANCMDLINE, dbv.ptszVal); db_free(&dbv); } else if (SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETCOUNT, 0, 0)) { SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETCURSEL, 0, 0); PostMessage(hwndDlg, M_SCANCMDLINESELCHANGE, 0, 0); } switch (db_get_b(NULL, "SRFile", "IfExists", FILERESUME_ASK)) { case FILERESUME_RESUMEALL: CheckDlgButton(hwndDlg, IDC_RESUME, BST_CHECKED); break; case FILERESUME_OVERWRITEALL: CheckDlgButton(hwndDlg, IDC_OVERWRITE, BST_CHECKED); break; case FILERESUME_RENAMEALL: CheckDlgButton(hwndDlg, IDC_RENAME, BST_CHECKED); break; default: CheckDlgButton(hwndDlg, IDC_ASK, BST_CHECKED); break; } SendMessage(hwndDlg, M_UPDATEENABLING, 0, 0); } return TRUE; case M_UPDATEENABLING: { int on = BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_NOSCANNER); EnableWindow(GetDlgItem(hwndDlg, IDC_ST_CMDLINE), on); EnableWindow(GetDlgItem(hwndDlg, IDC_SCANCMDLINE), on); EnableWindow(GetDlgItem(hwndDlg, IDC_SCANCMDLINEBROWSE), on); EnableWindow(GetDlgItem(hwndDlg, IDC_ST_CMDLINEHELP), on); EnableWindow(GetDlgItem(hwndDlg, IDC_AUTOMIN), IsDlgButtonChecked(hwndDlg, IDC_AUTOACCEPT)); } break; case M_SCANCMDLINESELCHANGE: { TCHAR str[512]; TCHAR szScanExe[MAX_PATH]; int iScanner = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETCURSEL, 0, 0), 0); if (iScanner >= _countof(virusScanners) || iScanner < 0) break; str[0] = '\0'; if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[iScanner].szExeRegPath, virusScanners[iScanner].szExeRegValue, szScanExe, _countof(szScanExe))) mir_sntprintf(str, virusScanners[iScanner].szCommandLine, szScanExe); SetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str); } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_FILEDIR: if ((HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0; break; case IDC_FILEDIRBROWSE: { TCHAR str[MAX_PATH]; GetDlgItemText(hwndDlg, IDC_FILEDIR, str, _countof(str)); if (BrowseForFolder(hwndDlg, str)) SetDlgItemText(hwndDlg, IDC_FILEDIR, str); } break; case IDC_AUTOACCEPT: case IDC_NOSCANNER: case IDC_SCANAFTERDL: case IDC_SCANDURINGDL: SendMessage(hwndDlg, M_UPDATEENABLING, 0, 0); break; case IDC_SCANCMDLINE: if (HIWORD(wParam) == CBN_SELCHANGE) PostMessage(hwndDlg, M_SCANCMDLINESELCHANGE, 0, 0); else if (HIWORD(wParam) != CBN_EDITCHANGE) return 0; break; case IDC_SCANCMDLINEBROWSE: TCHAR str[MAX_PATH + 2]; GetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str, _countof(str)); CMString tszFilter; tszFilter.AppendFormat(_T("%s (*.exe)%c*.exe%c"), TranslateT("Executable files"), 0, 0); tszFilter.AppendFormat(_T("%s (*)%c*%c"), TranslateT("All files"), 0, 0); OPENFILENAME ofn = { 0 }; ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = hwndDlg; ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_DONTADDTORECENT; ofn.lpstrFilter = tszFilter; ofn.lpstrFile = str; ofn.nMaxFile = _countof(str) - 2; if (str[0] == '"') { TCHAR *pszQuote = _tcschr(str + 1, '"'); if (pszQuote) *pszQuote = 0; memmove(str, str + 1, (mir_tstrlen(str) * sizeof(TCHAR))); } else { TCHAR *pszSpace = _tcschr(str, ' '); if (pszSpace) *pszSpace = 0; } ofn.nMaxFileTitle = MAX_PATH; if (!GetOpenFileName(&ofn)) break; if (_tcschr(str, ' ') != NULL) { memmove(str + 1, str, ((_countof(str) - 2) * sizeof(TCHAR))); str[0] = '"'; mir_tstrcat(str, _T("\"")); } SetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str); break; } SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: TCHAR str[512]; GetDlgItemText(hwndDlg, IDC_FILEDIR, str, _countof(str)); RemoveInvalidPathChars(str); db_set_ts(NULL, "SRFile", "RecvFilesDirAdv", str); db_set_b(NULL, "SRFile", "AutoAccept", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOACCEPT)); db_set_b(NULL, "SRFile", "AutoMin", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOMIN)); db_set_b(NULL, "SRFile", "AutoClose", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOCLOSE)); db_set_b(NULL, "SRFile", "AutoClear", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOCLEAR)); db_set_b(NULL, "SRFile", "UseScanner", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_SCANAFTERDL) ? VIRUSSCAN_AFTERDL : (IsDlgButtonChecked(hwndDlg, IDC_SCANDURINGDL) ? VIRUSSCAN_DURINGDL : VIRUSSCAN_DISABLE))); GetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str, _countof(str)); db_set_ts(NULL, "SRFile", "ScanCmdLine", str); db_set_b(NULL, "SRFile", "WarnBeforeOpening", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_WARNBEFOREOPENING)); db_set_b(NULL, "SRFile", "IfExists", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_ASK) ? FILERESUME_ASK : (IsDlgButtonChecked(hwndDlg, IDC_RESUME) ? FILERESUME_RESUMEALL : (IsDlgButtonChecked(hwndDlg, IDC_OVERWRITE) ? FILERESUME_OVERWRITEALL : FILERESUME_RENAMEALL)))); return TRUE; } break; } return FALSE; }
void CMediaStorageDlg::OnBnClickedButtonUser2userbrowse() { TCHAR szSaveDir[MAX_PATH]; if(BrowseForFolder(m_hWnd, m_szUserTxtDir, szSaveDir)) m_wndUserTxtDir.SetWindowText(szSaveDir); }
void CMediaStorageDlg::OnBnClickedButtonChanlogbrowse() { TCHAR szSaveDir[MAX_PATH]; if(BrowseForFolder(m_hWnd, m_szChanLogDir, szSaveDir)) m_wndChanLogDir.SetWindowText(szSaveDir); }