Ejemplo n.º 1
0
/////////////////////////////////////////////////////////////////////////////
// 显示OWM(View形式)
/////////////////////////////////////////////////////////////////////////////
BOOL CPlugIn::ShowOwmView(BOOL bShow, BOOL bActive)
{
	if(m_pVciObj == NULL)
	{
		return FALSE;
	}

	IVciOwm* pIVciOwm = (IVciOwm*)m_pVciObj;
	CMultiDocTemplate* pDocTemplate = NULL;
	pIVciOwm->GetDocTemplate(&pDocTemplate);

	if(pDocTemplate == NULL)
	{
		return FALSE;
	}

	POSITION posdoc = pDocTemplate->GetFirstDocPosition();
	if(!bShow)
	{
		if(posdoc)
		{
			CloseOwmFrame();
		}
		return TRUE;
	}

	if(!posdoc)
	{
		NewOwmFrame();
	}
	if(bActive)
	{
		POSITION posdoc = pDocTemplate->GetFirstDocPosition();
		if(posdoc)
		{
			CDocument* pDoc = pDocTemplate->GetNextDoc(posdoc);
			POSITION posview = pDoc->GetFirstViewPosition();
			if(posview)	// 如果视存在
			{
				CView* pOwmView = pDoc->GetNextView(posview);	// 取到视指针
				pOwmView->GetParentFrame()->ActivateFrame(); // 激活框架
				return TRUE;
			}
		}
	}

	return FALSE;
}
Ejemplo n.º 2
0
// 在 Frame中发消息给View 
U32 CPluginApp_i::SendMessageToView(UINT ulMsg, WPARAM wParam, LPARAM lParam) 
{
  CWinApp* pWinApp = AfxGetApp();
  if(pWinApp)
  {
    POSITION DocTemplatePos = pWinApp->GetFirstDocTemplatePosition();
  
    //while(DocTemplatePos)
    {
	    CMultiDocTemplate* pDocTemp = (CMultiDocTemplate*)pWinApp->GetNextDocTemplate(DocTemplatePos);
    
      //  
 	    POSITION pos = pDocTemp->GetFirstDocPosition ();
  
      // Find the doc within the same doctemplate.
      while (pos)
      {
	      CDocument* pDoc     = pDocTemp->GetNextDoc (pos);
	      POSITION ViewPos    = pDoc->GetFirstViewPosition ();
	      CView* pView        = pDoc->GetNextView (ViewPos);
        if(pView)
        {
          CMDIChildWnd* pFrame = (CMDIChildWnd*)pView->GetParentFrame();
          if(pFrame == this)
          {
            //OutputDebugString("Find!\n");
            pView->SendMessage(ulMsg, wParam, lParam);
          } 
        }
      }
    }
  }
  
  return 0;
}
Ejemplo n.º 3
0
//************************************
// Method:    OnHisMatching
// FullName:  CImgView::OnHisMatching
// Access:    protected 
// Returns:   void
// Qualifier:
//************************************
void CImgView::OnHisMatching() 
{
	// TODO: Add your command handler code here	
	procStatus eRetCode = eNormal;
	CMultiDocTemplate* pDocTemplate = ((CImgApp*)AfxGetApp())->m_pDocTemplate;
	ImgSrcList imgList;
	
	POSITION curDocPos = pDocTemplate->GetFirstDocPosition();
	
	while(curDocPos != NULL)
	{
		CImgDoc* curDoc  =	(CImgDoc*)pDocTemplate->GetNextDoc(curDocPos);
		CImgSource* imgSrc = curDoc->GetSource();
		if (imgSrc->GetType() >= eSrcMonoBitmap)
		{
			imgList.Add(imgSrc);
		}		
	}

	CMatchingDlg oDlg;
	oDlg.m_pImgList = &imgList;
	INT nRes = oDlg.DoModal();

	if(nRes == IDOK)
	{
		CImgSource* pImgSelected = imgList.GetAt(oDlg.m_nSelected);
		
		CHistogram oHis;
		eRetCode = pImgSelected->GetHistoram(oHis);
		
		if(eRetCode == eNormal)
		{
			CPHEMatcher oMatcher(&oHis);
			eRetCode = process(&oMatcher);
			if(eRetCode != eNormal)
			{
				AfxMessageBox(CUtility::MessageTranslate(eRetCode));
			}
		}	
	}	
}
Ejemplo n.º 4
0
void 	SaveAllDocs()

{
	CWedDoc*  pDoc = NULL;
    CMultiDocTemplate* pDocTemplate =
				((CWedApp*)AfxGetApp())->pDocTemplate;
	POSITION Pos = 	pDocTemplate->GetFirstDocPosition();
	for(;;)
		{
		if(!Pos)
			break;
		CWedDoc* doc = (CWedDoc*)pDocTemplate->GetNextDoc(Pos);

		if(!doc)
			continue;

		ASSERT_VALID(doc);

		if(doc->IsModified())
			doc->OnSaveDocument(doc->GetPathName());
		}
}
Ejemplo n.º 5
0
/////////////////////////////////////////////////////////////////////////////
// 新建OWM对象窗口(for Xtreme)
/////////////////////////////////////////////////////////////////////////////
void CPlugIn::NewOwmFrame(LPCTSTR lpszPath)
{
	if(m_pVciObj == NULL)
	{
		return;
	}

	IVciOwm* pIVciOwm = (IVciOwm*)m_pVciObj;
	CMultiDocTemplate* pDocTemplate = NULL;
	pIVciOwm->GetDocTemplate(&pDocTemplate);

	if((m_nType & OWM_DOC) && pDocTemplate)
	{
		// 如果只允许一个实例,则做相应处理
		if((m_nType & OWM_ONEFRAME) &&
			(pDocTemplate->GetFirstDocPosition()))
			return;

		// 打开一个空OWM文档
		//if(!pDocTemplate->OpenDocumentFile(lpszPath))
		if(!pDocTemplate->OpenDocumentFile(NULL))
		{
			return;
		}

		// 创建OWM扩展菜单
		if(m_nType & OWM_MENU)
		{
			// 取到文档指针,用来将扩展菜单指针纪录在文档中,文档关闭时清除
			POSITION pos = pDocTemplate->GetFirstDocPosition();
			CDocument* pDoc = pDocTemplate->GetNextDoc(pos);
			POSITION posview = pDoc->GetFirstViewPosition();
			if(posview)	// 如果视存在
			{
				CView* pView = pDoc->GetNextView(posview);	// 取到视指针
				//pView->GetParentFrame()->ActivateFrame(); // 激活框架
				if(m_nType & OWM_MAXWINDOW)
				{
					// 将窗口最大化
					pView->GetParentFrame()->ShowWindow(SW_SHOWMAXIMIZED);
				}
			}
/*
			// 注册OWM菜单,添加到弹出菜单上
			// 注:在Xtreme中需要通过MenuBar的GetMenu函数来获取主
			// 菜单的资源,而CJLib中直接通过MainFrame的GetMenu就可以了
			//ol.RegisterClientMenu(m_pMainWnd->GetMenu(), m_aOWMMenus, IDM_OWMCMD, pDoc);
			CXTMenuBar* pMenuBar = ((CMainFrame*)AfxGetMainWnd())->GetMenuBar();
			pIVciOwm->RegisterClientMenu(pMenuBar->GetMenu(),
							m_aOWMMenus, IDM_OWMCMD, pDoc);

			// 刷新菜单条
			// 注:在CJLib中用DrawMenuBar就可以了,在Xtreme中必须用
			// DrawMenuBarX来刷新Xtreme中的MenuBar和Menu资源的关联
			((CMainFrame*)AfxGetMainWnd())->DrawMenuBarX();

			// 注:关于OWM针对Xtreme toolkit的改动
			// Xtreme和CJLibrary的区别比较大,Cool菜单改为统一管理,
			// 通过CXTCoolMenu类来管理,此类可以加载许多图标资源,然后
			// 安装到一个窗口上,安装以后,用户不用再针对菜单做特殊处理
			// 就可以使用Cool菜单了.而以前的CJLib使用CoolMenu的方法是
			// 每个菜单单独加载图标资源.
			// 因此,在OWM中要想实现扩展菜单使用自己的图标资源,必须做
			// 一些特殊处理,因为OWM和主程序必须使用同一个CXTCoolMenu,
			// 这样是很容易造成资源冲突问题的,并且也不能通过资源切换
			// 来解决,那么唯一的办法就是保证OWM中需要添加到主程序的菜
			// 单和主程序中的菜单的资源ID不重合,因此规定OWM中需要扩展
			// 的资源ID必须在10000到20000范围内,其中10000-11999为系统
			// OWM保留,用户自己写的必须从12000开始.
			// 为了保证OWM接口的兼容性,因此对接口定义不做任何改动,在
			// OWM的RegisterClientMenu函数中要想注册自己的图标资源,
			// 可以通过获取MainFrame指针,然后通过MainFrame找到CXTCoolMenu
			// 的指针来操作.
*/
		}
	}
}
Ejemplo n.º 6
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;
}