Ejemplo n.º 1
0
BOOL CTenguEditorApp::InitInstance()
{
	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinAppEx::InitInstance();

	if (!AfxSocketInit())
	{
		AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
		return FALSE;
	}

	// Initialize OLE libraries
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}
	AfxEnableControlContainer();
	// 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
	// Change the registry key under which our settings are stored
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));
	LoadStdProfileSettings(6);  // Load standard INI file options (including MRU)

	InitContextMenuManager();

	InitKeyboardManager();

	InitTooltipManager();
	CMFCToolTipInfo ttParams;
	ttParams.m_bVislManagerTheme = TRUE;
	theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,
		RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views
	CMultiDocTemplate* pDocTemplate;
	pDocTemplate = new CMultiDocTemplate(IDR_TenguEditorTYPE,
		RUNTIME_CLASS(CTenguEditorDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CTenguEditorView));
	if (!pDocTemplate)
		return FALSE;
	pDocTemplate->SetContainerInfo(IDR_TenguEditorTYPE_CNTR_IP);
	AddDocTemplate(pDocTemplate);

	// create main MDI Frame window
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
	{
		delete pMainFrame;
		return FALSE;
	}
	m_pMainWnd = pMainFrame;
	// call DragAcceptFiles only if there's a suffix
	//  In an MDI app, this should occur immediately after setting m_pMainWnd
	// 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);


	// Dispatch commands specified on the command line.  Will return FALSE if
	// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;
	// The main window has been initialized, so show and update it
	pMainFrame->ShowWindow(m_nCmdShow);
	pMainFrame->UpdateWindow();

	return TRUE;
}
Ejemplo n.º 2
0
BOOL CCafeOrangeApp::InitInstance()
{
	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinAppEx::InitInstance();


	// Initialize OLE libraries
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}

	AfxEnableControlContainer();

	EnableTaskbarInteraction();

	// AfxInitRichEdit2() is required to use RichEdit control	
	// AfxInitRichEdit2();

	// 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
	// Change the registry key under which our settings are stored
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization
	SetRegistryKey(_T("CafeOrange"));
	LoadStdProfileSettings(4);  // Load standard INI file options (including MRU)


	InitContextMenuManager();
	InitShellManager();

	InitKeyboardManager();

	InitTooltipManager();
	CMFCToolTipInfo ttParams;
	ttParams.m_bVislManagerTheme = TRUE;
	theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,
		RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views
	CMultiDocTemplate* pImageEditorDocTemplate;
	pImageEditorDocTemplate = new CMultiDocTemplate(IDR_CafeOrangeTYPE,
		RUNTIME_CLASS(CCafeOrangeDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CCafeOrangeView));
	if (!pImageEditorDocTemplate)
		return FALSE;
	AddDocTemplate(pImageEditorDocTemplate);

	CMultiDocTemplate* pOpenCVDocTemplate;
	pOpenCVDocTemplate = new CMultiDocTemplate(IDR_CafeOrangeTYPE,
		RUNTIME_CLASS(CCafeOrangeDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(COpenCVView));
	if (!pOpenCVDocTemplate)
		return FALSE;
	AddDocTemplate(pOpenCVDocTemplate);

	// create main MDI Frame window
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
	{
		delete pMainFrame;
		return FALSE;
	}
	m_pMainWnd = pMainFrame;
	// call DragAcceptFiles only if there's a suffix
	//  In an MDI app, this should occur immediately after setting m_pMainWnd

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
	ParseCommandLine(cmdInfo);

	// Dispatch commands specified on the command line.  Will return FALSE if
	// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;
	// The main window has been initialized, so show and update it
	pMainFrame->ShowWindow(m_nCmdShow);
	//pMainFrame->UpdateWindow();
	
	CDocument* pOpenCVDoc = pOpenCVDocTemplate->OpenDocumentFile(NULL);
	CDocument* pImageEditorDoc = pImageEditorDocTemplate->OpenDocumentFile(NULL);

	pOpenCVDoc->SetTitle("Movie");
	pImageEditorDoc->SetTitle("ImageEditor");

	POSITION OpenCVPosition= pOpenCVDoc->GetFirstViewPosition();
	CView *pOpenCVView = pOpenCVDoc->GetNextView(OpenCVPosition);
	//CMDIChildWndEx* pOpenCVWnd = (CMDIChildWndEx*)pOpenCVView->GetParentFrame();

	POSITION ImageEditorPosition = pImageEditorDoc->GetFirstViewPosition();
	CView *pImageEditorView = pImageEditorDoc->GetNextView(ImageEditorPosition);
	//CMDIChildWndEx* pImageEditorWnd = (CMDIChildWndEx*)pImageEditorView->GetParentFrame();
	
	pMainFrame->InitializeMDIView(pOpenCVView, pImageEditorView);
	pMainFrame->UpdateWindow();


	return TRUE;
}
Ejemplo n.º 3
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
			// 的指针来操作.
*/
		}
	}
}