Beispiel #1
0
CDocument* CReportManager::OpenForm(CString csName,BOOL bVisible)
{
	if(!AfxGetMainWnd())
		return 0;

	POSITION pos=GetFirstDocTemplatePosition();
	CString csFind=mUpper(csName);
	CDocTemplate* pTemplate=NULL;
	BOOL bFind=FALSE;
	for(int i=0;i<aDescription.GetSize();i++)
	{
		pTemplate=GetNextDocTemplate(pos);

		CString csCurName=aDescription[i].csName;
		if(csFind==mUpper(csCurName))
		{
			bFind=TRUE;
			break;
		}
	}
	if(bFind)
	{
		if(pTemplate)
		{
			CDocument* pDoc=pTemplate->OpenDocumentFile(NULL,bVisible);
			((CEnterpriseApp*)AfxGetApp())->DeleteConfigName();
			return pDoc;
		}
	}
	return NULL;
}
Beispiel #2
0
//----------------------------------------------------------------------------
// GetCharTemplate returns template for document that will be shown in 
// character view at its first appearance
//----------------------------------------------------------------------------
CDocTemplate* CippsDemoApp::GetCharTemplate()
{
   POSITION pos = GetFirstDocTemplatePosition( );
   GetNextDocTemplate(pos);
   GetNextDocTemplate(pos);
   return GetNextDocTemplate(pos);
}
Beispiel #3
0
HRESULT CDxtexApp::RestoreDeviceObjects(VOID)
{
    // Tell each view of each doc to restore
    POSITION pos = GetFirstDocTemplatePosition();
    CDocTemplate* pDocTemplate = GetNextDocTemplate( pos );

    pos = pDocTemplate->GetFirstDocPosition();
    for( ; ; )
    {
        CDocument* pDoc = NULL;
        if( pos == NULL )
            break;
        pDoc = pDocTemplate->GetNextDoc( pos );
        if( pDoc == NULL )
            break;
        POSITION posView;
        CDxtexView* pView = NULL;
        posView = pDoc->GetFirstViewPosition();
        for( ; ; )
        {
            if( posView == NULL )
                break;
            pView = (CDxtexView*)pDoc->GetNextView( posView );
            if( pView == NULL )
                break;
            pView->RestoreDeviceObjects();
        }
    }
    return S_OK;
}
Beispiel #4
0
//----------------------------------------------------------------------------
// OpenNewDoc opens new user customized document.
// If newView == VIEW_DEMO then document will be created with signal default
// parameters and will be shown in graphic view;
// if newView == NEW_TEXT then document will be created with digital default
// parameters and will be shown in digital view
// if newView == VIEW_CHAR then document will be created with character default
// parameters and will be shown in character view
//----------------------------------------------------------------------------
void CippsDemoApp::OpenNewDoc(int newView)
{
   POSITION tPos = GetFirstDocTemplatePosition( );
   CDocTemplate* pTpl;
   for (int i=0; i<=newView; i++)
      pTpl = GetNextDocTemplate(tPos);
   ASSERT(pTpl);
   CippsDemoDoc* pDoc = (CippsDemoDoc*)pTpl->OpenDocumentFile(NULL);
   if (pDoc)
      pDoc->InitHisto();
}
void CImportExportApp::OnFileOpen() 
{
  CFileDialog dlg(TRUE,
				  NULL,
				  NULL,
				  OFN_HIDEREADONLY | OFN_FILEMUSTEXIST,
				  NULL, 
				  NULL );
  

	CString initdir(((OCC_BaseApp*) AfxGetApp())->GetInitDataDir());
	initdir += "\\Data";

	dlg.m_ofn.lpstrInitialDir = initdir;

	CString strFilter;
	CString strDefault;

	POSITION pos = GetFirstDocTemplatePosition();

	CDocTemplate* pTemplate = GetNextDocTemplate(pos);
	CString strFilterExt, strFilterName;
	if (pTemplate->GetDocString(strFilterExt, CDocTemplate::filterExt) &&
		!strFilterExt.IsEmpty() &&
		pTemplate->GetDocString(strFilterName, CDocTemplate::filterName) &&
		!strFilterName.IsEmpty()) {
		// add to filter
		strFilter += strFilterName;
		ASSERT(!strFilter.IsEmpty());  // must have a file type name
		strFilter += (TCHAR)'\0';  // next string please
		strFilter += (TCHAR)'*';
		strFilter += strFilterExt;
		strFilter += (TCHAR)'\0';  // next string please
		dlg.m_ofn.nMaxCustFilter++;		
	}
	// append the "*.*" all files filter
	CString allFilter;
	VERIFY(allFilter.LoadString(AFX_IDS_ALLFILTER));
	strFilter += allFilter;
	strFilter += (TCHAR)'\0';   // next string please
	strFilter += _T("*.*");
	strFilter += (TCHAR)'\0';   // last string
	dlg.m_ofn.nMaxCustFilter++;
	dlg.m_ofn.lpstrFilter = strFilter;

  if (dlg.DoModal() == IDOK) 
  {
	AfxGetApp()->OpenDocumentFile(dlg.GetPathName());
  }	
}
CSampleDoc* CIppsSampleApp::CreateNewDoc(int len, ppType type, BOOL bMakeVisible)
{
    int lenSave = m_NewLen;
    ppType typeSave = m_NewType;
    m_NewLen = len;
    m_NewType = type;

    POSITION pos = GetFirstDocTemplatePosition();
    CDocTemplate* pTpl = GetNextDocTemplate(pos);
    CSampleDoc* pDoc = (CSampleDoc*)pTpl->OpenDocumentFile(NULL,bMakeVisible);

    m_NewLen = lenSave;
    m_NewType = typeSave;
    return pDoc;
}
Beispiel #7
0
void CDocManager::OnFileNew()
/***************************/
{
    POSITION position = GetFirstDocTemplatePosition();
    if( position != NULL ) {
        CDocTemplate *pTemplate = GetNextDocTemplate( position );
        ASSERT( pTemplate != NULL );
        if( position == NULL ) {
            pTemplate->OpenDocumentFile( NULL );
        } else {
            CFileNewDialog dlg( this );
            if( dlg.DoModal() == IDOK ) {
                ASSERT( dlg.m_pDocTemplate != NULL );
                dlg.m_pDocTemplate->OpenDocumentFile( NULL );
            }
        }
    }
}
Beispiel #8
0
BOOL CWinApp::Unregister()
{
	HKEY    hKey = 0;
	TCHAR   szBuf[MAX_PATH+1];
	LONG    cSize;
	BOOL    bRet = TRUE;

	POSITION pos = GetFirstDocTemplatePosition();
	while (pos != NULL)
	{
		CDocTemplate* pTempl = GetNextDocTemplate(pos);
		if (pTempl != NULL)
			pTempl->OnCmdMsg(0, CN_OLE_UNREGISTER, NULL, NULL);
	}

	// Remove profile information -- the registry entries exist if
	// SetRegistryKey() was used.

	if (m_pszRegistryKey)
	{
		ASSERT(m_pszProfileName);

		CString strKey = _T("Software\\");
		strKey += m_pszRegistryKey;
		CString strSubKey = strKey + _T("\\") + m_pszProfileName;

		DelRegTree(HKEY_CURRENT_USER, strSubKey);

		// If registry key is empty then remove it

		DWORD   dwResult;
		if ((dwResult = ::RegOpenKey(HKEY_CURRENT_USER, strKey, &hKey)) ==
			ERROR_SUCCESS)
		{
			if (::RegEnumKey(hKey, 0, szBuf, _MAX_PATH) == ERROR_NO_MORE_ITEMS)
				DelRegTree(HKEY_CURRENT_USER, strKey);
			::RegCloseKey(hKey);
		}
		if (RegQueryValue(HKEY_CURRENT_USER, strSubKey, szBuf, &cSize) == ERROR_SUCCESS)
			bRet = TRUE;
	}
	return bRet;
}
Beispiel #9
0
void CReportManager::OnFileNew()
{
	CChooseValue dlg;
	CArray <CDocTemplate*,CDocTemplate*> listTemlate;
	POSITION pos=GetFirstDocTemplatePosition();
	for(int i=0;i<aDescription.GetSize();i++)
	{
		CDocTemplate* pTemplate=GetNextDocTemplate(pos);
		if(aDescription[i].bCanVisible)
		{
			dlg.List.Add(aDescription[i].csDescription);
			dlg.ListImage.Add(aDescription[i].nImage);
			listTemlate.Add(pTemplate);
		}
	}

	dlg.nStart=0;
	dlg.csTitle=csTitle;
	dlg.nMode=0;
	if(bSmall)
		dlg.Small();

	int nResponse = IDOK;
	int nIndex=0;
	if(dlg.List.GetSize()>1)
	{
		nResponse = dlg.DoModal();
		nIndex=dlg.nRes;
	}
	if (nResponse == IDOK)
	{
		if(listTemlate.GetSize()>0)
		if(listTemlate[nIndex])
			listTemlate[nIndex]->OpenDocumentFile(NULL);
	}
}
Beispiel #10
0
CImconDoc * CImconApp::NewImage(HANDLE hDib)
{
  if (!hDib)
    return NULL;

  POSITION Position = GetFirstDocTemplatePosition();
  CImconDoc *pDoc = (CImconDoc *) GetNextDocTemplate(Position)->OpenDocumentFile(NULL);
  if (pDoc)
    {
     pDoc->m_Dib.SetHandle(hDib);
     pDoc->SetProperties();
     pDoc->m_strFormat = "Bitmap"; 
     ((CMainFrame *) AfxGetMainWnd())->SetImageSize(pDoc->m_uWidth,
                                                    pDoc->m_uHeight,
                                                    pDoc->m_uBPP);
     ((CMainFrame *) AfxGetMainWnd())->SetImageFormat((LPCSTR) pDoc->m_strFormat);

     POSITION pos = pDoc->GetFirstViewPosition();
     CView* pFirstView = pDoc->GetNextView(pos);
     pFirstView->OnInitialUpdate();
    }

  return pDoc;
}
CDocument* CWinHTTrackApp::OpenDocumentFile( LPCTSTR lpszFileName)
{
  // Eviter deux fenêtres (un seul document)
  // Le CMultui..->CSingleDoc.. est trop complexe à changer (à cause du splitter-wnd)
  int count=1;

  { /* Check if a document exists, and if exists if empty or not, and if name is different */
    POSITION pos;
    pos=GetFirstDocTemplatePosition();
    if (pos) {
      CDocTemplate* tmpl=GetNextDocTemplate(pos);
      if (tmpl) {
        pos=tmpl->GetFirstDocPosition();
        if (pos) {
          CDocument* doc  = tmpl->GetNextDoc(pos);
          if (doc) {
            if (dialog0->GetName().GetLength()==0) {
              CloseAllDocuments(FALSE);
              count=0;        /* No documents */
            } else {
              if (dialog0->GetPath0()+".whtt" == LPCSTR(lpszFileName))
                return NULL;
            }
          }
        } else
          count=0;          /* No documents */
      }
    }
  }

  // Ouvrir nouvelle instance
  if (count) {
    char cmdl[2048];
    TCHAR ModulePath[MAX_PATH + 1];
    ModulePath[0] = '\0';
    ::GetModuleFileName(NULL, ModulePath, sizeof(ModulePath)/sizeof(TCHAR) - 1);
    CString name = ModulePath;
    strcpybuff(cmdl,"\"");
    strcatbuff(cmdl,lpszFileName);
    strcatbuff(cmdl,"\"");
    ShellExecute(NULL,"open",name,cmdl,"",SW_RESTORE);
    return NULL;
  }

  // Ouvrir nouveau?
  //if (count)
  //  return;       // ne rien faire, car limité à 1 document
  //count++;

  /* Ouvrir */
  /*
  CWinApp* app=AfxGetApp();
  POSITION pos;
  pos=app->GetFirstDocTemplatePosition();
  CDocTemplate* templ = app->GetNextDocTemplate(pos);
  pos=templ->GetFirstDocPosition();
  if (pos) {
    CDocument* doc  = templ->GetNextDoc(pos);
    if (doc)
      if (!doc->SaveModified())
        return NULL;
  }
  CloseAllDocuments(FALSE);
  */
  if (strlen(lpszFileName))
    return CWinApp::OpenDocumentFile(lpszFileName);
  else
    CWinApp::OnFileNew();
  return NULL;
}
Beispiel #12
0
BOOL CDxtexApp::InitInstance()
{
    // Change the registry key under which our settings are stored.
    SetRegistryKey(_T("Microsoft"));

    LoadStdProfileSettings();  // Load standard INI file options (including MRU)

    // Register the application's document templates.  Document templates
    //  serve as the connection between documents, frame windows and views.

    m_pDocManager = new CDxtexDocManager;
    
    CMultiDocTemplate* pDocTemplate;
    pDocTemplate = new CMultiDocTemplate(
        IDR_DXTXTYPE,
        RUNTIME_CLASS(CDxtexDoc),
        RUNTIME_CLASS(CChildFrame), // custom MDI child frame
        RUNTIME_CLASS(CDxtexView));
    AddDocTemplate(pDocTemplate);

    // Register file types with Explorer
    //RegisterShellFileTypes();
    //EnableShellOpen();

    // create main MDI Frame window
    CMainFrame* pMainFrame = new CMainFrame;
    if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
        return FALSE;
    m_pMainWnd = pMainFrame;

    // Initialize DirectDraw
    m_pd3d = Direct3DCreate9(D3D_SDK_VERSION);
    if (m_pd3d == NULL)
    {
        AfxMessageBox(ID_ERROR_D3DCREATEFAILED, MB_OK, 0);
        return FALSE;
    }

    HRESULT hr;
    D3DPRESENT_PARAMETERS presentParams;
    D3DDEVTYPE devType;

    ZeroMemory(&presentParams, sizeof(presentParams));
    presentParams.Windowed = TRUE;
    presentParams.SwapEffect = D3DSWAPEFFECT_COPY;
    presentParams.BackBufferWidth = 8;
    presentParams.BackBufferHeight = 8;
    presentParams.BackBufferFormat = D3DFMT_UNKNOWN;

    devType = D3DDEVTYPE_REF; 

    hr = m_pd3d->CreateDevice(D3DADAPTER_DEFAULT, devType, m_pMainWnd->GetSafeHwnd(), 
        D3DCREATE_SOFTWARE_VERTEXPROCESSING, &presentParams, &m_pd3ddev);
    if (FAILED(hr))
    {
        AfxMessageBox(ID_ERROR_CANTCREATEDEVICE);
        return FALSE;
    }

    D3DCAPS9 Caps;
    m_pd3ddev->GetDeviceCaps(&Caps);
    if (Caps.PrimitiveMiscCaps & D3DPMISCCAPS_NULLREFERENCE)
    {
        AfxMessageBox(ID_ERROR_NULLREF);
    }

    // Parse command line for standard shell commands, DDE, file open
    CDxtexCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);
    // Prevent automatic "New" at startup:
    if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew)
        cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;

    // Dispatch commands specified on the command line
    if (!ProcessShellCommand(cmdInfo))
        return FALSE;

    // Enable open by dragging files
    m_pMainWnd->DragAcceptFiles();

    // See if we loaded a document
    POSITION posTemp = GetFirstDocTemplatePosition();
    CDxtexDoc* pdoc = NULL;
    POSITION pos = pDocTemplate->GetFirstDocPosition();
    if (pos != NULL)
        pdoc = (CDxtexDoc*)pDocTemplate->GetNextDoc(pos);

    if (!cmdInfo.m_strFileNameAlpha.IsEmpty())
    {
        if (pdoc != NULL)
        {
            pdoc->LoadAlphaBmp(cmdInfo.m_strFileNameAlpha);
        }
    }
    if (cmdInfo.m_bMipMap)
    {
        if (pdoc != NULL)
        {
            pdoc->GenerateMipMaps();
        }
    }
    if (cmdInfo.m_fmt != 0)
    {
        if (pdoc != NULL)
        {
            pdoc->Compress(cmdInfo.m_fmt, TRUE);
        }
    }
    if (!cmdInfo.m_strFileNameSave.IsEmpty())
    {
        if (pdoc != NULL)
        {
            pdoc->OnSaveDocument(cmdInfo.m_strFileNameSave);
        }
        return FALSE; // Prevent UI from coming up
    }

    // The main window has been initialized, so show and update it.
    pMainFrame->ShowWindow(m_nCmdShow);
    pMainFrame->UpdateWindow();

    return TRUE;
}
Beispiel #13
0
void CWinAppSingle::RegisterShellFileTypesEx( BOOL bCompat   /*FALSE*/, 
										  BOOL bRegister /*TRUE*/ )
{
	// Register all application document types:

	if( bRegister == TRUE )
		CWinApp::RegisterShellFileTypes( bCompat );
		
	// Now register SDI document dde open.
	// Loop through the document templates:

	POSITION pos = GetFirstDocTemplatePosition();
	while( pos != NULL )
	{		
		CString strFileTypeId( _T("") );
		CDocTemplate* pTemplate = GetNextDocTemplate( pos );

		if( pTemplate->GetDocString( strFileTypeId,
		    CDocTemplate::regFileTypeId ) && !strFileTypeId.IsEmpty() )
		{
			// CDocTemplate::windowTitle is present only in the document template 
			// for SDI applications. So, we detected SDI application and should 
			// overregister shell file types :
			
			CString strTemp( _T("") );
			if ( pTemplate->GetDocString( strTemp, CDocTemplate::windowTitle ) &&
				 !strTemp.IsEmpty() )
			{
				// path\shell\open\ddeexec = [open("%1")]
				strTemp.Format( _T( "%s\\shell\\open\\%s" ), (LPCTSTR)strFileTypeId, _T( "ddeexec" ) );
				
				#if ( _MFC_VER >= 0x0700 )
					CRegKey reg( HKEY_CLASSES_ROOT );
				#else
					CRegKey reg;
					reg.Attach( HKEY_CLASSES_ROOT );
				#endif

				if( bRegister )
				{				
					if( reg.SetKeyValue( strTemp, _T( "[open(\"%1\")]" ) ) == ERROR_SUCCESS )
					{
						strTemp += _T( "\\Application" );

						OSVERSIONINFO osvi = { 0 };
						osvi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
						::GetVersionEx( & osvi );

						if( !( osvi.dwPlatformId == VER_PLATFORM_WIN32_NT &&
							   osvi.dwMajorVersion == 5 && 
							   osvi.dwMinorVersion >= 1 ) )
						{
							reg.SetKeyValue( strTemp, AfxGetAppName() );
						}
						else
							reg.DeleteSubKey( strTemp );
					}
				}
				else // Unregister 'ddeexec' registry entry:
					reg.RecurseDeleteKey( strTemp );
				
				#if ( _MFC_VER >= 0x0700 )
					reg.Flush();
				#else
					::RegFlushKey( reg );
				#endif
				reg.Close(); 
			}
		}
	}

	// Unregister all application document types:

	if( bRegister == FALSE )
		CWinApp::UnregisterShellFileTypes();
}
Beispiel #14
0
BOOL CSampleApp::InitInstance()
{
	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

	// initialized OLE 2.0 libraries
	if (!AfxOleInit())
	{
		AfxMessageBox(IDS_OLE_INIT_FAILED);
		return FALSE;
	}

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	// Change the registry key under which our settings are stored.
	// You should modify this string to be something appropriate
	// such as the name of your company or organization.
	SetRegistryKey(_T("RenderSoft TextCalc"));

	LoadStdProfileSettings(10);  // Load standard INI file options (including MRU)

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	CMultiDocTemplate* pDocTemplate;
	pDocTemplate = new CMultiDocTemplate(
		IDR_SAMPLETYPE,
		RUNTIME_CLASS(CSampleDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CSampleView));
	AddDocTemplate(pDocTemplate);

	// create main MDI Frame window
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
		return FALSE;
	m_pMainWnd = pMainFrame;

	// Enable drag/drop open
	m_pMainWnd->DragAcceptFiles();

	// Enable DDE Execute open
//	EnableShellOpen();
//	RegisterShellFileTypes(TRUE);

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	/*
	//if (cmdInfo!=NULL) 
		if (cmdInfo.m_strFileName!=NULL) 
			if (cmdInfo.m_strFileName!="") 
			*/

	if (cmdInfo.m_nShellCommand==CCommandLineInfo::FileOpen)
			m_nCmdShow=SW_SHOWMAXIMIZED;

	// Dispatch commands specified on the command line
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	// The main window has been initialized, so show and update it.
	pMainFrame->ShowWindow(m_nCmdShow);
	//pMainFrame->ShowWindow(SW_SHOWMAXIMIZED);
	pMainFrame->UpdateWindow();


	if (IsFirstLoad()) {

		int rt=MessageBox(NULL,"This is the first time you are running TextCalc.\n\nDo you want to load the help file?", "Invoke Help?", MB_YESNO | MB_ICONQUESTION);
		
		CString px=GetProgPath();
		CString filex=px+"\\"+"progdata.nfo";
		
		FILE *fp;
		fp=fopen(filex,"w");
		if (fp!=NULL)  {
			fprintf(fp,"<Not first load> = true");
			if (fp!=NULL) fclose(fp);
		}

		if (rt==IDNO) return TRUE;

		POSITION x=GetFirstDocTemplatePosition( );
		if (x==NULL) return TRUE;
		
		CDocTemplate* tp=GetNextDocTemplate(x);
		CSampleDoc* doc=NULL;
		if (tp!=NULL) {
				
			POSITION z=tp->GetFirstDocPosition( ); 
			
			if (z!=NULL)
				doc=(CSampleDoc* ) tp->GetNextDoc(z);

		}

		CSampleView * dview=NULL;
		if (doc!=NULL) {
			
			POSITION y=doc->GetFirstViewPosition(); 
			if (y!=NULL)
				dview=(CSampleView *) doc->GetNextView(y); 
		
			if (dview!=NULL) {
				dview->insertFile("Help.txt",101);

				pMainFrame->ShowWindow(SW_SHOWMAXIMIZED);
				//pMainFrame->UpdateWindow();

			}

		}
		

	}

	return TRUE;
}