📄 dsoframer.h
字号:
// ISupportErrorInfo Implementation
BEGIN_INTERFACE_PART(SupportErrorInfo, ISupportErrorInfo)
STDMETHODIMP InterfaceSupportsErrorInfo(REFIID riid);
END_INTERFACE_PART(SupportErrorInfo)
// IObjectSafety Implementation
BEGIN_INTERFACE_PART(ObjectSafety, IObjectSafety)
STDMETHODIMP GetInterfaceSafetyOptions(REFIID riid, DWORD *pdwSupportedOptions,DWORD *pdwEnabledOptions);
STDMETHODIMP SetInterfaceSafetyOptions(REFIID riid, DWORD dwOptionSetMask, DWORD dwEnabledOptions);
END_INTERFACE_PART(ObjectSafety)
STDMETHODIMP InitializeNewInstance();
STDMETHODIMP InPlaceActivate(LONG lVerb);
STDMETHODIMP_(void) SetInPlaceVisible(BOOL fShow);
STDMETHODIMP_(void) UpdateModalState(BOOL fModeless, BOOL fNotifyIPObject);
STDMETHODIMP_(void) UpdateActivationState(BOOL fActive);
STDMETHODIMP_(void) UpdateInteractiveState(BOOL fActive);
STDMETHODIMP_(void) OnDraw(DWORD dvAspect, HDC hdcDraw, LPRECT prcBounds, LPRECT prcWBounds, HDC hicTargetDev, BOOL fOptimize);
STDMETHODIMP_(void) OnFocusChange(BOOL fGotFocus, HWND hFocusWnd);
STDMETHODIMP_(void) OnDestroyWindow();
STDMETHODIMP_(void) OnResize();
STDMETHODIMP_(void) OnMouseMove(UINT x, UINT y);
STDMETHODIMP_(void) OnButtonDown(UINT x, UINT y);
STDMETHODIMP_(void) OnMenuMessage(UINT msg, WPARAM wParam, LPARAM lParam);
STDMETHODIMP_(void) OnToolbarAction(DWORD cmd);
STDMETHODIMP_(void) OnComponentActivationChange(BOOL fActivate);
STDMETHODIMP_(void) OnAppActivation(BOOL fActive, DWORD dwThreadID);
STDMETHODIMP_(void) OnPaletteChanged(HWND hwndPalChg);
STDMETHODIMP_(void) OnWindowEnable(BOOL fEnable){TRACE1("CDsoFramerControl::OnWindowEnable(%d)\n", fEnable);}
STDMETHODIMP_(HMENU) GetActivePopupMenu();
STDMETHODIMP_(BOOL) FRunningInDesignMode();
STDMETHODIMP DoDialogAction(dsoShowDialogType item);
STDMETHODIMP ProvideErrorInfo(HRESULT hres);
// Some inline methods are provided for common tasks such as site notification
// or calculation of draw size based on user selection of tools and border style.
void __fastcall ViewChanged()
{
if (m_pDataAdviseHolder) // Send data change notification.
m_pDataAdviseHolder->SendOnDataChange((IDataObject*)&m_xDataObject, NULL, 0);
if (m_pViewAdviseSink) // Send the view change notification....
{
m_pViewAdviseSink->OnViewChange(DVASPECT_CONTENT, -1);
if (m_fViewAdviseOnlyOnce) // If they asked to be advised once, kill the connection
m_xViewObjectEx.SetAdvise(DVASPECT_CONTENT, 0, NULL);
}
InvalidateRect(m_hwnd, NULL, TRUE); // Ensure a full repaint...
}
void __fastcall GetSizeRectAfterBorder(LPRECT lprcx, LPRECT lprc)
{
if (lprcx) CopyRect(lprc, lprcx);
else SetRect(lprc, 0, 0, m_Size.cx, m_Size.cy);
if (m_fBorderStyle) InflateRect(lprc, -(4-m_fBorderStyle), -(4-m_fBorderStyle));
}
void __fastcall GetSizeRectAfterTitlebar(LPRECT lprcx, LPRECT lprc)
{
GetSizeRectAfterBorder(lprcx, lprc);
if (m_fShowTitlebar) lprc->top += 21;
}
void __fastcall GetSizeRectForMenuBar(LPRECT lprcx, LPRECT lprc)
{
GetSizeRectAfterTitlebar(lprcx, lprc);
lprc->bottom = lprc->top + 24;
}
void __fastcall GetSizeRectForDocument(LPRECT lprcx, LPRECT lprc)
{
GetSizeRectAfterTitlebar(lprcx, lprc);
if (m_fShowMenuBar) lprc->top += 24;
if (lprc->top > lprc->bottom) lprc->top = lprc->bottom;
}
void __fastcall RedrawCaption()
{
RECT rcT;
if ((m_hwnd) && (m_fShowTitlebar))
{ GetClientRect(m_hwnd, &rcT); rcT.bottom = 21;
InvalidateRect(m_hwnd, &rcT, FALSE);
}
if ((m_hwnd) && (m_fShowMenuBar))
{ GetSizeRectForMenuBar(NULL, &rcT);
InvalidateRect(m_hwnd, &rcT, FALSE);
}
}
// The control window proceedure is handled through static class method.
static STDMETHODIMP_(LRESULT) ControlWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
// The variables for the control are kept private but accessible to the
// nested classes for each interface.
private:
ULONG m_cRef; // Reference count
IUnknown *m_pOuterUnknown; // Outer IUnknown (points to m_xInternalUnknown if not agg)
ITypeInfo *m_ptiDispType; // ITypeInfo Pointer (IDispatch Impl)
EXCEPINFO *m_pDispExcep; // EXCEPINFO Pointer (IDispatch Impl)
HWND m_hwnd; // our window
HWND m_hwndParent; // immediate parent window
SIZEL m_Size; // the size of this control
RECT m_rcLocation; // where we at
IOleClientSite *m_pClientSite; // active client site of host containter
IOleControlSite *m_pControlSite; // control site
IOleInPlaceSite *m_pInPlaceSite; // inplace site
IOleInPlaceFrame *m_pInPlaceFrame; // inplace frame
IOleInPlaceUIWindow *m_pInPlaceUIWindow; // inplace ui window
IAdviseSink *m_pViewAdviseSink; // advise sink for view (only 1 allowed)
IOleAdviseHolder *m_pOleAdviseHolder; // OLE advise holder (for oleobject sinks)
IDataAdviseHolder *m_pDataAdviseHolder; // OLE data advise holder (for dataobject sink)
IDispatch *m_dispEvents; // event sink (we only support 1 at a time)
IStorage *m_pOleStorage; // IStorage for OLE hosts.
CDsoDocObject *m_pDocObjFrame;
OLE_COLOR m_clrBorderColor; // Control Colors
OLE_COLOR m_clrBackColor; // "
OLE_COLOR m_clrForeColor; // "
OLE_COLOR m_clrTBarColor; // "
OLE_COLOR m_clrTBarTextColor; // "
BSTR m_bstrCustomCaption; // A custom caption (if provided)
HMENU m_hmenuFilePopup; // The File menu popup
WORD m_wFileMenuFlags; // Bitflags of enabled file menu items.
WORD m_wSelMenuItem; // Which item (if any) is selected
WORD m_cMenuItems; // Count of items on menu bar
RECT m_rgrcMenuItems[DSO_MAX_MENUITEMS]; // Menu bar items
class CDsoFrameWindowHook* m_pFrameHook;
HBITMAP m_hbmDeactive;
LPWSTR m_pwszHostName;
unsigned int m_fDirty:1; // does the control need to be resaved?
unsigned int m_fInPlaceVisible:1; // we are in place visible or not?
unsigned int m_fUIActive:1; // are we UI active or not.
unsigned int m_fViewAdvisePrimeFirst: 1;// for IViewobject2::setadvise
unsigned int m_fViewAdviseOnlyOnce: 1; // for IViewobject2::setadvise
unsigned int m_fUsingWindowRgn:1; // for SetObjectRects and clipping
unsigned int m_fFreezeEvents:1; // should events be frozen?
unsigned int m_fDesignMode:1; // are we in design mode?
unsigned int m_fModeFlagValid:1; // has mode changed since last check?
unsigned int m_fBorderStyle:2; // the border style
unsigned int m_fShowTitlebar:1; // should we show titlebar?
unsigned int m_fShowToolbars:1; // should we show toolbars?
unsigned int m_fModalState:1; // are we modal?
unsigned int m_fObjectMenu:1; // are we over obj menu item?
unsigned int m_fConCntDone:1; // for enum connectpts
unsigned int m_fComponentActive:1; // are we the active component?
unsigned int m_fShowMenuBar:1; // should we show menubar?
unsigned int m_fInDocumentLoad:1; // set when loading file
unsigned int m_fNoInteractive:1; // set when we don't allow interaction with docobj
unsigned int m_fShowMenuPrev:1; // were menus visible before loss of interactivity?
unsigned int m_fShowToolsPrev:1; // were toolbars visible before loss of interactivity?
};
////////////////////////////////////////////////////////////////////
// CDsoFrameWindowHook -- Top-Level Frame Window Hook
//
// Used by the control to allow for proper host notification of focus
// and activation events occurring at top-level window frame. Because
// this DocObject host is an OCX, we don't own these notifications and
// have to "steal" them from our parent using a subclass.
//
// The hook allows for more than one instance of the control by serializing
// activation notifications so only one instance of the control can be
// "UI active" at a time. This is required for proper ActiveX Document
// containment.
//
#define DSOF_MAX_CONTROLS 20
class CDsoFrameWindowHook
{
public:
CDsoFrameWindowHook(){
m_hwndTopLevelHost=NULL;
m_pfnOrigWndProc=NULL;
m_cControls=0;
m_fHostUnicodeWindow=FALSE;
m_idxActive = 0;
memset(m_pControls, 0, sizeof(CDsoFrameWindowHook* ) * DSOF_MAX_CONTROLS);
}
~CDsoFrameWindowHook(){}
static STDMETHODIMP_(CDsoFrameWindowHook*)
AttachToFrameWindow(HWND hwndCtl, CDsoFramerControl* pocx);
STDMETHODIMP Detach(CDsoFramerControl* pocx);
STDMETHODIMP SetActiveComponent(CDsoFramerControl* pocx);
inline STDMETHODIMP_(CDsoFramerControl*)
GetActiveComponent(){return m_pControls[m_idxActive];}
static STDMETHODIMP_(LRESULT)
HostWindowProcHook(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
protected:
HWND m_hwndTopLevelHost; // Top-level host window (hooked)
WNDPROC m_pfnOrigWndProc;
DWORD m_idxActive;
DWORD m_cControls;
CDsoFramerControl* m_pControls[DSOF_MAX_CONTROLS];
BOOL m_fHostUnicodeWindow;
};
#endif //DS_DSOFRAMER_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -