本文整理汇总了C++中CFileDialog::GetPathName方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileDialog::GetPathName方法的具体用法?C++ CFileDialog::GetPathName怎么用?C++ CFileDialog::GetPathName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileDialog
的用法示例。
在下文中一共展示了CFileDialog::GetPathName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Save_Set
BOOL CMUSHclientDoc::Save_Set (const int set_type,
CWnd * parent_window)
{
CString suggested_name = m_mush_name,
filter,
title,
suggested_extension;
CFile * f = NULL;
CArchive * ar = NULL;
BOOL error = TRUE;
CString sig;
CString filename;
if (Set_Up_Set_Strings (set_type,
suggested_name,
filter,
title,
suggested_extension))
return TRUE; // bad set_type
CFileDialog filedlg (FALSE, // saving the file
suggested_extension, // default extension
"", // suggested name
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
filter, // filter
parent_window); // parent window
// fix up name to remove characters that are invalid
int i;
while ((i = suggested_name.FindOneOf ("<>\"|?:#%;/\\")) != -1)
suggested_name = suggested_name.Left (i) + suggested_name.Mid (i + 1);
filedlg.m_ofn.lpstrTitle = title;
filedlg.m_ofn.lpstrFile = filename.GetBuffer (_MAX_PATH); // needed!! (for Win32s)
if (App.platform == VER_PLATFORM_WIN32s)
strcpy (filedlg.m_ofn.lpstrFile, "");
else
strcpy (filedlg.m_ofn.lpstrFile, suggested_name);
ChangeToFileBrowsingDirectory ();
int nResult = filedlg.DoModal();
ChangeToStartupDirectory ();
if (nResult != IDOK)
return TRUE; // cancelled dialog
CPlugin * pSavedPlugin = m_CurrentPlugin;
m_CurrentPlugin = NULL; // make sure we save main triggers etc.
try
{
f = new CFile (filedlg.GetPathName (),
CFile::modeCreate | CFile::modeReadWrite);
ar = new CArchive(f, CArchive::store);
switch (set_type)
{
case TRIGGER: Save_World_XML (*ar, XML_TRIGGERS); break;
case ALIAS: Save_World_XML (*ar, XML_ALIASES); break;
case COLOUR: Save_World_XML (*ar, XML_COLOURS); break;
case MACRO: Save_World_XML (*ar, XML_MACROS); break;
case TIMER: Save_World_XML (*ar, XML_TIMERS); break;
} // end of switch
error = FALSE;
} // end of try block
catch (CFileException * e)
{
::TMessageBox ("Unable to create the requested file", MB_ICONEXCLAMATION);
e->Delete ();
} // end of catching a file exception
catch (CMemoryException * e)
{
::TMessageBox ("Insufficient memory to do this operation", MB_ICONEXCLAMATION);
e->Delete ();
} // end of catching a memory exception
catch (CArchiveException * e)
{
::TMessageBox ("There was a problem in the data format", MB_ICONEXCLAMATION);
e->Delete ();
} // end of catching an archive exception
m_CurrentPlugin = pSavedPlugin;
delete ar; // delete archive
delete f; // delete file
return error; // OK return
} // end of CMUSHclientDoc::save_set
示例2: OnButtonopen
void CDfuFileMgrDlgExtract::OnButtonopen()
{
TCHAR szFilters[]=
"Dfu Files (*.dfu)|*.dfu|All Files (*.*)|*.*||";
char Path[MAX_PATH];
char Tmp[MAX_PATH];
char *pTmp;
GetModuleFileName(NULL, Path, MAX_PATH);
strrev(Path);
pTmp = strchr(Path, '\\');
strrev(pTmp);
lstrcpy(Tmp, pTmp);
lstrcpy(Path, Tmp);
lstrcat(Path, "*.dfu");
CFileDialog* dlg;
dlg = new CFileDialog(TRUE, _T("dfu"), _T("*.dfu"), OFN_FILEMUSTEXIST, szFilters, this);
UpdateData(TRUE);
m_ListFiles.ResetContent();
if (dlg->DoModal()==IDOK)
{
BYTE Alts;
WORD Vid;
WORD Pid;
WORD Bcd;
if (m_hFile!=0)
STDFUFILES_CloseDFUFile(m_hFile);
if (STDFUFILES_OpenExistingDFUFile((LPSTR)(LPCSTR)dlg->GetPathName(), &m_hFile, &Vid, &Pid, &Bcd, &Alts) == STDFUFILES_NOERROR)
{
BYTE Alt;
CString Tmp, Tmp1;
m_Pid.Format("%04X", Pid);
m_Vid.Format("%04X", Vid);
m_Bcd.Format("%04X", Bcd);
m_FileBaseName=dlg->GetPathName().Left(dlg->GetPathName().GetLength()-4);
m_DfuFile = dlg->GetPathName();
UpdateData(FALSE);
for (BYTE i=0;i<Alts;i++)
{
HANDLE Image;
CString Tmp;
if (STDFUFILES_ReadImageFromDFUFile(m_hFile, i, &Image)==STDFUFILES_NOERROR)
{
char Name[512];
STDFUFILES_GetImageAlternate(Image, &Alt);
STDFUFILES_GetImageName(Image, Name);
STDFUFILES_DestroyImage(&Image);
Tmp.Format("Image for Target ID %02i", Alt);
if (Name[0]!='\0')
{
Tmp+=" (";
Tmp+=Name;
Tmp+=")";
}
m_ListFiles.AddString(Tmp);
}
else
{
AfxMessageBox("Unable to read images in file...");
break;
}
if(m_ListFiles.GetCount()>0)
m_ListFiles.SetCurSel(0);
}
}
else
AfxMessageBox("Error... Maybe bad or old file format");
}
}
示例3: Load_Set
BOOL CMUSHclientDoc::Load_Set (const int set_type,
CString strFileName,
CWnd * parent_window)
{
BOOL replace = TRUE;
if (strFileName.IsEmpty ())
{
CString suggested_name = m_mush_name,
filter,
title,
suggested_extension;
CString filename;
if (Set_Up_Set_Strings (set_type,
suggested_name,
filter,
title,
suggested_extension))
return TRUE; // bad set_type
CFileDialog filedlg (TRUE, // loading the file
suggested_extension, // default extension
"", // suggested name
OFN_HIDEREADONLY | OFN_FILEMUSTEXIST,
filter, // filter
parent_window); // parent window
filedlg.m_ofn.lpstrTitle = title;
filedlg.m_ofn.lpstrFile = filename.GetBuffer (_MAX_PATH); // needed!! (for Win32s)
if (App.platform == VER_PLATFORM_WIN32s)
strcpy (filedlg.m_ofn.lpstrFile, "");
else
strcpy (filedlg.m_ofn.lpstrFile, suggested_name);
ChangeToFileBrowsingDirectory ();
int nResult = filedlg.DoModal();
ChangeToStartupDirectory ();
if (nResult!= IDOK)
return TRUE; // cancelled dialog
// since they can have any number of triggers, aliases and timers, ask them
// whether they want to add this file to an existing list (if any)
if (set_type == TRIGGER && !m_TriggerMap.IsEmpty ())
{
if (::TMessageBox ("Replace existing triggers?\n"
"If you reply \"No\", then triggers from the file"
" will be added to existing triggers",
MB_YESNO | MB_ICONQUESTION) == IDNO)
replace = FALSE;
}
else
if (set_type == ALIAS && !m_AliasMap.IsEmpty ())
{
if (::TMessageBox ("Replace existing aliases?\n"
"If you reply \"No\", then aliases from the file"
" will be added to existing aliases",
MB_YESNO | MB_ICONQUESTION) == IDNO)
replace = FALSE;
}
else
if (set_type == TIMER && !m_TimerMap.IsEmpty ())
{
if (::TMessageBox ("Replace existing timers?\n"
"If you reply \"No\", then timers from the file"
" will be added to existing timers",
MB_YESNO | MB_ICONQUESTION) == IDNO)
replace = FALSE;
}
strFileName = filedlg.GetPathName ();
} // end of no filename suppliedl
CFile * f = NULL;
CArchive * ar = NULL;
try
{
f = new CFile (strFileName, CFile::modeRead | CFile::shareDenyWrite);
ar = new CArchive(f, CArchive::load);
if (IsArchiveXML (*ar))
{
switch (set_type)
{
case TRIGGER:
if (replace)
DELETE_MAP (m_TriggerMap, CTrigger);
Load_World_XML (*ar, XML_TRIGGERS | XML_NO_PLUGINS);
break;
case ALIAS:
if (replace)
DELETE_MAP (m_AliasMap, CAlias);
//.........这里部分代码省略.........
示例4: OnDraw
void CGUIFaceInVideoView::OnDraw(CDC* pDC)
{
CGUIFaceInVideoDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (pDoc == NULL)
return;
CIplImage *pImgIn;
CvPoint *pPointL, *pPointR;
int nNameTag, nBestMatch;
char strMessage[200];
CPerceptualVisionSystem *pPVS = pDoc->getPVS();
bool bRes = pPVS->initializeNextFrame();
if (bRes == false)
return; // if want to show it but not process it, change it.
sprintf(strMessage, "%i msec", pPVS->m_tBetweenFrames);
OnDraw_LogWindow(pDC, strMessage, set_window(0,0), 0);
pDoc->m_gui.check_start = pDoc->m_gui.check_start;
if (pDoc->m_gui.check_start == true)
{
int z;
for (z=0; z < pPVS->m_pianoPlaying.m_nNumHands; z++)
pPVS->m_pianoPlaying.m_Hand[z].destroy();
pPVS->m_pianoPlaying.m_nNumHands = 0;
}
////////////AVI RECORDING//////////////////
if (pDoc->m_recordCheck == true) // For saving video file made of video frames
{
pPVS->m_imgIn.draw(pDC->m_hDC, set_window(0,3), false, false);
OnDraw_LogWindow(pDC, "Start recording..", set_window(0,3), 1);
pPVS->m_bRecording = true;
if (pPVS->m_bRecordingStarted == false)
{
// open a dialog box.
TCHAR szFilter[] = _T ( "Movie Files (*.avi)" );
CFileDialog *dlg = new CFileDialog( FALSE, _T("avi"), _T("*.avi"), OFN_ENABLESIZING | OFN_OVERWRITEPROMPT, szFilter, (CWnd*)this);
char strAviFullName[200], strAviLocalName[200];
if(dlg->DoModal() == IDOK)
strcpy(strAviFullName, dlg->GetPathName());
pPVS->m_pCvVideoWriter = NULL;
pPVS->m_pCvVideoWriter = cvCreateVideoWriter(strAviFullName,
// Uncompressed
CV_FOURCC('D','I','B',' '), 10.0, cvSize(160,120) );
pPVS->m_bRecordingStarted = true;// Open AVI file
}
//Add frame to AVI
if (pPVS->m_pCvVideoWriter)
cvWriteFrame( pPVS->m_pCvVideoWriter, pPVS->m_imgIn.getIplImage() );
return;
}
else
{
pPVS->m_bRecording = false;
if (pPVS->m_bRecordingStarted == true)
{
pPVS->m_bRecordingStarted = false; // Close AVI
if (pPVS->m_pCvVideoWriter)
cvReleaseVideoWriter( &pPVS->m_pCvVideoWriter );
}
}
////////////////END AVI RECORDING////////////////
///////////////////////
// return; //////// debuging.....
///////////////////////
/***************************************************************************************/
/*** Grab data from MIDI **************************************************/
/***************************************************************************************/
int q, keyValue, octave;
bool keyChange[200]; // bKeyChanged[nTotalPianoKeys] //To indicate Changes only
//For printing Purposes
if (m_bMidiCheck==false)
{
//.........这里部分代码省略.........
示例5: OnExportHTML
void CCWArrangePage::OnExportHTML ()
{
m_List.SaveEdit ();
GetTracksInfo ();
if (m_pTracks == NULL)
return;
CFileDialog dlg (FALSE, "html");
if (dlg.DoModal () == IDOK)
{
CStdioFile file (dlg.GetPathName (), CFile::modeCreate | CFile::modeWrite);
file.WriteString ("<html>\r\n\t<head>\r\n\t\t<title>Exported Track Listing: " +
m_pTracks->GetTitle () + "</title>\r\n\t</head>\r\n\r\n\t<body>\r\n");
if (m_pTracks->GetArtist ().IsEmpty ())
file.WriteString ("\t\t<h1>" + m_pTracks->GetTitle () + "</h1>\r\n");
else
file.WriteString ("\t\t<h1>" + m_pTracks->GetArtist () + "</h1>\r\n\t\t<h2>" +
m_pTracks->GetTitle () + "</h2>\r\n");
file.WriteString ("\t\t<table border=\"1\">\r\n\t\t\t<tr>\r\n");
file.WriteString ("\t\t\t\t<th>Track</th>\r\n");
file.WriteString ("\t\t\t\t<th>Track title</th>\r\n");
file.WriteString ("\t\t\t\t<th>Track remarks</th>\r\n");
file.WriteString ("\t\t\t\t<th>Track length</th>\r\n");
file.WriteString ("\t\t\t</tr>\r\n\r\n");
for (int i = 0; i < m_pTracks->GetNumTracks (); i++)
{
CTrack t = m_pTracks->GetTrack (i);
file.WriteString ("\t\t\t<tr>\r\n");
CString s;
s.Format ("%d.", i + 1);
// s
file.WriteString ("\t\t\t\t<td>");
if (s.IsEmpty ())
file.WriteString (" ");
else
file.WriteString (s);
file.WriteString ("</td>\r\n");
// title
file.WriteString ("\t\t\t\t<td>");
s = t.GetTitle ();
if (s.IsEmpty ())
file.WriteString (" ");
else
file.WriteString (s);
file.WriteString ("</td>\r\n");
// remarks
file.WriteString ("\t\t\t\t<td>");
s = t.GetRemarks ();
if (s.IsEmpty ())
file.WriteString (" ");
else
file.WriteString (s);
file.WriteString ("</td>\r\n");
// length
file.WriteString ("\t\t\t\t<td>");
s = t.GetNiceLength ();
if (s.IsEmpty ())
file.WriteString (" ");
else
file.WriteString (s);
file.WriteString ("</td>\r\n");
file.WriteString ("\t\t\t</tr>\r\n");
}
file.WriteString ("\t\t</table>\r\n\t</body>\r\n</html>");
file.Close ();
}
}
示例6: ExportHistory
void CDlgExportHistory::ExportHistory(int iWhich, BOOL bCompletedOnly, BOOL bAppend)
{
fs::list <fsDLHistoryRecord*> vpHist;
switch (iWhich)
{
case 0:
{
_DldsMgr.m_histmgr.Lock ();
for (int i = 0; i < _DldsMgr.m_histmgr.GetRecordCount (); i++)
{
fsDLHistoryRecord* rec = _DldsMgr.m_histmgr.GetRecord (i);
if (bCompletedOnly && rec->dateDownloaded.dwHighDateTime == 0)
continue;
vpHist.add (rec);
}
_DldsMgr.m_histmgr.Unlock ();
}
break;
case 1:
{
CDownloads_History* list = &_pwndDownloads->m_wndHistory;
int cItems = list->GetItemCount ();
for (int i = cItems-1; i >= 0; i--)
{
fsDLHistoryRecord* rec = (fsDLHistoryRecord*) list->GetItemData (i);
if (bCompletedOnly && rec->dateDownloaded.dwHighDateTime == 0)
continue;
vpHist.add (rec);
}
}
break;
case 2:
CDownloads_History* list = &_pwndDownloads->m_wndHistory;
POSITION pos = list->GetFirstSelectedItemPosition ();
while (pos)
{
int nItem = list->GetNextSelectedItem (pos);
fsDLHistoryRecord* rec = (fsDLHistoryRecord*) list->GetItemData (nItem);
if (bCompletedOnly && rec->dateDownloaded.dwHighDateTime == 0)
continue;
vpHist.add (rec);
}
}
if (vpHist.size () == 0)
{
AfxGetApp ()->m_pMainWnd->MessageBox (LS (L_NOTHINGTOEXPORT), NULL, MB_ICONEXCLAMATION);
return;
}
CString strFilter;
strFilter.Format ("%s (*.html)|*.html||", LS (L_HTMLFILES));
UINT flags = OFN_NOCHANGEDIR;
if (bAppend == FALSE)
flags |= OFN_OVERWRITEPROMPT;
CFileDialog dlg (FALSE, "html", NULL, flags, strFilter, NULL);
if (_DlgMgr.DoModal (&dlg) == IDCANCEL)
return;
ExportHistory (dlg.GetPathName (), vpHist, bAppend);
}
示例7: OnFileOpen
void CChildView::OnFileOpen()
{
CFileDialog* fd = new CFileDialog(true, _T("jfd"), _T("*.jfd"));
wstring fileName;
fd->m_ofn.lpstrTitle = TEXT("Open save file");
fd->m_ofn.lpstrFilter = TEXT("JFDraw Files (*.jfd)");
if (fd->DoModal() == IDOK)
{
fileName = fd->GetPathName();
ifstream file(fileName);
string rawline;
CChildView::Reset();
while (getline(file, rawline))
{
if (!rawline.empty())
{
stringstream line(rawline);
string seg;
vector<string> segs;
while (getline(line, seg, ','))
{
segs.push_back(seg);
}
if (segs.size() != 7)
{
continue;
}
CPoint startp(stoi(segs[1]), stoi(segs[2]));
CPoint endp(stoi(segs[3]), stoi(segs[4]));
int penWidth = stoi(segs[5]);
string text = segs[6];
Fraint::Shape* shape;
if (segs[0] == "Circle")
{
shape = new Fraint::Circle(startp, endp);
}
else if (segs[0] == "Rectangle")
{
shape = new Fraint::Rectangle(startp, endp);
}
else if (segs[0] == "Ellipse")
{
shape = new Fraint::Ellipse(startp, endp);
}
else if (segs[0] == "Square")
{
shape = new Fraint::Square(startp, endp);
}
else
{
continue;
}
shape->SetPenWidth(penWidth);
shape->SetText(text);
m_Shapes.push_back(shape);
}
}
RedrawShapes();
file.close();
}
}