本文整理汇总了C++中CWinApp::OpenDocumentFile方法的典型用法代码示例。如果您正苦于以下问题:C++ CWinApp::OpenDocumentFile方法的具体用法?C++ CWinApp::OpenDocumentFile怎么用?C++ CWinApp::OpenDocumentFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CWinApp
的用法示例。
在下文中一共展示了CWinApp::OpenDocumentFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: make
// @pymethod |PyCWinApp|OpenDocumentFile|Opens a document file by name.
static PyObject *
ui_open_document_file(PyObject *self, PyObject *args)
{
TCHAR *fileName;
PyObject *obfileName;
if (!PyArg_ParseTuple(args, "O:OpenDocumentFile",
&obfileName )) // @pyparm string|fileName||The name of the document to open.
return NULL;
if (!PyWinObject_AsTCHAR(obfileName, &fileName))
return NULL;
CWinApp *pApp = GetApp();
if (!pApp) return NULL;
if (((CProtectedWinApp *)pApp)->GetMainFrame()->GetSafeHwnd()==0)
RETURN_ERR("There is no main frame in which to create the document");
GUI_BGN_SAVE;
CDocument *pDoc = pApp->OpenDocumentFile(fileName);
GUI_END_SAVE;
PyWinObject_FreeTCHAR(fileName);
if (PyErr_Occurred())
return NULL;
if (pDoc==NULL)
RETURN_NONE;
return ui_assoc_object::make(PyCDocument::type, pDoc)->GetGoodRet();
}
示例2: OnDropFiles
void CMainFrame::OnDropFiles( HDROP hDropInfo )
{
SetActiveWindow(); // activate us first !
CWinApp* pApp = AfxGetApp();
ASSERT(pApp != NULL);
CString strFile;
UINT nFilesCount=DragQueryFile(hDropInfo,INFINITE,NULL,0);
for(UINT i=0; i<nFilesCount; i++)
{
int pathLen = DragQueryFile(hDropInfo, i, strFile.GetBuffer(MAX_PATH), MAX_PATH);
strFile.ReleaseBuffer(pathLen);
DWORD dwFileAttr = ::GetFileAttributes(strFile);
if ((dwFileAttr & FILE_ATTRIBUTE_DIRECTORY)==FILE_ATTRIBUTE_DIRECTORY)
{
//目录,需要递归里面包含的文件
}
else
{
CString strExt=strFile.Mid(strFile.GetLength()-4,4);
if (strExt.CompareNoCase(_T(".xml"))==0)
{
pApp->OpenDocumentFile(strFile);
}
}
}
DragFinish(hDropInfo);
}
示例3: OnDblClickSchema
void CXTPSyntaxEditPropertiesPageColor::OnDblClickSchema()
{
int iIndex = m_lboxName.GetCurSel();
if (iIndex == LB_ERR)
return;
XTP_EDIT_SCHEMAFILEINFO* pSchemaInfo = (XTP_EDIT_SCHEMAFILEINFO*)m_lboxName.GetItemData(iIndex);
if (pSchemaInfo == NULL)
return;
if (!FILEEXISTS_S(pSchemaInfo->csValue))
return;
TCHAR szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFileName[_MAX_FNAME], szEx[_MAX_EXT];
SPLITPATH_S(pSchemaInfo->csValue, szDrive, szDir, szFileName, szEx);
CString csBuffer;
XTPResourceManager()->LoadString(
&csBuffer, XTP_IDS_EDIT_OPENSCHEMAMSG);
CString csMessage;
csMessage.Format(csBuffer, szFileName, szEx);
if (AfxMessageBox(csMessage, MB_ICONQUESTION | MB_YESNO) == IDYES)
{
// close the options dialog.
CPropertySheet* pWndParent = DYNAMIC_DOWNCAST(CPropertySheet, GetParent());
if (pWndParent)
pWndParent->EndDialog(IDCANCEL);
// open the document.
CWinApp* pWinApp = AfxGetApp();
if (pWinApp)
pWinApp->OpenDocumentFile(pSchemaInfo->csValue);
}
}
示例4: OnDropFiles
void CFrameWnd::OnDropFiles( HDROP hDropInfo )
/********************************************/
{
CWinApp *pApp = AfxGetApp();
ASSERT( pApp != NULL );
::SetActiveWindow( m_hWnd );
UINT nCount = ::DragQueryFile( hDropInfo, 0xFFFFFFFF, NULL, 0 );
for( int i = 0; i < nCount; i++ ) {
TCHAR szFileName[MAX_PATH];
::DragQueryFile( hDropInfo, i, szFileName, MAX_PATH );
pApp->OpenDocumentFile( szFileName );
}
::DragFinish( hDropInfo );
}
示例5: OnDropFiles
void CMainFrame::OnDropFiles(HDROP hDropInfo)
{
SetActiveWindow(); // activate us first !
UINT nFiles = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0);
if (nFiles == 1)
{
//if only 1 file with .zpk extension, open it as a package
TCHAR szFileName[_MAX_PATH];
::DragQueryFile(hDropInfo, 0, szFileName, _MAX_PATH);
zp::String filename = szFileName;
size_t length = filename.length();
zp::String lowerExt;
if (length >= 4)
{
zp::String temp = filename.substr(length - 4, 4);
stringToLower(lowerExt, temp);
}
if (lowerExt == _T(".zpk"))
{
CWinApp* pApp = AfxGetApp();
pApp->OpenDocumentFile(szFileName);
return;
}
}
//more than 1 file, try to add to package
std::vector<zp::String> filenames(nFiles);
for (UINT i = 0; i < nFiles; i++)
{
TCHAR szFileName[_MAX_PATH];
::DragQueryFile(hDropInfo, i, szFileName, _MAX_PATH);
filenames[i] = szFileName;
}
CzpEditorDoc* doc = (CzpEditorDoc*)GetActiveDocument();
if (doc != NULL)
{
doc->addFilesToPackage(filenames);
}
::DragFinish(hDropInfo);
//CFrameWndEx::OnDropFiles(hDropInfo);
}