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

📄 dsoframer.h

📁 主要用于打开office文档而使用. ole开发,
💻 H
📖 第 1 页 / 共 3 页
字号:
/***************************************************************************
 * DSOFRAMER.H
 *
 * Developer Support Office ActiveX Document Framer Control Sample
 *
 *  Copyright ?999-2004; Microsoft Corporation. All rights reserved.
 *  Written by Microsoft Developer Support Office Integration (PSS DSOI)
 * 
 *  This code is provided via KB 311765 as a sample. It is not a formal
 *  product and has not been tested with all containers or servers. Use it
 *  for educational purposes only.
 *
 *  You have a royalty-free right to use, modify, reproduce and distribute
 *  this sample application, and/or any modified version, in any way you
 *  find useful, provided that you agree that Microsoft has no warranty,
 *  obligations or liability for the code or information provided herein.
 *
 *  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
 *  EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 *  WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
 *
 *  See the EULA.TXT file included in the KB download for full terms of use
 *  and restrictions. You should consult documentation on MSDN Library for
 *  possible updates or changes to behaviors or interfaces used in this sample.
 *
 ***************************************************************************/
#ifndef DS_DSOFRAMER_H 
#define DS_DSOFRAMER_H

////////////////////////////////////////////////////////////////////
// We compile at level 4 and disable some unnecessary warnings...
//
#pragma warning(push, 4) // Compile at level-4 warnings
#pragma warning(disable: 4100) // unreferenced formal parameter (in OLE this is common)
#pragma warning(disable: 4146) // unary minus operator applied to unsigned type, result still unsigned
#pragma warning(disable: 4268) // const static/global data initialized with compiler generated default constructor
#pragma warning(disable: 4310) // cast truncates constant value
#pragma warning(disable: 4786) // identifier was truncated in the debug information

////////////////////////////////////////////////////////////////////
// Compile Options For Modified Behavior...
//
#define DSO_MSDAIPP_USE_DAVONLY          // Default to WebDAV protocol for open by HTTP/HTTPS
#define DSO_WORD12_PERSIST_BUG           // Perform workaround for IPersistFile bug in Word 2007

////////////////////////////////////////////////////////////////////
// Needed include files (both standard and custom)
//
#include <windows.h>
#include <ole2.h>
#include <olectl.h>
#include <oleidl.h>
#include <objsafe.h>

#include "version.h"
#include "utilities.h"
#include "dsofdocobj.h"
#include ".\lib\dsoframerlib.h"
#include ".\res\resource.h"

////////////////////////////////////////////////////////////////////
// Global Variables
//
extern HINSTANCE        v_hModule;
extern CRITICAL_SECTION v_csecThreadSynch;
extern HICON            v_icoOffDocIcon;
extern ULONG            v_cLocks;
extern BOOL             v_fUnicodeAPI;
extern BOOL             v_fWindows2KPlus;

////////////////////////////////////////////////////////////////////
// Custom Errors - we support a very limited set of custom error messages
//
#define DSO_E_ERR_BASE              0x80041100
#define DSO_E_UNKNOWN               0x80041101   // "An unknown problem has occurred."
#define DSO_E_INVALIDPROGID         0x80041102   // "The ProgID/Template could not be found or is not associated with a COM server."
#define DSO_E_INVALIDSERVER         0x80041103   // "The associated COM server does not support ActiveX Document embedding."
#define DSO_E_COMMANDNOTSUPPORTED   0x80041104   // "The command is not supported by the document server."
#define DSO_E_DOCUMENTREADONLY      0x80041105   // "Unable to perform action because document was opened in read-only mode."
#define DSO_E_REQUIRESMSDAIPP       0x80041106   // "The Microsoft Internet Publishing Provider is not installed, so the URL document cannot be open for write access."
#define DSO_E_DOCUMENTNOTOPEN       0x80041107   // "No document is open to perform the operation requested."
#define DSO_E_INMODALSTATE          0x80041108   // "Cannot access document when in modal condition."
#define DSO_E_NOTBEENSAVED          0x80041109   // "Cannot Save file without a file path."
#define DSO_E_FRAMEHOOKFAILED       0x8004110A   // "Unable to set frame hook for the parent window."
#define DSO_E_ERR_MAX               0x8004110B

