📄 bcfcontrolctl.h
字号:
//=--------------------------------------------------------------------------=
// BCFControlCtl.H
//=--------------------------------------------------------------------------=
// Copyright 1995 Microsoft Corporation. All Rights Reserved.
//
// 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.
//=--------------------------------------------------------------------------=
//
// class declaration for the BCFControl control.
//
#ifndef _BCFCONTROLCONTROL_H_
#include "IPServer.H"
#include "CtrlObj.H"
#include "BCFControlInterfaces.H"
#include "Dispids.H"
#include "internet.h"
#include "IPerPropertyBrowsing.h"
#include "IDataObject.h"
#include "IEnumFORMATETC.h"
#include "IDropSource.h"
#include "IDropTarget.h"
#include "alignmentenums.h"
typedef enum
{
BCFControlEvent_Change = 0,
} BCFCONTROLEVENTS;
VARTYPE rgPI4PBSTR [];
EVENTINFO m_rgBCFControlEvents[];
typedef struct tagBCFCONTROLCTLSTATE
{
long lCaptionLength;
long lAlignment;
OLE_COLOR ocBackColor;
long lReadyState;
long lTextDataPathLength;
} BCFCONTROLCTLSTATE;
//=--------------------------------------------------------------------------=
// CBCFControlControl
//=--------------------------------------------------------------------------=
// our control.
//
class CBCFControlControl : public CInternetControl, public IBCFControl,
public ISupportErrorInfo, public IPerPropertyBrowsing, public IDataObject,
public IEnumFORMATETC, public IDropSource, public IDropTarget
{
public:
// IUnknown methods
//
DECLARE_STANDARD_UNKNOWN();
// IDispatch methods
//
DECLARE_STANDARD_DISPATCH();
// ISupportErrorInfo methods
//
DECLARE_STANDARD_SUPPORTERRORINFO();
// IPerPropertyBrowsing methods
//
DECLARE_STANDARD_PERPROPERTYBROWSING();
// IDataObject methods
//
DECLARE_STANDARD_DATAOBJECT();
// IEnumFORMATETC methods
//
DECLARE_STANDARD_ENUMFORMATETC();
// IDropSource methods
//
DECLARE_STANDARD_DROPSOURCE();
// IDropTarget methods
//
DECLARE_STANDARD_IDROPTARGET();
// IBCFControl methods
//
STDMETHOD(get_Alignment)(THIS_ long FAR* lRetValue);
STDMETHOD(put_Alignment)(THIS_ long lNewValue);
STDMETHOD(get_BackColor)(THIS_ OLE_COLOR FAR* ocRetValue);
STDMETHOD(put_BackColor)(THIS_ OLE_COLOR ocNewValue);
STDMETHOD(get_ReadyState)(THIS_ long FAR* lRetValue);
STDMETHOD(get_TextDataPath)(THIS_ BSTR FAR* bstrRetVal);
STDMETHOD(put_TextDataPath)(THIS_ BSTR bstrNewValue);
STDMETHOD(CaptionMethod)(THIS_ BSTR bstrCaption, VARIANT varAlignment, long FAR* lRetVal);
STDMETHOD(get_CaptionProp)(THIS_ VARIANT varAlignment, BSTR FAR* bstrRetVal);
STDMETHOD(put_CaptionProp)(THIS_ VARIANT varAlignment, BSTR lpszNewValue);
STDMETHOD_(void, AboutBox)(THIS);
// OLE Control stuff follows:
//
CBCFControlControl(IUnknown *pUnkOuter);
virtual ~CBCFControlControl();
// static creation function. all controls must have one of these!
//
static IUnknown *Create(IUnknown *);
private:
// overridables that the control must implement.
//
STDMETHOD(LoadBinaryState)(IStream *pStream);
STDMETHOD(SaveBinaryState)(IStream *pStream);
STDMETHOD(LoadTextState)(IPropertyBag *pPropertyBag, IErrorLog *pErrorLog);
STDMETHOD(SaveTextState)(IPropertyBag *pPropertyBag, BOOL fWriteDefault);
STDMETHOD(OnDraw)(DWORD dvAspect, HDC hdcDraw, LPCRECTL prcBounds, LPCRECTL prcWBounds, HDC hicTargetDev, BOOL fOptimize);
virtual LRESULT WindowProc(UINT msg, WPARAM wParam, LPARAM lParam);
virtual BOOL RegisterClassData(void);
virtual HRESULT InternalQueryInterface(REFIID, void **);
virtual BOOL BeforeCreateWindow(DWORD *pdwWindowStyle, DWORD *pdwExWindowStyle, LPSTR pszWindowTitle);
virtual void BeforeDestroyWindow(void);
virtual BOOL AfterCreateWindow(void);
/// OnData is called asynchronously as data for an object or property arrives...
virtual HRESULT OnData(DISPID propId, DWORD bscfFlag, IStream * strm, DWORD dwSize);
// private state information.
//
BCFCONTROLCTLSTATE m_state;
BCFCONTROLCTLSTATE m_DefaultState;
protected:
void FireChange(void);
LPTSTR m_lptstrCaption;
LPTSTR m_lptstrTextDataPath;
IFont * m_pFont;
void LoadFont(void);
HBRUSH hBrush, hOldBrush;
COLORREF TranslateColor(OLE_COLOR clrColor, HPALETTE hpal = NULL){COLORREF cr = RGB(0x00,0x00,0x00);OleTranslateColor(clrColor, hpal, &cr);return cr;}
void FillSolidRect(HDC hDC, LPCRECT lpRect, COLORREF clr){::SetBkColor(hDC, clr);::ExtTextOut(hDC, 0, 0, ETO_OPAQUE, lpRect, NULL, 0, NULL);}
void GetTextExtent(HDC hDC, LPCTSTR lpctstrString, int & cx, int & cy);
BOOL bRetrievedDimensions;
int iCharWidthArray[256];
int iCharacterSpacing, iCharacterHeight;
void CopyStgMedium(LPSTGMEDIUM lpTargetStgMedium, LPSTGMEDIUM lpSourceStgMedium, CLIPFORMAT cfSourceFormat);
void CopyDataToClipboard(void);
void PrepareDataForTransfer(void);
void GetDataFromClipboard(void);
void GetDataFromTransfer(IDataObject * ipDataObj);
ULONG ulFORMATETCElement;
void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
void OnLButtonDown(UINT nFlags, short sHor, short sVer);
private:
FORMATETC sTextFormatEtc;
STGMEDIUM sTextStgMedium;
// custom format storage variables
UINT m_uiCustomFormat;
FORMATETC sCustomFormatEtc;
STGMEDIUM sCustomStgMedium;
};
// TODO: if you have an array of verbs, then add an extern here with the name
// of it, so that you can include it in the DEFINE_CONTROLOBJECT.
// ie. extern VERBINFO m_BCFControlCustomVerbs [];
//
extern const GUID *rgBCFControlPropPages [];
DEFINE_CONTROLOBJECT(BCFControl,
&CLSID_BCFControl,
"BCFControlCtl",
CBCFControlControl::Create,
1,
&IID_IBCFControl,
"BCFControl.HLP",
&DIID_DBCFControlEvents,
OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_RECOMPOSEONRESIZE|OLEMISC_CANTLINKINSIDE|OLEMISC_INSIDEOUT,
0, // no IPointerInactive policy by default
RESID_TOOLBOX_BITMAP1,
"BCFControlWndClass",
1,
rgBCFControlPropPages,
0,
NULL);
#define _BCFCONTROLCONTROL_H_
#endif // _BCFCONTROLCONTROL_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -