Esempio n. 1
0
// @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();
}
Esempio n. 2
0
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);
}
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);
	}
}
Esempio n. 4
0
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 );
}
Esempio n. 5
0
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);
}