void CHallQueFrontView::OnLeadinwav() { // TODO: 在此添加命令处理程序代码 CStringArray strWavArray; CString strWavLibPath = CommonStrMethod::GetModuleDir() + _T("wavLib\\"); CFileDialog filedlg(TRUE,0,0,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT,m_strPicFilter); if(IDOK == filedlg.DoModal()) { POSITION pos; pos = filedlg.GetStartPosition(); while (pos) { strWavArray.Add(filedlg.GetNextPathName(pos)); } BOOL bResult = TRUE; for (int i=0;i<strWavArray.GetCount();i++) { CString strName = CommonStrMethod::GetNameFromAbsName(strWavArray[i]); bResult = ::CopyFile(strWavArray[i],strWavLibPath+strName,TRUE); if (!bResult) { AfxMessageBox(strName+L"已存在,请重命名。"); break; } } if (bResult) { AfxMessageBox(L"语音文件导入完毕!"); } } }
//////////////////////////////////////////////////////////////////// // Method: OnAudioFileSelect // Class: CGUIFrame // Purpose: handle the panel button press // Input: pointer to event // Output: nothing //////////////////////////////////////////////////////////////////// void CConfigView::OnAudioFileSelect( wxCommandEvent& pEvent ) { char strLoadPath[255]; char strLoadMsg[255]; char strLoadPattern[255]; wxString strFileName; strcpy( strLoadPath, "./" ); strcpy( strLoadMsg, FILE_LOAD_AUDIO_TITLE ); strcpy( strLoadPattern, FILE_LOAD_AUDIO_TYPE ); // create a file choser wxFileDialog filedlg( this, strLoadMsg, _(""), _(""), strLoadPattern, wxOPEN | wxFILE_MUST_EXIST ); // set path to curret or + data dir (TODO) filedlg.SetPath( strLoadPath ); // if ok if( filedlg.ShowModal() == wxID_OK ) { // debug strFileName = filedlg.GetPath( ); // sprintf( strTmp, "INFO :: going to load file %s\n", strFileName.GetData() ); // m_pLogger->Log( strTmp ); // check the envent's id // now do something here m_pNotifyAudioFile->SetValue( strFileName.GetData() ); } }
void LifeFrame::OnOpen(wxCommandEvent& WXUNUSED(event)) { wxFileDialog filedlg(this, _("Choose a file to open"), wxEmptyString, wxEmptyString, _("Life patterns (*.lif)|*.lif|All files (*.*)|*.*"), wxFD_OPEN | wxFD_FILE_MUST_EXIST); if (filedlg.ShowModal() == wxID_OK) { wxFileInputStream stream(filedlg.GetPath()); LifeReader reader(stream); // the reader handles errors itself, no need to do anything here if (reader.IsOk()) { // stop if running and put the pattern OnStop(); m_life->Clear(); m_life->SetPattern(reader.GetPattern()); // recenter canvas m_canvas->Recenter(0, 0); m_tics = 0; UpdateInfoText(); } } }
void CBaiDlg::OnBtOpen() { CFileDialog filedlg(TRUE,"ccr","",NULL,"ÆåÆ×|*.ccr||",this); int respond=filedlg.DoModal(); if(respond==IDOK) { CFace face; if(face.Open(filedlg.GetFileName())) { if(face.IsNormal())New(face); else { CString str; str.Format("\"%s\"\n²»ÊÇÕýÈ·µÄÆåÆ×",filedlg.GetFileName()); MessageBox(str,"´íÎó",MB_OK|MB_ICONERROR); } } else { CString str; str.Format("²»ÄÜ´ò¿ª\"%s\"",filedlg.GetFileName()); MessageBox(str,"´íÎó",MB_OK|MB_ICONERROR); } } }
void MyPipeFrame::OnBtnSendFile(wxCommandEvent& WXUNUSED(event)) { #if wxUSE_FILEDLG wxFileDialog filedlg(this, wxT("Select file to send")); if ( filedlg.ShowModal() != wxID_OK ) return; wxFFile file(filedlg.GetFilename(), wxT("r")); wxString data; if ( !file.IsOpened() || !file.ReadAll(&data) ) return; // can't write the entire string at once, this risk overflowing the pipe // and we would dead lock size_t len = data.length(); const wxChar *pc = data.c_str(); while ( len ) { const size_t CHUNK_SIZE = 4096; m_out.Write(pc, len > CHUNK_SIZE ? CHUNK_SIZE : len); // note that not all data could have been written as we don't block on // the write end of the pipe const size_t lenChunk = m_out.LastWrite(); pc += lenChunk; len -= lenChunk; DoGet(); } #endif // wxUSE_FILEDLG }
void MiscControlPage::OnBrowsePrinterLogFile(wxCommandEvent& event) { wxString path = wxT("All files|*.*||"); wxFileDialog filedlg(this, wxT("Choose file to save printer log to"), wxT(""), wxT(""), path, wxFD_SAVE | wxFD_OVERWRITE_PROMPT); if (filedlg.ShowModal() == wxID_OK) { m_printerLogFile->SetValue(filedlg.GetPath()); } }
void CMainFrame::OnFileOpen() { CFileDialog filedlg(TRUE, "gsn", "test.gsn", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, NULL, this); if(filedlg.DoModal() == IDOK) { cb_load_module(filedlg.GetPathName()); } }
void CBaiDlg::OnBtSave() { UpdateData(TRUE); CFace face; if(GetFace(face)) { face.side=m_nGoSide; CFileDialog filedlg(FALSE,"ccr","δÃüÃû",OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"ÆåÆ×|*.ccr||",this); int respond=filedlg.DoModal(); if(respond==IDOK)face.Save(filedlg.GetFileName()); } }
LRESULT CScriptEditor::OnFileSaveAs(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { static _TCHAR Filter[] = _T("JScript Files (*.js)\0*.js\0"); CPath fn((LPCTSTR)scriptError->GetFile()); CFileDialog filedlg(FALSE,_T("*.js"),(LPCTSTR)fn,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST,Filter); if(filedlg.DoModal(GetDesktopWindow())!=IDOK) return 0; CString text; m_edit.GetWindowText(text); SaveString(filedlg.m_szFileName,text); return 0; }
/* Export data in Pcbnew format * remember Pcbnew uses a Y reversed axis, so we must negate all Y coordinates */ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event ) { int layercount = 0; // Count the Gerber layers which are actually currently used for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii ) { if( g_GERBER_List[ii] != NULL ) layercount++; } if( layercount == 0 ) { DisplayInfoMessage( this, _( "None of the Gerber layers contain any data" ) ); return; } wxString fileName; wxString path = wxGetCwd();; wxFileDialog filedlg( this, _( "Board file name:" ), path, fileName, LegacyPcbFileWildcard, wxFD_SAVE ); if( filedlg.ShowModal() == wxID_CANCEL ) return; fileName = filedlg.GetPath(); /* Install a dialog frame to choose the mapping * between gerber layers and Pcbnew layers */ LAYERS_MAP_DIALOG* layerdlg = new LAYERS_MAP_DIALOG( this ); int ok = layerdlg->ShowModal(); layerdlg->Destroy(); if( ok != wxID_OK ) return; if( wxFileExists( fileName ) ) { if( !IsOK( this, _( "OK to change the existing file ?" ) ) ) return; } GBR_TO_PCB_EXPORTER gbr_exporter( this, fileName ); gbr_exporter.ExportPcb( layerdlg->GetLayersLookUpTable(), layerdlg->GetCopperLayersCount() ); }
void CGetListingDlg2::OnAddParser() { // TODO: Add your control notification handler code here CParserSetup * parsersetup; CListingData * pListingData = NULL; CString temp; CFileDialog filedlg(TRUE,"lpf",NULL, OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,"Listing Parser Files (*.lpf)|*.lpf|All Files (*.*)|*.*||"); int result2; int result = filedlg.DoModal(); //I should display a file open dialog if (result == IDOK) { pListingData = new CListingData; pListingData->m_path = filedlg.GetPathName(); parsersetup = new CParserSetup(pListingData->m_path); for (int i = 0 ; i < m_channelcombo.GetCount(); i++) { m_channelcombo.GetLBText(i,temp); parsersetup->SetChannelName(temp); result2 = parsersetup->DoModal(); if (result2 == IDOK) { pListingData->m_listingID.Add(parsersetup->GetSelChannelNum()); }else{ return; } } pListingData->m_parsername = parsersetup->GetParserName(); m_listingdata.Add(pListingData); delete parsersetup; FillListingCombo(); } }
CString CGeneralSettingsDlg::BrowseAndGetSingleFile(CString strInitialPath,CString strFilter) { CString strFileName(TEXT("")); CFileDialog filedlg(TRUE,NULL,NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,strFilter); TCHAR pBuffer[MAX_PATH]; memset(pBuffer,0,sizeof(TCHAR)*(MAX_PATH)); swprintf(pBuffer,nof(pBuffer),(LPCTSTR)strInitialPath); filedlg.m_ofn.lpstrFile = pBuffer; filedlg.m_ofn.nMaxFile = MAX_PATH; if( IDOK == filedlg.DoModal() ) { POSITION pos = filedlg.GetStartPosition(); while (pos != NULL) { strFileName = filedlg.GetNextPathName(pos); } } return strFileName; }
void Nin10Edit::OnOpen(wxCommandEvent& event) { EventLog l(__func__); std::unique_ptr<wxFileDialog> filedlg(new wxFileDialog(this, _("Open Image"), "", "", wxFileSelectorDefaultWildcardStr, wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR | wxFD_PREVIEW | wxFD_OPEN)); if (filedlg->ShowModal() == wxID_CANCEL) { WarnLog("No image given"); return; } std::string file = filedlg->GetPath().ToStdString(); InfoLog("Got file: %s", file.c_str()); images.emplace(file, file); ConvertToMode4(images, images8); auto* graphics_panel = new GraphicsEditorPanel(graphics_notebook); graphics_notebook->AddPage(graphics_panel, file, false); graphics_panel->SetImage(&images8[0]); palette_panel->SetPalette(images8[0].palette); }
void COTPPancel::OnSearchPublicKey() { // TODO: Add your control notification handler code here TCHAR szFilter[] = _T("PublicKey Files(*.key)|*.key||"); CFileDialog filedlg(TRUE, _T("PublicKey Files"), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter,this); char WorkPath[MAX_PATH+1] = {0}; //保存当前的工作路径 GetCurrentDirectory(MAX_PATH,WorkPath); if(filedlg.DoModal() == IDOK) { CFile file; CFileException fError; m_PublicKeyFileName = filedlg.GetPathName(); file.Open(m_PublicKeyFileName.GetBuffer(0),CFile::modeRead,&fError); if(fError.m_cause != CFileException::none) //file error { HLOCAL hlocal = NULL; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ALLOCATE_BUFFER,NULL,fError.m_lOsError,0,(LPTSTR)&hlocal,0,NULL); CString errorout = (LPTSTR)LocalLock(hlocal); AfxMessageBox(errorout,MB_OK|MB_ICONERROR); m_PublicKeyFileName = ""; } else { file.Read(gPublicKey.bytePublicKey,GOZONE_PUBLICKEY_LEN); file.Close(); } UpdateData(FALSE); } //还原当前的工作路径 SetCurrentDirectory(WorkPath); }
void CUIControler::openHistoryFile() { TCHAR szFilters[]= _T("XML (*.xml)"); CFileDialog filedlg(TRUE,_T("xml"),_T("*.xml"),0,szFilters); if (filedlg.DoModal()==IDOK) { if (filedlg.GetPathName().IsEmpty()) { return; } } else { return; } std::string filePath=CCommonUtilities::toBasicString(filedlg.GetPathName()); testsFilesMapT::iterator myIt=testsFilesMap.find(filePath); if(myIt!=testsFilesMap.end()) { AfxMessageBox(_T("Already opened")); return; } CTestsFile* pTests=openFile(filePath); if (pTests) { pHistoryTree->renderFile(pTests,pHistoryTree->hRoot); addFileToHomeCombo(filedlg.GetPathName()); } // }
void CGetListingDlg::OnAddParser() { // TODO: Add your control notification handler code here CParserSetup * parsersetup; CListingData * pListingData; CFileDialog filedlg(TRUE,"lpf",NULL, OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY,"Listing Parser Files (*.lpf)|*.lpf|All Files (*.*)|*.*||"); filedlg.DoModal(); //I should display a file open dialog pListingData = new CListingData; pListingData->m_path = filedlg.GetPathName(); parsersetup = new CParserSetup(pListingData->m_path); for (int i = 0 ; i < channelarray.GetSize(); i++) { parsersetup->SetChannelName(channelarray.GetAt(i)); int result = parsersetup->DoModal(); if (result == IDOK) { //pListingData->m_listingID.Add(parsersetup->GetSelChannelNum()); } } pListingData->m_parsername = parsersetup->GetParserName(); m_listingdata.Add(pListingData); FillListingCombo(); SaveSettings(); }
LRESULT CChatBkDlg::OnPreSendMsg(WPARAM wParam, LPARAM lParam) { switch (wParam) { case 0: if (m_pMsgEdit->GetRichEditCtrl().GetSafeHwnd() && m_pMsgEdit->GetRichEditCtrl().GetTextLength()) { clock_t clr0 = clock(); //将字符串插入到整个内容的最前面 m_pMsgEdit->GetRichEditCtrl().HideSelection(TRUE, FALSE); m_pMsgEdit->GetRichEditCtrl().SetSel(0, -1); m_pMsgEdit->GetRichEditCtrl().SetSelectionCharFormat(m_defaultCharFormat); CMemFile memFile(m_pBuf, BUFLEN); memFile.SeekToBegin(); ///////////////////////将整个 RichView中的内容写到内存文件中 EDITSTREAM es; es.dwCookie = (DWORD_PTR)&memFile; es.pfnCallback = RichEditStreamOutCallback; m_pMsgEdit->GetRichEditCtrl().SetSel(0, -1); m_pMsgEdit->GetRichEditCtrl().StreamOut(SF_RTF | SFF_SELECTION, es); m_pMsgEdit->GetRichEditCtrl().Clear(); m_pMsgEdit->GetRichEditCtrl().HideSelection(FALSE, FALSE); TRACE(_T("写入内存 用时:%d ms 时间:%d\n"), clock() - clr0, clock()); clr0 = clock(); //IRichEditOle* pRichEditOleMsg = pChatFrame->m_pMsgView->GetRichEditCtrl().GetIRichEditOle(); //int count = pRichEditOleMsg->GetObjectCount(); //for(int i = 0 ; i < count ; i++) //遍历位图 //{ // REOBJECT object; //位图信息存在这里 // memset(&object,0,sizeof(REOBJECT)); // object.cbStruct = sizeof(REOBJECT); // pRichEditOleMsg->GetObject(i, &object, REO_GETOBJ_ALL_INTERFACES); // int pos = object.cp ; //位图的位置信息 // DWORD dwUSer =object.dwUser; //位图的信息,之前应用程序设置的,应有程序当然知道什么意思了 //} //IRichEditOle* pRichEditOleRecord = pChatFrame->m_pRecordView->GetRichEditCtrl().GetIRichEditOle(); if (m_pCurrentUser->state == USERINFO::USER_STATE_ONLINE) { CNetData *pChatNetData = new CNetData(); pChatNetData->MakeNETBuffer(CNetData::TCP_CHATMSG, RIMConfig::GetInstance()->m_pLogonUser, m_pCurrentUser, m_curUserIP, m_pBuf, UINT(memFile.Seek(0, CFile::current))); if (pChatNetData->GetBufferLen()) RIMConfig::GetInstance()->m_TCPSendQueue.Push(pChatNetData); else delete pChatNetData; //int memFileLen = UINT(memFile.Seek(0, CFile::current)); //LPBYTE pBufferTemp = new BYTE[memFileLen + 5]; //////////////////////////////对数据进行压缩 //if (HZIP hz = CreateZip(pBufferTemp, memFileLen + 5, "")) //{ // tstring newGuidStr = GetNewGuid() + _T(".txt"); // if (ZR_OK == ZipAdd(hz, newGuidStr.c_str(), m_pBuf, UINT(memFile.Seek(0, CFile::current)))) // { // LPBYTE pZipBuffer = NULL; // DWORD destlen = 0; // ZipGetMemory(hz, (void**)&pZipBuffer, &destlen); // if (pZipBuffer && destlen) // { // CNetData *pChatNetData = new CNetData(); // pChatNetData->MakeNETBuffer(CNetData::TCP_CHATMSG, RIMConfig::GetInstance()->m_pLogonUser, m_pCurrentUser, pZipBuffer, destlen); // RIMConfig::GetInstance()->m_TCPSendQueue.Push(pChatNetData); // } // } // if (hz != NULL) { CloseZip(hz); hz = NULL; } //} //if (pBufferTemp) // delete[] pBufferTemp; } TRACE(_T("写入数据队列 用时:%d ms 时间:%d\n"), clock() - clr0, clock()); clr0 = clock(); {//////////////// 将内存文件中的内容写到通话记录视图中 ///////////////构造字符串,包括发送的用户,及发送时间 SYSTEMTIME systemtime; GetLocalTime(&systemtime); TCHAR ch[MAX_PATH] ={ 0 }; _stprintf_s(ch, MAX_PATH, _T("%s (%d/%02d/%02d %02d:%02d:%02d):\n"), RIMConfig::GetInstance()->m_pLogonUser->UserName.c_str(), systemtime.wYear, systemtime.wMonth, systemtime.wDay, systemtime.wHour, systemtime.wMinute, systemtime.wSecond); memFile.SeekToBegin(); m_pRecordView->GetRichEditCtrl().SetReadOnly(FALSE); m_pRecordView->GetRichEditCtrl().SetSel(-2, -1); m_pRecordView->GetRichEditCtrl().SetWordCharFormat(m_sendUserCharFormat); m_pRecordView->GetRichEditCtrl().ReplaceSel(ch, FALSE); //输入用户发送时间 EDITSTREAM es; es.dwCookie = (DWORD_PTR)&memFile; es.pfnCallback = RichEditStreamInCallback; m_pRecordView->GetRichEditCtrl().SetSel(-2, -1); m_pRecordView->GetRichEditCtrl().StreamIn(SF_RTF | SFF_SELECTION, es); //为了解决添加SFF_SELECTION后,自动滚动不显示的问题 if(!(GetAsyncKeyState(VK_LBUTTON) && 0x8000)) ////鼠标没有按下 m_pRecordView->GetRichEditCtrl().PostMessage(WM_VSCROLL, MAKELONG(SB_BOTTOM, 0), 0);; m_pRecordView->GetRichEditCtrl().SetReadOnly(TRUE); } TRACE(_T("写入上面View 用时:%d ms 时间:%d\n"), clock() - clr0, clock()); clr0 = clock(); } break; case 1: { CFileDialog filedlg(TRUE, NULL, NULL, OFN_PATHMUSTEXIST | OFN_READONLY, _T("All Files (*.*)|*.*||"), this); if (IDOK == filedlg.DoModal()) { CString filePath = filedlg.GetPathName(); SendFileOrDic(filePath); } InvalidateRect(m_sendFileRc, FALSE); } break; case 2: { TCHAR szPath[MAX_PATH] ={ 0 }; //存放选择的目录路径 BROWSEINFO bi; bi.hwndOwner = m_hWnd; bi.pidlRoot = NULL; bi.pszDisplayName = szPath; bi.lpszTitle = _T("请选择需要导出的目录:"); bi.ulFlags = BIF_RETURNONLYFSDIRS; bi.lpfn = BrowseCallbackProc; //设置CALLBACK函数 bi.iImage = 0; bi.lParam = long(m_oldDic.GetBuffer()); //弹出选择目录对话框 LPITEMIDLIST lp = SHBrowseForFolder(&bi); if (lp && SHGetPathFromIDList(lp, szPath)) { m_oldDic = szPath; SendFileOrDic(szPath); } InvalidateRect(m_sendDicRc, FALSE); } break; case 3: { CString sFilter = _T("All image file|*.bmp;*.jpg;|Bitmap Files (*.bmp)|*.bmp|JPEG Files (*.jpg)|*.jpg|"); //CString sFilter = _T("All image file|*.bmp;*.jpg;*.gif|Bitmap Files (*.bmp)|*.bmp|JPEG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif|"); CFileDialog filedlg(TRUE, NULL, NULL, OFN_PATHMUSTEXIST | OFN_READONLY, sFilter, this); if (IDOK == filedlg.DoModal()) { CTapBitmap bmp; if (bmp.Load(filedlg.GetPathName()) == FALSE) { AfxMessageBox(_T("Could not load image.")); return TRUE; } CEnBitmap enBitmap; CBitmap Bitmap; if (enBitmap.Attach(bmp.GetBMP(), 0)) { Bitmap.DeleteObject(); Bitmap.Attach(enBitmap.Detach()); IRichEditOle *pRichEditOle; pRichEditOle = m_pMsgEdit->GetRichEditCtrl().GetIRichEditOle(); HBITMAP hBitmap = (HBITMAP)Bitmap; if (hBitmap) { ImageDataObject::InsertBitmap(pRichEditOle, hBitmap); } pRichEditOle->Release(); } } InvalidateRect(m_sendPictureRc, FALSE); } break; } return TRUE; }