////////////////////////////////////////////////////////////////////
// Custom OLE Command IDs - we use for special tasks
//
#define OLECMDID_GETDATAFORMAT      0x7001  // 28673
#define OLECMDID_SETDATAFORMAT      0x7002  // 28674
#define OLECMDID_LOCKSERVER         0x7003  // 28675
#define OLECMDID_RESETFRAMEHOOK     0x7009  // 28681
#define OLECMDID_NOTIFYACTIVE       0x700A  // 28682

////////////////////////////////////////////////////////////////////
// Custom Window Messages (only apply to CDsoFramerControl window proc)
//
#define DSO_WM_ASYNCH_OLECOMMAND         (WM_USER + 300)
#define DSO_WM_ASYNCH_STATECHANGE        (WM_USER + 301)

#define DSO_WM_HOOK_NOTIFY_COMPACTIVE    (WM_USER + 400)
#define DSO_WM_HOOK_NOTIFY_APPACTIVATE   (WM_USER + 401)
#define DSO_WM_HOOK_NOTIFY_FOCUSCHANGE   (WM_USER + 402)
#define DSO_WM_HOOK_NOTIFY_SYNCPAINT     (WM_USER + 403)
#define DSO_WM_HOOK_NOTIFY_PALETTECHANGE (WM_USER + 404)

// State Flags for DSO_WM_ASYNCH_STATECHANGE:
#define DSO_STATE_MODAL            1
#define DSO_STATE_ACTIVATION       2
#define DSO_STATE_INTERACTIVE      3
#define DSO_STATE_RETURNFROMMODAL  4


////////////////////////////////////////////////////////////////////
// Menu Bar Items
//
#define DSO_MAX_MENUITEMS         16
#define DSO_MAX_MENUNAME_LENGTH   32

#ifndef DT_HIDEPREFIX
#define DT_HIDEPREFIX             0x00100000
#define DT_PREFIXONLY             0x00200000
#endif

#define SYNCPAINT_TIMER_ID         4


////////////////////////////////////////////////////////////////////
// Control Class Factory
//
class CDsoFramerClassFactory : public IClassFactory
{
public:
    CDsoFramerClassFactory(): m_cRef(0){}
    ~CDsoFramerClassFactory(void){}

 // IUnknown Implementation
    STDMETHODIMP         QueryInterface(REFIID riid, void ** ppv);
    STDMETHODIMP_(ULONG) AddRef(void);
    STDMETHODIMP_(ULONG) Release(void);

 // IClassFactory Implementation
    STDMETHODIMP  CreateInstance(LPUNKNOWN punk, REFIID riid, void** ppv);
    STDMETHODIMP  LockServer(BOOL fLock);

private:
    ULONG          m_cRef;          // Reference count

};

////////////////////////////////////////////////////////////////////
// CDsoFramerControl -- Main Control (OCX) Object 
//
//  The CDsoFramerControl control is standard OLE control designed around 
//  the OCX94 specification. Because we plan on doing custom integration to 
//  act as both OLE object and OLE host, it does not use frameworks like ATL 
//  or MFC which would only complicate the nature of the sample.
//
//  The control inherits from its automation interface, but uses nested 
//  classes for all OLE interfaces. This is not a requirement but does help
//  to clearly seperate the tasks done by each interface and makes finding 
//  ref count problems easier to spot since each interface carries its own
//  counter and will assert (in debug) if interface is over or under released.
//  
//  The control is basically a stage for the ActiveDocument embedding, and 
//  handles any external (user) commands. The task of actually acting as
//  a DocObject host is done in the site object CDsoDocObject, which this 
//  class creates and uses for the embedding.
//
class CDsoFramerControl : public _FramerControl
{
public:
    CDsoFramerControl(LPUNKNOWN punk);
    ~CDsoFramerControl(void);

 // IUnknown Implementation -- Always delgates to outer unknown...
    STDMETHODIMP         QueryInterface(REFIID riid, void ** ppv){return m_pOuterUnknown->QueryInterface(riid, ppv);}
    STDMETHODIMP_(ULONG) AddRef(void){return m_pOuterUnknown->AddRef();}
    STDMETHODIMP_(ULONG) Release(void){return m_pOuterUnknown->Release();}

 // IDispatch Implementation
    STDMETHODIMP GetTypeInfoCount(UINT* pctinfo); 
    STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo);
    STDMETHODIMP GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId);
    STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr);

 // _FramerControl Implementation
    STDMETHODIMP Activate();
    STDMETHODIMP get_ActiveDocument(IDispatch** ppdisp);
    STDMETHODIMP CreateNew(BSTR ProgIdOrTemplate);
    STDMETHODIMP Open(VARIANT Document, VARIANT ReadOnly, VARIANT ProgId, VARIANT WebUsername, VARIANT WebPassword);
    STDMETHODIMP Save(VARIANT SaveAsDocument, VARIANT OverwriteExisting, VARIANT WebUsername, VARIANT WebPassword);
    STDMETHODIMP _PrintOutOld(VARIANT PromptToSelectPrinter);
    STDMETHODIMP Close();
	STDMETHODIMP OpenComments();//Create dengll 08.07.08
    STDMETHODIMP put_Caption(BSTR bstr);
    STDMETHODIMP get_Caption(BSTR* pbstr);
    STDMETHODIMP put_Titlebar(VARIANT_BOOL vbool);
    STDMETHODIMP get_Titlebar(VARIANT_BOOL* pbool);
    STDMETHODIMP put_Toolbars(VARIANT_BOOL vbool);
    STDMETHODIMP get_Toolbars(VARIANT_BOOL* pbool);
    STDMETHODIMP put_ModalState(VARIANT_BOOL vbool);
    STDMETHODIMP get_ModalState(VARIANT_BOOL* pbool);
    STDMETHODIMP ShowDialog(dsoShowDialogType DlgType);
    STDMETHODIMP put_EnableFileCommand(dsoFileCommandType Item, VARIANT_BOOL vbool);
    STDMETHODIMP get_EnableFileCommand(dsoFileCommandType Item, VARIANT_BOOL* pbool);
	STDMETHODIMP put_EnableDefineCommand(dsoDefineToolsType Item, VARIANT_BOOL vbool);//Create dengll 08.07.07
	STDMETHODIMP get_EnableDefineCommand(dsoDefineToolsType Item, VARIANT_BOOL* pbool);//Create dengll 08.07.07
    STDMETHODIMP put_BorderStyle(dsoBorderStyle style);
    STDMETHODIMP get_BorderStyle(dsoBorderStyle* pstyle);
    STDMETHODIMP put_BorderColor(OLE_COLOR clr);
    STDMETHODIMP get_BorderColor(OLE_COLOR* pclr);
    STDMETHODIMP put_BackColor(OLE_COLOR clr);
    STDMETHODIMP get_BackColor(OLE_COLOR* pclr);
    STDMETHODIMP put_ForeColor(OLE_COLOR clr);
    STDMETHODIMP get_ForeColor(OLE_COLOR* pclr);
    STDMETHODIMP put_TitlebarColor(OLE_COLOR clr);
    STDMETHODIMP get_TitlebarColor(OLE_COLOR* pclr);
    STDMETHODIMP put_TitlebarTextColor(OLE_COLOR clr);
    STDMETHODIMP get_TitlebarTextColor(OLE_COLOR* pclr);
    STDMETHODIMP ExecOleCommand(LONG OLECMDID, VARIANT Options, VARIANT* vInParam, VARIANT* vInOutParam);
    STDMETHODIMP put_Menubar(VARIANT_BOOL vbool);
    STDMETHODIMP get_Menubar(VARIANT_BOOL* pbool);
    STDMETHODIMP put_HostName(BSTR bstr);
    STDMETHODIMP get_HostName(BSTR* pbstr);
    STDMETHODIMP get_DocumentFullName(BSTR* pbstr);
    STDMETHODIMP PrintOut(VARIANT PromptUser, VARIANT PrinterName, VARIANT Copies, VARIANT FromPage, VARIANT ToPage, VARIANT OutputFile);
    STDMETHODIMP PrintPreview();
    STDMETHODIMP PrintPreviewExit();
    STDMETHODIMP get_IsReadOnly(VARIANT_BOOL* pbool);
    STDMETHODIMP get_IsDirty(VARIANT_BOOL* pbool);

⌨️ 快捷键说明

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