⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dsofauto.cpp

📁 主要用于打开office文档而使用. ole开发,
💻 CPP
📖 第 1 页 / 共 4 页
字号:

////////////////////////////////////////////////////////////////////////
// CDsoFramerControl::(put_Toolbars/get_Toolbars)
//
//  True/False. Should we display toolbars or not?
//
STDMETHODIMP CDsoFramerControl::put_Toolbars(VARIANT_BOOL vbool)
{
	TRACE1("CDsoFramerControl::put_Toolbars(%d)\n", vbool);

 // If the control is in modal state, we can't do things that
 // will call the server directly, like toggle toolbars...
    if ((m_fModalState) || (m_fNoInteractive))
        return ProvideErrorInfo(DSO_E_INMODALSTATE);

	if (m_fShowToolbars != (WORD)(BOOL)vbool)
	{
		m_fShowToolbars = (BOOL)vbool;
		m_fDirty = TRUE;

		if (m_pDocObjFrame)
			m_pDocObjFrame->OnNotifyChangeToolState(m_fShowToolbars);

		ViewChanged();
        OnResize();
	}
	return S_OK;
}

STDMETHODIMP CDsoFramerControl::get_Toolbars(VARIANT_BOOL* pbool)
{
	ODS("CDsoFramerControl::get_Toolbars\n");
	if (pbool) *pbool = (m_fShowToolbars ? VARIANT_TRUE : VARIANT_FALSE);
	return S_OK;
}


////////////////////////////////////////////////////////////////////////
// CDsoFramerControl::(put_ModalState/get_ModalState)
//
//  True/False. Disables the active object (if any) thereby setting it 
//  up to behave "modal". Any time a dialog or other blocking window 
//  on the same thread is called, the developer should set this to True
//  to let the IP object know it should stay modal in the background. 
//  Set it back to False when the dialog is removed.
//
//  Technically, this should be a counter to allow for nested modal states.
//  However, we thought that might be confusing to some VB/Web developers
//  and since this is only a sample, made it a Boolean property.
//
STDMETHODIMP CDsoFramerControl::put_ModalState(VARIANT_BOOL vbool)
{
	TRACE1("CDsoFramerControl::put_ModalState(%d)\n", vbool);

 // you can't force modal state change unless active...
    if ((m_fNoInteractive) || (!m_fComponentActive))
        return ProvideErrorInfo(E_ACCESSDENIED);

	if (m_fModalState != (WORD)(BOOL)vbool)
		UpdateModalState((vbool != VARIANT_FALSE), TRUE);

	return S_OK;
}

STDMETHODIMP CDsoFramerControl::get_ModalState(VARIANT_BOOL* pbool)
{
	ODS("CDsoFramerControl::get_ModalState\n");
	if (pbool) *pbool = ((m_fModalState) ? VARIANT_TRUE : VARIANT_FALSE);
	return S_OK;
}


////////////////////////////////////////////////////////////////////////
// CDsoFramerControl::ShowDialog
//
//  Uses IOleCommandTarget to get the embedded object to display one of
//  these standard dialogs for the user.
//
STDMETHODIMP CDsoFramerControl::ShowDialog(dsoShowDialogType DlgType)
{
	HRESULT hr = E_ACCESSDENIED;

	TRACE1("CDsoFramerControl::ShowDialog(%d)\n", DlgType);
	if ((DlgType < dsoFileNew) || (DlgType > dsoDialogProperties))
		return E_INVALIDARG;

 // Cannot access object if in modal condition...
    if ((m_fModalState) || (m_fNoInteractive))
        return ProvideErrorInfo(DSO_E_INMODALSTATE);

 // The first three dialog types we handle...
	if (DlgType < dsoDialogSaveCopy)
	{
		hr = DoDialogAction(DlgType);
	}
 // The others are provided by the server via IOleCommandTarget...
	else if (m_pDocObjFrame)
	{
		DWORD dwOleCmd;
		switch (DlgType)
		{
		case dsoDialogSaveCopy:   dwOleCmd = OLECMDID_SAVECOPYAS; break;
		case dsoDialogPageSetup:  dwOleCmd = OLECMDID_PAGESETUP;  break;
		case dsoDialogProperties: dwOleCmd = OLECMDID_PROPERTIES; break;
		default:                  dwOleCmd = OLECMDID_PRINT;
		}
		hr = m_pDocObjFrame->DoOleCommand(dwOleCmd, OLECMDEXECOPT_PROMPTUSER, NULL, NULL);
	}

	return ProvideErrorInfo(hr);
}


