Exemplo n.º 1
0
/////////////////////////////////////////////////////////////////////////////
// 创建工程接口对象
/////////////////////////////////////////////////////////////////////////////
IProject* CPlugIn::CreateProjectObject(CString strInstName)
{
	IProject* pIProject = (IProject*)(CreateObject(strInstName));
	if(pIProject)
	{
		// 加载扩展菜单
		COWMMenuArray aOWMMenus;
		CXTPCommandBars* pCommandBars = ((CMainFrame*)AfxGetMainWnd())->GetCommandBars();
		CXTPCommandBar* pMenuBar = pCommandBars->GetMenuBar();
		pIProject->RegisterMenu((CMenu*)pMenuBar, aOWMMenus, 40000);
	}

	return pIProject;
}
Exemplo n.º 2
0
/////////////////////////////////////////////////////////////////////////////
// 释放工程接口对象
/////////////////////////////////////////////////////////////////////////////
BOOL CPlugIn::ReleaseProjectObject(LPVOID pVciObj, BOOL bForceDelete)
{
	if(m_strType != "project")
	{
		return FALSE;
	}

	IProject* pIProject = (IProject*)pVciObj;
	if(pIProject)
	{
		COWMMenuArray aOWMMenus;
		aOWMMenus.Add(OWMMENUITEM());
		CXTPCommandBars* pCommandBars = ((CMainFrame*)AfxGetMainWnd())->GetCommandBars();
		CXTPCommandBar* pMenuBar = pCommandBars->GetMenuBar();
		aOWMMenus[0].pProc = (TYPEOF_ClientMenu*)pMenuBar;
		pIProject->UnregisterMenu(aOWMMenus);
	}

	return ReleaseObject(pVciObj, bForceDelete);
}
Exemplo n.º 3
0
/////////////////////////////////////////////////////////////////////////////
// 加载扩展菜单
/////////////////////////////////////////////////////////////////////////////
BOOL CPlugIn::AddOwmSubMenu(CString strMainMenu, CString strSubMenu, CString strAction)
{
	CMainFrame* pMainFrame = (CMainFrame*)(theApp.GetMainWnd());
	CXTPCommandBars* pCommandBars = pMainFrame->GetCommandBars();
	if(!pCommandBars)
	{
		return FALSE;		
	}
	CXTPCommandBar* pMenuBar = pCommandBars->GetMenuBar();
	if(!pMenuBar)
	{
		return FALSE;
	}

	CXTPControls* pControls = pMenuBar->GetControls();
	CXTPControl* pControl = pControls->GetFirst();
	CXTPCommandBar* pMenuBarSub = NULL;
	CXTPControl* pControlExtSub = NULL;
	while(pControl)
	{
		if(pControl->GetCaption() == strMainMenu)
		{
			pMenuBarSub = pControl->GetCommandBar();
			CXTPControls* pControlsSub = pMenuBarSub->GetControls();
			pControl = pControlsSub->GetFirst();
			while(pControl)
			{
				if(pControl->GetCaption() == strSubMenu)
				{
					pControlExtSub = pControl;
					break;
				}
				pControlsSub->GetNext(pControl);
			}			
			break;
		}
		pControls->GetNext(pControl);
	}
	if(pMenuBarSub && !pControlExtSub)
	{
		CExtMenuInfo extMenuInfo;
		extMenuInfo.m_strVciId = m_strId;
		extMenuInfo.m_strMainMenu = strMainMenu;
		extMenuInfo.m_strSubMenu = strSubMenu;
		extMenuInfo.pProc = (TYPEOF_ClientMenu*)OnOwmExtMenuProc;
		extMenuInfo.pUpdateProc = NULL;
		extMenuInfo.nProcType = MENU_PROC_TYPE_PARAM_ID;
		
		int nExMenuId = IDM_OWMCMD+g_nIdOwmExMenu;
		extMenuInfo.m_strAction = strAction;
		extMenuInfo.nId = nExMenuId-IDM_OWMCMD;
		pMainFrame->m_arExtMenuInfo.Add(extMenuInfo);

		CXTPControls* pControlsSub = pMenuBarSub->GetControls();
		CMenu* pMenu = new CMenu();
		pMenu->CreatePopupMenu();
		pMenu->AppendMenu(MF_STRING, nExMenuId, strSubMenu);
		pControlsSub->AddMenuItem(pMenu, 0);
		delete pMenu;

		g_nIdOwmExMenu++;
	}

	return TRUE;
}
Exemplo n.º 4
0
/////////////////////////////////////////////////////////////////////////////
// 关闭一个VCI组件
/////////////////////////////////////////////////////////////////////////////
BOOL CPlugIn::CloseOwm()
{
	if(m_pVciObj == NULL)
	{
		return TRUE;
	}

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

	// 执行Done操作
	if(m_pIVciControl == NULL)
	{
		return FALSE;
	}
	((IVciControl*)m_pIVciControl)->Done(m_strDoneParam);

	// 关闭ControlBar
	if((m_nType & OWM_CONTROLBAR) || (m_nType & OWM_TABCTRLBAR))
		CloseOwmControlBar();

	// 卸载ToolBar
	if(m_nType & OWM_TOOLBAR)
	{
		CMainFrame* pMainFrame = (CMainFrame*)(AfxGetMainWnd());
		//CXTToolBar* pToolBar = &(pMainFrame->m_wndToolBar);
		//pIVciOwm->UnregisterClientToolBar(pToolBar, m_aOWMMenus, IDM_OWMCMD);
		//pMainFrame->ShowControlBar(pToolBar, TRUE, FALSE);
	}

	// 重置TCL扩展命令(没有必要在此处注销,因为TCL只在创建解释器时有效)
	if(m_nType & OWM_TCL)
	{
		// 注销TCL扩展命令
		//if(owminfo.ol.UnregisterTclCmd)
		//	owminfo.ol.UnregisterTclCmd();
	}

	// 卸载扩展菜单命令
	if(m_nType & OWM_MENU)
	{
		COWMMenuArray aOWMMenus;
		aOWMMenus.Add(OWMMENUITEM());
		CXTPCommandBars* pCommandBars = ((CMainFrame*)AfxGetMainWnd())->GetCommandBars();
		CXTPCommandBar* pMenuBar = pCommandBars->GetMenuBar();
		aOWMMenus[0].pProc = (TYPEOF_ClientMenu*)pMenuBar;
		pIVciOwm->UnregisterClientMenu(aOWMMenus);
	}

	// 释放OWM文档模板
	if((m_nType & OWM_DOC) && m_pDocTemplate)
	{
		// 关闭所有OWM文档和窗口
		POSITION pos = m_pDocTemplate->GetFirstDocPosition();
		if(pos != 0)
		{
			m_pDocTemplate->CloseAllDocuments(FALSE);
		}
		// 删除OWM文档模板
		delete m_pDocTemplate;
		m_pDocTemplate = NULL;
	}

	pIVciOwm->Release();

	m_pIVciControl = NULL;
	m_pVciObj = NULL;

	return TRUE;
}
Exemplo n.º 5
0
// 加载OWM类型插件
BOOL CPlugIn::LoadOwmPlugIn()
{
	// 检查进程标识,判断是否可以在本进程加载
	if((m_strProcess != "") && (theApp.m_strProcessId != "") && (m_strProcess != theApp.m_strProcessId))
	{
		return NULL;
	}

	OpenVciLib(IID_IVciOwm);
	m_pVciObj = CreateObject();
	if(m_pVciObj == NULL)
	{
		return FALSE;
	}

	IVciOwm* pIVciOwm = (IVciOwm*)m_pVciObj;

	OWM_INFO owminfo;
	memset(&owminfo, 0, sizeof(OWM_INFO));
	owminfo.bEnable = TRUE;

	pIVciOwm->SetIPlatUI(theApp.GetIPlatUI());

	// 创建文档模板
	if(m_nType & OWM_DOC)
	{
		CRuntimeClass* pDocClass = NULL;
		CRuntimeClass* pFrameClass = NULL;
		CRuntimeClass* pViewClass = NULL;
		pIVciOwm->GetRuntimeClass(1, &pDocClass);
		pIVciOwm->GetRuntimeClass(2, &pFrameClass);
		pIVciOwm->GetRuntimeClass(3, &pViewClass);
		m_pDocTemplate =  new CMultiDocTemplate(
			IDR_BLUEUITYPE,
			pDocClass,
			pFrameClass,
			pViewClass);
		pIVciOwm->SetDocTemplate(m_pDocTemplate);
		// 兼容以前的数据结构
		owminfo.ol.pDocClass = pDocClass;
		owminfo.ol.pFrameClass = pFrameClass;
		owminfo.ol.pViewClass = pViewClass;
		owminfo.ol.pDocTemplate = m_pDocTemplate;
	}

	owminfo.ol.nOWMType		= m_nType;
	owminfo.ol.CommandPlat	= gCommandPlat;
//	owminfo.ol.TraceFmt		= PF_TRACE_FMT;
//	owminfo.ol.CreateOutput	= PF_CREATE_OUTPUT;
//	owminfo.ol.CloseOutput	= PF_CLOSE_OUTPUT;
//	owminfo.ol.OutputSet	= PF_TRACE_SET_ID;
//	owminfo.ol.Output		= PF_TRACE_EX_ID;

	// 设置OWM链接
	pIVciOwm->Command(OC_SETOWMLINK, (WPARAM)(&owminfo.ol), NULL);

	// 加载菜单
	// 注册OWM菜单,添加到弹出菜单上
	// 注:在Xtreme中需要通过MenuBar的GetMenu函数来获取主
	// 菜单的资源,而CJLib中直接通过MainFrame的GetMenu就可以了
	//ol.RegisterClientMenu(m_pMainWnd->GetMenu(), m_aOWMMenus, IDM_OWMCMD, pDoc);
	
	// 加载扩展菜单
	if(AfxGetMainWnd()->GetSafeHwnd() != NULL)
	{
		COWMMenuArray aOWMMenus;
		CXTPCommandBars* pCommandBars = ((CMainFrame*)AfxGetMainWnd())->GetCommandBars();
		CXTPCommandBar* pMenuBar = pCommandBars->GetMenuBar();
		pIVciOwm->RegisterClientMenu((CMenu*)pMenuBar,
						aOWMMenus, 40000, NULL);
	}

	// 加载ToolBar
	if(m_nType & OWM_TOOLBAR)
	{/*
		CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();
		CXTToolBar* pToolBar = &(pMainFrame->m_wndToolBar);
		int nStart = pToolBar->CommandToIndex(ID_VIEW_OUTPUT);

		pIVciOwm->RegisterClientToolBar(pToolBar, m_aOWMMenus, IDM_OWMCMD, nStart);
		pMainFrame->ShowControlBar(pToolBar, TRUE, FALSE);*/
	}

	// 执行OWM的初始化操作
	if(m_pIVciControl == NULL)
	{
		return FALSE;
	}
	((IVciControl*)m_pIVciControl)->Init(m_strInitParam);

	// 创建第一个OWM窗口
	if((m_nType & OWM_DOC) && (m_nType & OWM_AUTOCREATE))
	{
		if((m_nType & OWM_CONTROLBAR) || (m_nType & OWM_TABCTRLBAR))
			//&& owminfo.ol.pCtrlBarClass)
			NewOwmControlBar();
		else
			NewOwmFrame(m_strInitParam);
	}

	return TRUE;
}
BOOL CXTPCustomizeMenusPage::OnInitDialog()
{
	CXTPPropertyPage::OnInitDialog();

	CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars();

	CString strDefaultMenu;
	GetDlgItemText(XTP_IDC_STATIC_DESCRIPTION, strDefaultMenu);

	if (_tcschr(strDefaultMenu, _T('\n')) != NULL)
	{
		AfxExtractSubString(m_strDefaultMenuDesc, strDefaultMenu, 1);
		AfxExtractSubString(m_strDefaultMenu, strDefaultMenu, 0);
	}
	else
	{
		m_strDefaultMenu = m_strDefaultMenuDesc = strDefaultMenu;
	}

	int nIndex = m_cmbAppMenus.AddString(m_strDefaultMenu);
	m_cmbAppMenus.SetItemData(nIndex, 0);
	int nCurSel = 0;

	if (pCommandBars->GetMenuBar() && ((pCommandBars->GetMenuBar()->GetFlags() & xtpFlagIgnoreSetMenuMessage) == 0))
	{
		CXTPMenuBar* pMenuBar = pCommandBars->GetMenuBar();
		CXTPMenuBarMDIMenus* pMDIControls = pMenuBar->GetMDIMenus();

		POSITION pos = pMDIControls->GetStartPosition();
		CXTPMenuBarMDIMenuInfo* pInfo;
		while (pos)
		{
			pMDIControls->GetNextMenu(pos, pInfo);
			if (pInfo->m_nIDResource == pMenuBar->GetDefaultMenuResource())
				continue;

			if (!pInfo->m_strTitle.IsEmpty())
			{
				nIndex = m_cmbAppMenus.AddString(pInfo->m_strTitle);
				m_cmbAppMenus.SetItemData(nIndex, (DWORD_PTR)pInfo);

				if (pInfo->m_nIDResource == pMenuBar->GetCurrentMenuResource())
				{
					nCurSel = nIndex;
				}
			}
		}
	}

	m_cmbAppMenus.SetCurSel(nCurSel);
	OnSelectionChangedAppmenus();

	nIndex = m_cmbContextMenus.AddString(_T(""));
	m_cmbContextMenus.SetItemData(nIndex, 0);

	for (int i = 0; i < pCommandBars->GetContextMenus()->GetCount(); i++)
	{
		CXTPPopupBar* pPopupBar = (CXTPPopupBar*)pCommandBars->GetContextMenus()->GetAt(i);

		nIndex = m_cmbContextMenus.AddString(pPopupBar->GetTitle());
		m_cmbContextMenus.SetItemData(nIndex, (DWORD_PTR)pPopupBar);
	}
	m_cmbContextMenus.SetCurSel(0);
	OnSelectionChangedContextmenus();


	SetResize(XTP_IDC_STATIC_APPLICATIONMENUS, XTP_ANCHOR_TOPLEFT, XTP_ANCHOR_TOPRIGHT);
	SetResize(XTP_IDC_STATIC_CONTEXTMENUS, XTP_ANCHOR_TOPLEFT, XTP_ANCHOR_TOPRIGHT);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}