void CLoadSavePropPage::OnBnClickedButtonSave() { const int MAX_BUFFER_SIZE = 1024; CFileDialog FileDialog(FALSE); CString strBuffer; FileDialog.GetOFN().lpstrFile = strBuffer.GetBuffer(MAX_BUFFER_SIZE); FileDialog.GetOFN().nMaxFile = MAX_BUFFER_SIZE; FileDialog.GetOFN().lpstrDefExt = TEXT(".txt"); FileDialog.GetOFN().lpstrFilter = TEXT("Text Files(*.txt)\0*.txt\0All Files(*.*)\0*.*\0\0"); INT_PTR nRet = FileDialog.DoModal(); strBuffer.ReleaseBuffer(); if (nRet == IDOK) { CString strFileName = FileDialog.GetPathName(); CString strText; m_TextEdit.GetWindowText(strText); CStrList StrList; StrList.SetText(strText); StrList.SaveToFile(strFileName, false); } }
void PCB_Grid::OnSave() { CString settingsFile = getApp().getUserPath() + "default.grd"; CFileDialog FileDialog(FALSE, "GRD", settingsFile, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Manuf Grid File (*.GRD)|*.GRD|All Files (*.*)|*.*||", NULL); if (FileDialog.DoModal() != IDOK) return; CStdioFile file; if (!file.Open(FileDialog.GetPathName(), file.modeCreate | file.modeWrite | file.typeText)) { ErrorMessage(FileDialog.GetPathName(), "Unable to Open File!", MB_ICONEXCLAMATION | MB_OK); return; } UpdateData(); file.WriteString("! CAMCAD Manufacturing Grid Settings\n\n"); int decimals = GetDecimals(doc->getSettings().getPageUnits()); CString buf; buf.Format(".Units %s\n", GetUnitName(doc->getSettings().getPageUnits())); file.WriteString(buf); buf.Format(".Horizontal %d %d %.*lf\n", m_horz, m_hSteps, decimals, getHSizePageUnits()); file.WriteString(buf); buf.Format(".Vertical %d %d %.*lf\n", m_vert, m_vSteps, decimals, getVSizePageUnits()); file.WriteString(buf); buf.Format(".Thickness %.*lf\n", decimals,m_gridThickness); file.WriteString(buf); file.Close(); }
bool CDocCommands::OpenImage() { CWaitCursor Wait; LPCTSTR pstrFilter = (CImage::IsGdiPlusInstalled() ? FILTER_WITH_GDIPLUS : FILTER_WITHOUT_GDIPLUS); CFileDialog FileDialog(true, _T("jpg"), NULL/*pszFileName*/, OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT, pstrFilter, m_DocWindow/*hWndParent*/); FileDialog.m_ofn.lpstrTitle = _T("Open an Image File"); if (FileDialog.DoModal(m_DocWindow) == IDCANCEL) return false; CString strFileName = FileDialog.m_ofn.lpstrFile; // Save the path in the registry //j if (regkey.m_hKey) //j bool bOK = (regkey.SetStringValue(REGVAL_MRU_PICTURE_PATH, StrPath(szFileName)) == ERROR_SUCCESS); // Redraw the window underneath, before we get to work ::UpdateWindow(m_DocWindow); if (SINGLE_IMAGE_EDITOR) { // Close the existing image if you want to a single image editor if (m_DocWindow.GetSelectedObject()) CloseImage(); } CImageObject* pObject = m_DocWindow.OpenImage(strFileName, NULL/*pDib*/, NULL/*pMatrix*/); if (!pObject) return false; return true; }
void CBordersTab::OnBorderImageChoose() { #define FILTER_WITH_GDIPLUS _T("All Supported Files (*.bmp, *.gif, *.jpg, *.tif, *.png, *.wmf, *.ico, *.emf)|*.bmp;*.gif;*.jpg;*.tif*;*.png;*.wmf;*.ico;*.emf|Bitmap Files (*.bmp)|*.bmp|GIF Files (*.gif)|*.gif|JPG Files (*.jpg)|*.jpg|TIF Files (*.tif)|*.tif*|PNG Files (*.png)|*.png|Windows Metafiles Files (*.wmf)|*.wmf|Windows Enhanced Metafiles Files (*.emf)|*.emf|Icon Files (*.ico)|*.ico|All Files (*.*)|*.*||") #define FILTER_WITHOUT_GDIPLUS _T("All Supported Files (*.bmp, *.gif, *.jpg, *.png, *.wmf, *.ico, *.emf)|*.bmp;*.gif;*.jpg;*.png;*.wmf;*.ico;*.emf|Bitmap Files (*.bmp)|*.bmp|GIF Files (*.gif)|*.gif|JPG Files (*.jpg)|*.jpg|PNG Files (*.png)|*.png|Windows Metafiles Files (*.wmf)|*.wmf|Windows Enhanced Metafiles Files (*.emf)|*.emf|Icon Files (*.ico)|*.ico|All Files (*.*)|*.*||") LPCTSTR pstrFilter = (CImage::IsGdiPlusInstalled() ? FILTER_WITH_GDIPLUS : FILTER_WITHOUT_GDIPLUS); CFileDialog FileDialog(true, _T("jpg"), NULL/*pszFileName*/, OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT, pstrFilter, this/*hWndParent*/); FileDialog.m_ofn.lpstrTitle = _T("Open an Image File"); if (FileDialog.DoModal() == IDCANCEL) return; CString strFileName = FileDialog.m_ofn.lpstrFile; //j FileDialog.GetPathName(); // Save the path in the registry //j if (regkey.m_hKey) //j bool bOK = (regkey.SetStringValue(REGVAL_MRU_PICTURE_PATH, StrPath(szFileName)) == ERROR_SUCCESS); CString strName = FileDialog.m_ofn.lpstrFileTitle; int iDot = strName.ReverseFind('.'); if (iDot >= 0) strName = strName.Left(iDot); m_editBorderImageFileName.SetWindowText(strName); bool bOK = DoCommand(_T("OpenBorderImage"), strFileName); if (bOK) OnBorderImage(); }
void COpenDBDlg::OnButtonPath() { CString strFilter = _T("SuperMap sdbplus File(*.sdb)|*.sdb||"); if(m_nEngineType == 5 ) { strFilter = _T("SuperMap Image File(*.sit;*.bmp;*.jpg;*.png)|*.sit;*.bmp;*.jpg;*.png||"); } else if( m_nEngineType == OGDC::oeFile) { strFilter = _T("SuperMap UDB File(*.udb)|*.udb||"); } else { strFilter = _T( m_Provider.m_strName+"("+ m_Provider.GetPostfix()+")"+"|"+ m_Provider.GetPostfix()+"||" ); } CFileDialog FileDialog(m_bOpen, _T(""), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, strFilter); FileDialog.m_ofn.lpstrInitialDir = "..\\..\\..\\SampleData"; if(IDOK == FileDialog.DoModal()) { m_strDatabase = _T(""); m_strPassWord = _T(""); m_strUser = _T(""); m_strServer = FileDialog.GetPathName(); m_strAlias = FileDialog.GetFileTitle(); UpdateData(false); } }
//打开房间 void CServiceLoaderDlg::OnBnClickedOpen() { //获取目录 TCHAR szPath[MAX_PATH]=TEXT(""); GetCurrentDirectory(sizeof(szPath),szPath); //选择文件 LPCTSTR pszFilter=TEXT("房间配置文件 (*.ROP)|*.ROP||"); CFileDialog FileDialog(TRUE,NULL,NULL,OFN_NOCHANGEDIR|OFN_HIDEREADONLY,pszFilter); FileDialog.m_pOFN->lpstrInitialDir=szPath; if (FileDialog.DoModal()!=IDOK) return; //打开房间 TCHAR szDescribe[128]=TEXT(""); bool bSuccess=m_ServiceParameter.LoadParameter(FileDialog.GetPathName()); if (bSuccess==true) { _snprintf(szDescribe,sizeof(szDescribe),TEXT("“%s”游戏房间加载成功"),FileDialog.GetFileName()); ShowErrorMessasge(szDescribe,TraceLevel_Normal); } else { _snprintf(szDescribe,sizeof(szDescribe),TEXT("“%s”游戏房间加载失败"),FileDialog.GetFileName()); ShowErrorMessasge(szDescribe,TraceLevel_Exception); } //控制界面 GetDlgItem(IDC_START)->EnableWindow(bSuccess?TRUE:FALSE); GetDlgItem(IDC_OPTION)->EnableWindow(bSuccess?TRUE:FALSE); GetDlgItem(IDC_SAVE_OPTION)->EnableWindow(bSuccess?TRUE:FALSE); return; }
void CCEtoODBApp::OnRunMacro() { CString filename; if (activeView) { CCEtoODBDoc *doc = (CCEtoODBDoc*)activeView->GetDocument(); filename = doc->getSettings().getDirectoryMacro(); } filename += "*.BAS"; CFileDialog FileDialog(TRUE, "BAS", filename, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, "Macro File (*.BAS)|*.BAS|All Files (*.*)|*.*||", NULL); if (FileDialog.DoModal() != IDOK) return; CWaitCursor wait; filename = "\""; filename += FileDialog.GetPathName(); filename += "\""; // filename = FileDialog.GetPathName(); SAX dlg; dlg.Create(IDD_SAX_BASIC); dlg.m_sbpro.RunFile(filename); }
void glTakeScreenshot(GtkWidget* window) { char* filename=NULL; char* pixels; int w,h,aw; BITMAPFILEHEADER hd; BITMAPINFO info; FILE *fp; memset(&hd,0,sizeof(BITMAPFILEHEADER)); memset(&info,0,sizeof(BITMAPINFO)); gdk_drawable_get_size(window->window,&w,&h); filename=FileDialog(SAVE_DIALOG,window); fp=fopen(filename,"wb"); if(!fp) { if(filename) free(filename); return; } if(w%4) aw=(w*3/4+1)*4; else aw=w*3; pixels=malloc(aw*h); //glPixelStorei(GL_PACK_ALIGNMENT,1); glReadPixels(0,0,w,h,GL_BGR,GL_UNSIGNED_BYTE,pixels); // BMP header info.bmiHeader.biSize=sizeof(BITMAPINFOHEADER); info.bmiHeader.biWidth=w; info.bmiHeader.biHeight=h; info.bmiHeader.biPlanes=1; info.bmiHeader.biBitCount=24; info.bmiHeader.biCompression=BI_RGB; info.bmiHeader.biSizeImage=aw*h; info.bmiHeader.biXPelsPerMeter=2952; info.bmiHeader.biYPelsPerMeter=2952; hd.bfType=0x4d42; hd.bfSize=info.bmiHeader.biSizeImage+sizeof(BITMAPINFO)+sizeof(BITMAPFILEHEADER); hd.bfOffBits=sizeof(BITMAPINFO)+sizeof(BITMAPFILEHEADER); // Write to BMP file fwrite(&hd,sizeof(BITMAPFILEHEADER),1,fp); fwrite(&info,sizeof(BITMAPINFO),1,fp); fwrite(pixels,info.bmiHeader.biSizeImage,1,fp); fclose(fp); free(pixels); }
//_____________________________________________________________________________ void CCEtoODBApp::OnLoadFont() { CFileDialog FileDialog(TRUE, "FNT", "*.FNT", OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, "CAMCAD Font File (*.FNT)|*.FNT|All Files (*.*)|*.*||", NULL); if (FileDialog.DoModal() != IDOK) return; CFontList::getFontList().glyphFont(FileDialog.GetPathName()); }
void PCB_Grid::OnLoad() { CFileDialog FileDialog(TRUE, "GRD", "*.grd", OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, "Manuf Grid File (*.GRD)|*.GRD|All Files (*.*)|*.*||", NULL); if (FileDialog.DoModal() != IDOK) return; LoadGridSettings(FileDialog.GetPathName(), TRUE); }
void CLayerTypeDlg::OnBnClickedSave() { CFileDialog FileDialog(FALSE, "LT", "DEFAULT.LT", OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, "Layertype Info File (*.LT)|*.LT|All Files (*.*)|*.*||", NULL); if (FileDialog.DoModal() != IDOK) return; applyChanges(); SaveLayerTypeInfo(pDoc, FileDialog.GetPathName()); }
void CXMLDlg::OnBrowseClicked() { CFileDialog FileDialog(true, "*.xml", NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, "XML Files (*.xml)|*.xml|All Files (*.*)|*.*||", AfxGetMainWnd()); if (FileDialog.DoModal() != IDOK) return; m_strFileName = FileDialog.GetPathName(); UpdateData(false); }
void CLayerTypeDlg::OnBnClickedLoad() { CFileDialog FileDialog(TRUE, "LT", "DEFAULT.LT", OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, "Layertype Info File (*.LT)|*.LT|All Files (*.*)|*.*||", NULL); if (FileDialog.DoModal() != IDOK) return; LoadLayerTypeInfo(pDoc, FileDialog.GetPathName()); fillColorSetNameColumnTitles(); fillColorSetsComboBox(); fillLayerTypesInGrid(); fillLayerColorsInGrid(); }
int EditBoxCollection::check_save() { if(!current()) return 0; EditBox* cur = current(); do { //if(current()->get_changed()) if(!current()->get_saved()) { draw(); int rc = AChoice(5, 5, Yes_No, "Save?"); switch(rc) { case -1: case 2: select(cur); return -1; case 0: if(current()->is_untitled()) { rc = FileDialog(5, 5, cName, 2); if(!rc) current()->save_as(cName); else return -1; } if(current()->save()) { MessageBox("Error saving file!"); return -1; } } } else current()->save(); //just put EA and ignore errors next(); } while(current() != cur); return 0; }
void TerrainImportContour::OnBnClickedButtonContoureBroswer() { // TODO(jason): 在此添加控件通知处理程序代码 CString tt, stt; FILE* fp; CFileDialog FileDialog(TRUE, "等高势图", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "等高势图terrain(*.bmp)|*.bmp|文本格式(*.txt)|*.txt||", NULL); FileDialog.m_ofn.lpstrTitle = "选择等高势图文件"; if (FileDialog.DoModal() == IDOK) m_TerrainContour = FileDialog.GetPathName(); else return; this->UpdateData(FALSE); if ((fp = fopen(m_TerrainContour, "r")) == NULL) { MessageBox("等高势图文件不存在!", "初始化地面模型", MB_ICONINFORMATION + MB_OK); LOGGER_ERROR << "等高势图文件不存在!"; exit(-1); } }
void CSkyBoxTexLoad::OnBnClickedButtonSkyBk() { // TODO(jason): 在此添加控件通知处理程序代码 CString tt, stt; FILE* fp; CFileDialog FileDialog(TRUE, "天空盒", NULL, OFN_HIDEREADONLY \ | OFN_OVERWRITEPROMPT, \ "天空盒(*.bmp)|*.bmp|", NULL); FileDialog.m_ofn.lpstrTitle = "选择天空盒[后面]文件"; if (FileDialog.DoModal() == IDOK) m_SkyBoxTexBK = FileDialog.GetPathName(); else return; this->UpdateData(FALSE); if ((fp = fopen(m_SkyBoxTexBK, "r")) == NULL) { MessageBox("天空盒文件不存在!", "初始化天空盒模型", MB_ICONINFORMATION + MB_OK); exit(-1); } }
bool CDocCommands::SaveImage() { CWaitCursor Wait; CImageObject* pObject = m_DocWindow.GetSelectedObject(); if (!pObject) { CMessageBox::NoObjectSelected(); return false; } CString strFilePath = StripExtension(pObject->GetSourceFile()); LPCTSTR pstrFilter = _T("All Supported Files (*.bmp, *.jpg)\0*.bmp;*.jpg\0Bitmap Files (*.bmp)\0*.bmp\0JPG Files (*.jpg)\0*.jpg\0All Files (*.*)\0*.*\0\0"); CFileDialog FileDialog(false, _T("jpg"), strFilePath, OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT, pstrFilter, m_DocWindow/*hWndParent*/); FileDialog.m_ofn.lpstrTitle = _T("Save an Image File"); if (FileDialog.DoModal(m_DocWindow) == IDCANCEL) return false; CString strFileName = FileDialog.m_ofn.lpstrFile; bool bOK = false; BITMAPINFOHEADER* pDib = pObject->GetDib(true/*bForDraw*/); // DibForDraw gives us the rotated image if (pDib) { CString strExtension = StrExtension(strFileName); if (strExtension == ".bmp") bOK = DibWrite(pDib, strFileName); else if (strExtension == ".jpg") bOK = ConvertDibToJpg(pDib, 100, strFileName); } if (!bOK) CMessageBox::Message(String("Error saving to file '%s'.", strFileName)); return bOK; }
void MyDialog2::OnOpenButton() { CFileDialog FileDialog(TRUE); CString FileName = "Default.olsr"; CString PathName; FileDialog.m_ofn.lpstrFilter = "Configuration file (*.olsr)\0*.olsr\0"; FileDialog.m_ofn.nFilterIndex = 1; FileDialog.m_ofn.lpstrFile = FileName.GetBuffer(500); FileDialog.m_ofn.nMaxFile = 500; if (FileDialog.DoModal() == IDOK) { PathName = FileDialog.GetPathName(); if (OpenConfigFile(PathName) < 0) AfxMessageBox("Cannot open configuration file '" + PathName + "'."); } FileName.ReleaseBuffer(); }
void CEOSSPropertySheet::OnPrintButton() { FILE* outfile; char *at; while ((at = strchr(m_pCaption,':'))!=NULL) at[0] = '_'; m_dToClose = 0; CFileDialog FileDialog(FALSE,"txt",m_pCaption, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN, "Text Files (*.txt)|*.txt|All Files (*.*)|*.*||",this); if (FileDialog.DoModal()!=IDCANCEL) { CString filename = FileDialog.GetPathName(); outfile = fopen(filename,"w"); m_pParent->IssuePrint(outfile); fclose(outfile); } }
bool CDocCommands::BorderImageChoose(CString& strFileName) { LPCTSTR pstrFilter = (CImage::IsGdiPlusInstalled() ? FILTER_WITH_GDIPLUS : FILTER_WITHOUT_GDIPLUS); CFileDialog FileDialog(true, _T("jpg"), NULL/*pszFileName*/, OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT, pstrFilter, m_DocWindow/*hWndParent*/); FileDialog.m_ofn.lpstrTitle = _T("Open an Image File"); if (FileDialog.DoModal(m_DocWindow) == IDCANCEL) return false; strFileName = FileDialog.m_ofn.lpstrFile; // Save the path in the registry //j if (regkey.m_hKey) //j bool bOK = (regkey.SetStringValue(REGVAL_MRU_PICTURE_PATH, StrPath(szFileName)) == ERROR_SUCCESS); // Redraw the window underneath, before we get to work ::UpdateWindow(m_DocWindow); return true; }
void CTextureDlg::OnAddTexture() { CFileDialog FileDialog(TRUE, NULL, NULL, OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST, STRING_IMPORT_IMG_FILTER); if (FileDialog.DoModal() != IDOK){ return; } CString FileExt = FileDialog.GetFileExt(); CString FilePath = FileDialog.GetPathName(); CMainFrame* pMainFrm = (CMainFrame*)AfxGetMainWnd(); ASSERT(pMainFrm); pMainFrm->AddTexture(FilePath); CString FileName = FileDialog.GetFileName(); CString message; int ItemCount = TextureList.GetItemCount(); message.Format("%d", ItemCount+1); AddItem(ItemCount, (int)TEXTURE_LIST_INDEX, message); AddItem(ItemCount, (int)TEXTURE_LIST_FILE, FileName); AddItem(ItemCount, (int)TEXTURE_LIST_OPERATION, CString(TextureOperation[0])); AddItem(ItemCount, (int)TEXTURE_LIST_ADDRESS, CString(TextureAddress[1])); }
void Action_LoadFile(void) { FileDialog(); }
bool SaveFileDialog(const QString& title, const QString& suffix, const QStringList& filters, QString& filename, int* usedFilter) { return FileDialog().SaveFile(title, suffix, filters, filename, usedFilter); }
std::string putFile(){ return FileDialog(true); };
void CDlgHistory::OnBnClickedButtonExport() { // TODO: 在此添加控件通知处理程序代码 UpdateData(TRUE); GetDlgItem(IDC_BUTTON_EXPORT)->EnableWindow(FALSE); COleVariant covTrue((short)TRUE),covFalse((short)FALSE),covOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR); book.PrintPreview(_variant_t(false)); CFileDialog FileDialog(FALSE,"xlsx",NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, _T("Microsoft Excel 2007(*.xlsx)|*.xlsx|所有文件(*.*)"),this); if(FileDialog.DoModal()!=IDOK) { GetDlgItem(IDC_BUTTON_EXPORT)->EnableWindow(TRUE); return; } CString cStrFile=FileDialog.GetPathName(); //选择保存路径名称 if(::PathFileExists(cStrFile)) DeleteFile(cStrFile); CString AntID,SensorID,StrStartTime,StrStopTime,tmpData,passWord,StartTime,StopTime,message,strRecordTime,rowCount,strRow,strLimit; StrStartTime.Format("%f",m_DataBegin); StrStopTime.Format("%f",m_DataEnding); CTime m_Startdate; m_CtlDateTimeStartTime.GetTime(m_Startdate); StartTime.Format("%d%02d%02d",m_Startdate.GetYear(), m_Startdate.GetMonth(),m_Startdate.GetDay()); _RecordsetPtr m_pRecordsetch; m_pRecordsetch.CreateInstance(__uuidof(Recordset)); books = app.get_Workbooks(); book = books.Add(covOptional); sheets = book.get_Worksheets(); sheets.Add(vtMissing,vtMissing,vtMissing,vtMissing); int nCount; char cCell; for(int i=1;i<5;i++) { tmpData.Format("%d",i); AntID = "天线"+tmpData; sheet = sheets.get_Item(COleVariant((short)i)); //得到第一个工作表 sheet.put_Name(AntID); for(int j=1;j<13;j++) { nCount = 3; tmpData.Format("%d",j); SensorID = "传感器"+tmpData; cCell = 'A' + 2*(j-1); rowCount.Format(_T("%c"),cCell); rowCount+="1"; range = sheet.get_Range(COleVariant(rowCount),COleVariant(rowCount)); range.put_Value2(COleVariant(SensorID)); rowCount.Format(_T("%c"),cCell); rowCount+="2"; range = sheet.get_Range(COleVariant(rowCount),COleVariant(rowCount)); range.put_Value2(COleVariant("时间")); rowCount.Format(_T("%c"),cCell+1); rowCount+="2"; range = sheet.get_Range(COleVariant(rowCount),COleVariant(rowCount)); range.put_Value2(COleVariant("温度")); _bstr_t bstrSQLdata ="SELECT Temperature,RecordTime FROM DB_Data where ReaderID='"+strReader+"' and AntID='"+AntID+"' and SensorID='"+SensorID+"' and RecordTime<"+StrStopTime+" and RecordTime>"+StrStartTime+" and (Notes='正常' or Notes='超限') order by DataID;"; m_pRecordsetch->Open(bstrSQLdata,m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText); while(!m_pRecordsetch->adoEOF) { CString temper=(LPCSTR)(_bstr_t)m_pRecordsetch->GetCollect("Temperature"); CString time=(LPCSTR)(_bstr_t)m_pRecordsetch->GetCollect("RecordTime"); COleDateTime t=atof(time); strRecordTime=t.Format("%Y-%m-%d %H:%M:%S"); rowCount.Format(_T("%c"),cCell); strRow.Format(_T("%d"),nCount); rowCount+=strRow; range = sheet.get_Range(COleVariant(rowCount),COleVariant(rowCount)); range.put_NumberFormat(COleVariant("hh:mm:ss")); range.put_Value2(COleVariant(strRecordTime)); //设置时间 rowCount.Format(_T("%c"),cCell+1); rowCount+=strRow; range = sheet.get_Range(COleVariant(rowCount),COleVariant(rowCount)); range.put_Value2(COleVariant(temper)); //设置温度 time.ReleaseBuffer(); temper.ReleaseBuffer(); m_pRecordsetch->MoveNext(); nCount++; } m_pRecordsetch->Close(); } range = sheet.get_Range(COleVariant("A3"),COleVariant("A3")); COleVariant vResult =range.get_Value2(); if(vResult.vt==VT_EMPTY) { passWord="******"; } else { SYSTEMTIME st; VariantTimeToSystemTime(vResult.date, &st); passWord.Format("%d%02d%02d",st.wYear,st.wMonth,st.wDay); passWord+="hshiot"; } sheet.Protect(_variant_t(passWord),vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing); } book.SaveCopyAs(COleVariant(cStrFile)); //保存到cStrFile文件 book.put_Saved(true); books.Close(); book.ReleaseDispatch(); books.ReleaseDispatch(); app.ReleaseDispatch(); app.Quit(); message = "已导出数据,文件位置 :"+cStrFile; AfxMessageBox(message); GetDlgItem(IDC_BUTTON_EXPORT)->EnableWindow(TRUE); }
/* * New version notification dialog */ INT_PTR CALLBACK new_version_callback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { int i; HWND hNotes; char tmp[128], cmdline[] = APPLICATION_NAME " /W"; static char* filepath = NULL; static int download_status = 0; STARTUPINFOA si; PROCESS_INFORMATION pi; HFONT hyperlink_font = NULL; EXT_DECL(exe_ext, NULL, __VA_GROUP__("*.exe"), __VA_GROUP__("Application")); switch (message) { case WM_INITDIALOG: download_status = 0; set_title_bar_icon(hDlg); center_dialog(hDlg); // Subclass the callback so that we can change the cursor original_wndproc = (WNDPROC)SetWindowLongPtr(hDlg, GWLP_WNDPROC, (LONG_PTR)subclass_callback); hNotes = GetDlgItem(hDlg, IDC_RELEASE_NOTES); SendMessage(hNotes, EM_AUTOURLDETECT, 1, 0); SendMessageA(hNotes, EM_SETTEXTEX, (WPARAM)&friggin_microsoft_unicode_amateurs, (LPARAM)update.release_notes); SendMessage(hNotes, EM_SETSEL, -1, -1); SendMessage(hNotes, EM_SETEVENTMASK, 0, ENM_LINK); safe_sprintf(tmp, sizeof(tmp), "Your version: %d.%d (Build %d)", application_version[0], application_version[1], application_version[2]); SetWindowTextU(GetDlgItem(hDlg, IDC_YOUR_VERSION), tmp); safe_sprintf(tmp, sizeof(tmp), "Latest version: %d.%d (Build %d)", update.version[0], update.version[1], update.version[2]); SetWindowTextU(GetDlgItem(hDlg, IDC_LATEST_VERSION), tmp); SetWindowTextU(GetDlgItem(hDlg, IDC_DOWNLOAD_URL), update.download_url); SendMessage(GetDlgItem(hDlg, IDC_PROGRESS), PBM_SETRANGE, 0, (MAX_PROGRESS<<16) & 0xFFFF0000); if (update.download_url == NULL) EnableWindow(GetDlgItem(hDlg, IDC_DOWNLOAD), FALSE); break; case WM_CTLCOLORSTATIC: if ((HWND)lParam != GetDlgItem(hDlg, IDC_WEBSITE)) return FALSE; // Change the font for the hyperlink SetBkMode((HDC)wParam, TRANSPARENT); CreateStaticFont((HDC)wParam, &hyperlink_font); SelectObject((HDC)wParam, hyperlink_font); SetTextColor((HDC)wParam, RGB(0,0,125)); // DARK_BLUE return (INT_PTR)CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); case WM_COMMAND: switch (LOWORD(wParam)) { case IDCLOSE: case IDCANCEL: if (download_status != 1) { safe_free(filepath); EndDialog(hDlg, LOWORD(wParam)); } return (INT_PTR)TRUE; case IDC_WEBSITE: ShellExecuteA(hDlg, "open", APPLICATION_URL, NULL, NULL, SW_SHOWNORMAL); break; case IDC_DOWNLOAD: // Also doubles as abort and launch function switch(download_status) { case 1: // Abort download_status = 0; error_code = ERROR_SEVERITY_ERROR|ERROR_CANCELLED; break; case 2: // Launch newer version and close this one Sleep(1000); // Add a delay on account of antivirus scanners memset(&si, 0, sizeof(si)); memset(&pi, 0, sizeof(pi)); si.cb = sizeof(si); if (!CreateProcessU(filepath, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { print_status(0, TRUE, "Failed to launch new application"); dprintf("Failed to launch new application: %s\n", WindowsErrorString()); } else { print_status(0, FALSE, "Launching new application..."); PostMessage(hDlg, WM_COMMAND, (WPARAM)IDCLOSE, 0); PostMessage(hMainDialog, WM_CLOSE, 0, 0); } break; default: // Download if (update.download_url == NULL) { print_status(0, TRUE, "Could not get download URL\n"); break; } for (i=(int)strlen(update.download_url); (i>0)&&(update.download_url[i]!='/'); i--); exe_ext.filename = PathFindFileNameU(update.download_url); filepath = FileDialog(TRUE, app_dir, &exe_ext, OFN_NOCHANGEDIR); if (filepath == NULL) { print_status(0, TRUE, "Could not get save path\n"); break; } DownloadFileThreaded(update.download_url, filepath, hDlg); break; } return (INT_PTR)TRUE; } break; case UM_DOWNLOAD_INIT: error_code = 0; download_status = 1; SetWindowTextU(GetDlgItem(hDlg, IDC_DOWNLOAD), "Abort"); return (INT_PTR)TRUE; case UM_DOWNLOAD_EXIT: if (wParam) { SetWindowTextU(GetDlgItem(hDlg, IDC_DOWNLOAD), "Launch"); download_status = 2; } else { SetWindowTextU(GetDlgItem(hDlg, IDC_DOWNLOAD), "Download"); download_status = 0; } return (INT_PTR)TRUE; } return (INT_PTR)FALSE; }
string pDialogWindow::fileSave(Window &parent, const string &path, const lstring &filter) { return FileDialog(true, parent, path, filter); }
string pDialogWindow::fileOpen(Window &parent, const string &path, const lstring &filter) { return FileDialog(false, parent, path, filter); }
std::string getFile(){ return FileDialog(false); };
bool OpenFolderDialog(const QString& title, QString& folder) { return FileDialog().OpenFolder(title, folder); }