////////////////////////////////////////////////////////////////////////
// CDsoFramerControl::(put_EnableFileCommand/get_EnableFileCommand)
//
//  True/False. This allows the developer to disable certain menu/toolbar
//  items that are considered "file-level" -- New, Save, Print, etc.
//
//  We use the Item parameter to set a bit flag which is used when
//  displaying the menu to enable/disable the item. The OnFileCommand
//  event will not fire for disabled commands.
//
STDMETHODIMP CDsoFramerControl::put_EnableFileCommand(dsoFileCommandType Item, VARIANT_BOOL vbool)
{
	TRACE2("CDsoFramerControl::put_EnableFileCommand(%d, %d)\n", Item, vbool);

	if ((Item < dsoFileNew) || (Item > dsoFilePrintPreview))
		return E_INVALIDARG;

 // You cannot access menu when in a modal condition...
    if ((m_fModalState) || (m_fNoInteractive))
        return ProvideErrorInfo(DSO_E_INMODALSTATE);

 // We keep bit flags for menu state. Just set the bit and a update
 // the embedded object as needed. User will see change next time menu is shown...
	UINT code = (1 << Item);
	if (vbool == 0)	m_wFileMenuFlags &= ~(code);
	else 		    m_wFileMenuFlags |= code;

	if (m_pDocObjFrame) // This should update toolbar icon (if server supports it)
		m_pDocObjFrame->DoOleCommand(OLECMDID_UPDATECOMMANDS, 0, NULL, NULL);

	return S_OK;
}


STDMETHODIMP CDsoFramerControl::get_EnableFileCommand(dsoFileCommandType Item, VARIANT_BOOL* pbool)
{
	TRACE1("CDsoFramerControl::get_EnableFileCommand(%d)\n", Item);

	if ((Item < dsoFileNew) || (Item > dsoFilePrintPreview))
		return E_INVALIDARG;

	UINT code = (1 << Item);
	if (pbool) *pbool = ((m_wFileMenuFlags & code) ? VARIANT_TRUE : VARIANT_FALSE);

	return S_OK;
}


////////////////////////////////////////////////////////////////////////
// CDsoFramerControl::(put_EnableDefineCommand/get_EnableDefineCommand)
//
//  True/False. This allows the developer to disable certain menu/toolbar
//  items that are considered "file-level" -- New, Save, Print, etc.
//
//  We use the Item parameter to set a bit flag which is used when
//  displaying the menu to enable/disable the item. The OnFileCommand
//  event will not fire for disabled commands.
//	Create dengll 08.07.07

STDMETHODIMP CDsoFramerControl::put_EnableDefineCommand(dsoDefineToolsType Item, VARIANT_BOOL vbool);
{
	TRACE2("CDsoFramerControl::put_EnableDefineCommand(%d, %d)\n", Item, vbool);

	if ((Item < dsoOpenComments) || (Item > dsoCloseComments))
		return E_INVALIDARG;

	// You cannot access menu when in a modal condition...
	if ((m_fModalState) || (m_fNoInteractive))
		return ProvideErrorInfo(DSO_E_INMODALSTATE);

	 // We keep bit flags for menu state. Just set the bit and a update
	 // the embedded object as needed. User will see change next time menu is shown...
	UINT code = (1 << Item);
	if (vbool == 0)	m_wDefineMenuFlags &= ~(code);
	else 		    m_wDefineMenuFlags |= code;

	if (m_pDocObjFrame) // This should update toolbar icon (if server supports it)
		m_pDocObjFrame->DoOleCommand(OLECMDID_UPDATECOMMANDS, 0, NULL, NULL);
	return S_OK;
}


STDMETHODIMP CDsoFramerControl::get_EnableDefineCommand(dsoDefineToolsType Item, VARIANT_BOOL* pbool)
{
	TRACE1("CDsoFramerControl::get_EnableDefineCommand(%d)\n", Item);

	if ((Item < dsoOpenComments) || (Item > dsoCloseComments))
		return E_INVALIDARG;

	UINT code = (1 << Item);
	if (pbool) *pbool = ((m_wDefineMenuFlags & code) ? VARIANT_TRUE : VARIANT_FALSE);

	return S_OK;
}


////////////////////////////////////////////////////////////////////////
// CDsoFramerControl::(put_BorderStyle/get_BorderStyle)
//
//  Change the border style for the control.
//
STDMETHODIMP CDsoFramerControl::put_BorderStyle(dsoBorderStyle style)
{
	ODS("CDsoFramerControl::put_BorderStyle\n");

	if ((style < dsoBorderNone) || (style > dsoBorder3DThin))
		return E_INVALIDARG;

    if (m_fModalState) // Cannot access object if in modal condition...
        return ProvideErrorInfo(DSO_E_INMODALSTATE);

	if (m_fBorderStyle != (DWORD)style)
	{
		m_fBorderStyle = style;
		m_fDirty = TRUE;
		OnResize();
		ViewChanged();
	}
	return S_OK;
}

STDMETHODIMP CDsoFramerControl::get_BorderStyle(dsoBorderStyle* pstyle)
{
	ODS("CDsoFramerControl::get_BorderStyle\n");
	if (pstyle)	*pstyle = (dsoBorderStyle)m_fBorderStyle;
	return S_OK;
}


////////////////////////////////////////////////////////////////////////
// Control Color Properties...
//
//
STDMETHODIMP CDsoFramerControl::put_BorderColor(OLE_COLOR clr)
{
	ODS("CDsoFramerControl::put_BorderColor\n");
	if (m_clrBorderColor != clr)
	{
		m_clrBorderColor = clr;
		m_fDirty = TRUE;
		ViewChanged();
	}
	return S_OK;
}

STDMETHODIMP CDsoFramerControl::get_BorderColor(OLE_COLOR* pclr)
{if (pclr) *pclr = m_clrBorderColor; return S_OK;}

STDMETHODIMP CDsoFramerControl::put_BackColor(OLE_COLOR clr)
{
	ODS("CDsoFramerControl::put_BackColor\n");
	if (m_clrBackColor != clr)
	{
		m_clrBackColor = clr;
		m_fDirty = TRUE;
		ViewChanged();
	}
	return S_OK;
}

STDMETHODIMP CDsoFramerControl::get_BackColor(OLE_COLOR* pclr)
{if (pclr) *pclr = m_clrBackColor; return S_OK;}

STDMETHODIMP CDsoFramerControl::put_ForeColor(OLE_COLOR clr)
{
	ODS("CDsoFramerControl::put_ForeColor\n");
	if (m_clrForeColor != clr)
	{
		m_clrForeColor = clr;
		m_fDirty = TRUE;
		ViewChanged();
	}
	return S_OK;
}

STDMETHODIMP CDsoFramerControl::get_ForeColor(OLE_COLOR* pclr)
{if (pclr) *pclr = m_clrForeColor; return S_OK;}

STDMETHODIMP CDsoFramerControl::put_TitlebarColor(OLE_COLOR clr)
{
	ODS("CDsoFramerControl::put_TitlebarColor\n");
	if (m_clrTBarColor != clr)
	{
		m_clrTBarColor = clr;
		m_fDirty = TRUE;
		ViewChanged();
	}
	return S_OK;
}

STDMETHODIMP CDsoFramerControl::get_TitlebarColor(OLE_COLOR* pclr)
{if (pclr) *pclr = m_clrTBarColor; return S_OK;}


STDMETHODIMP CDsoFramerControl::put_TitlebarTextColor(OLE_COLOR clr)
{
	ODS("CDsoFramerControl::put_TitlebarTextColor\n");
	if (m_clrTBarTextColor != clr)
	{
		m_clrTBarTextColor = clr;
		m_fDirty = TRUE;
		ViewChanged();
	}
	return S_OK;
}

STDMETHODIMP CDsoFramerControl::get_TitlebarTextColor(OLE_COLOR* pclr)
{if (pclr) *pclr = m_clrTBarTextColor; return S_OK;}


////////////////////////////////////////////////////////////////////////
// CDsoFramerControl::(put_Menubar/get_Menubar)
//
//  True/False. Should we display menu bar?
//
STDMETHODIMP CDsoFramerControl::put_Menubar(VARIANT_BOOL vbool)
{
	TRACE1("CDsoFramerControl::put_Menubar(%d)\n", vbool);

 // If the control is in modal state, we can't do things that
 // will call the server directly, like toggle menu bar...
    if ((m_fModalState) || (m_fNoInteractive))
        return ProvideErrorInfo(DSO_E_INMODALSTATE);

	if (m_fShowMenuBar != (WORD)(BOOL)vbool)
	{
		m_fShowMenuBar = (BOOL)vbool;
		m_fDirty = TRUE;
		ViewChanged();
        OnResize();
	}
	return S_OK;
}

STDMETHODIMP CDsoFramerControl::get_Menubar(VARIANT_BOOL* pbool)
{
	ODS("CDsoFramerControl::get_Menubar\n");
	if (pbool) *pbool = (m_fShowMenuBar ? VARIANT_TRUE : VARIANT_FALSE);
	return S_OK;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -