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

📄 control.h

📁 vc6.0完整版
💻 H
📖 第 1 页 / 共 2 页
字号:
	MESSAGE_HANDLER(WM_CREATE, OnCreate)
	MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
[!if=(SubclassWindow, "RichEdit")]
	MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
[!endif]
[!endif]
[!if=(CompositeControl, "TRUE")]
	CHAIN_MSG_MAP(CComCompositeControl<[!ClassName]>)
[!else]
	CHAIN_MSG_MAP(CComControl<[!ClassName]>)
[!endif]
[!if!=(SubclassWindow, "")]
ALT_MSG_MAP(1)
	// Replace this with message map entries for superclassed [!SubclassWindow]
[!endif]
[!if=(SubclassWindow, "")]
[!if!(CompositeControl)]
	DEFAULT_REFLECTION_HANDLER()
[!endif]
[!endif]
END_MSG_MAP()
// Handler prototypes:
//  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
//  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
//  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);

[!if=(CompositeControl, "TRUE")]
[!crlf]
BEGIN_SINK_MAP([!ClassName])
	//Make sure the Event Handlers have __stdcall calling convention
END_SINK_MAP()
[!crlf]

	STDMETHOD(OnAmbientPropertyChange)(DISPID dispid)
	{
		if (dispid == DISPID_AMBIENT_BACKCOLOR)
		{
			SetBackgroundColorFromAmbient();
			FireViewChange();
		}
		return IOleControlImpl<[!ClassName]>::OnAmbientPropertyChange(dispid);
	}

[!endif]
[!crlf]
[!if=(UseArrowKeys, "TRUE")]
	BOOL PreTranslateAccelerator(LPMSG pMsg, HRESULT& hRet)
	{
		if(pMsg->message == WM_KEYDOWN && 
			(pMsg->wParam == VK_LEFT || 
			pMsg->wParam == VK_RIGHT ||
			pMsg->wParam == VK_UP ||
			pMsg->wParam == VK_DOWN))
		{
			hRet = S_FALSE;
			return TRUE;
		}
		//TODO: Add your additional accelerator handling code here
		return FALSE;
	}
[!endif]

[!crlf]
[!if!=(SubclassWindow, "")]
	LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		LRESULT lRes = CComControl<[!ClassName]>::OnSetFocus(uMsg, wParam, lParam, bHandled);
		if (m_bInPlaceActive)
		{
			DoVerbUIActivate(&m_rcPos,  NULL);
			if(!IsChild(::GetFocus()))
				m_ctl[!SubclassWindowSymbol].SetFocus();
		}
		return lRes;
	}
[!if=(SubclassWindow, "RichEdit")]
[!crlf]
	HINSTANCE m_hLibRichEdit;
[!endif]
[!crlf]
	LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		RECT rc;
		GetWindowRect(&rc);
		rc.right -= rc.left;
		rc.bottom -= rc.top;
		rc.top = rc.left = 0;
[!if=(UseCommonControls, "TRUE")]		InitCommonControls();[!endif]
[!if=(SubclassWindow, "RichEdit")]		m_hLibRichEdit = LoadLibrary(_T("RICHED32.DLL"));[!endif]
		m_ctl[!SubclassWindowSymbol].Create(m_hWnd, rc);
		return 0;
	}
[!if=(SubclassWindow, "RichEdit")]
	LRESULT OnDestroy(UINT, WPARAM, LPARAM, BOOL&)
	{
		m_ctl[!SubclassWindowSymbol].DestroyWindow();
		FreeLibrary(m_hLibRichEdit);
		return 0;
	}
[!endif]
	STDMETHOD(SetObjectRects)(LPCRECT prcPos,LPCRECT prcClip)
	{
		IOleInPlaceObjectWindowlessImpl<[!ClassName]>::SetObjectRects(prcPos, prcClip);
		int cx, cy;
		cx = prcPos->right - prcPos->left;
		cy = prcPos->bottom - prcPos->top;
		::SetWindowPos(m_ctl[!SubclassWindowSymbol].m_hWnd, NULL, 0,
			0, cx, cy, SWP_NOZORDER | SWP_NOACTIVATE);
		return S_OK;
	}
[!endif]

[!if=(FreeThreadedMarshaler, "TRUE")]
[!crlf]
	HRESULT FinalConstruct()
	{
		return CoCreateFreeThreadedMarshaler(
			GetControllingUnknown(), &m_pUnkMarshaler.p);
	}
[!crlf]
	void FinalRelease()
	{
		m_pUnkMarshaler.Release();
	}

[!crlf]
	CComPtr<IUnknown> m_pUnkMarshaler;
[!endif]

[!if=(ErrorInfoEnabled, "TRUE")]
[!crlf]
// ISupportsErrorInfo
	STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid)
	{
		static const IID* arr[] = 
		{
			&IID_[!InterfaceName],
		};

		for (int i=0; i<sizeof(arr)/sizeof(arr[0]); i++)
		{
			if (InlineIsEqualGUID(*arr[i], riid))
				return S_OK;
		}
		return S_FALSE;
	}
[!endif]
[!crlf]
// IViewObjectEx
[!if=(Opaque, "TRUE")]
[!if=(SolidBackground, "TRUE")]
	DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
[!else]
	DECLARE_VIEW_STATUS(VIEWSTATUS_OPAQUE)
[!endif]
[!else]
	DECLARE_VIEW_STATUS(0)
[!endif]
[!crlf]
// [!InterfaceName]
public:
[!if!(HTMLControl)]
[!if!(CompositeControl)]
[!if=(SubclassWindow, "")]

[!if=(NormalizeDCEnabled, "TRUE")]
[!crlf]
	HRESULT OnDraw(ATL_DRAWINFO& di)
[!else]
[!crlf]
	HRESULT OnDrawAdvanced(ATL_DRAWINFO& di)
[!endif]
	{
		RECT& rc = *(RECT*)di.prcBounds;
		Rectangle(di.hdcDraw, rc.left, rc.top, rc.right, rc.bottom);
[!crlf]
		SetTextAlign(di.hdcDraw, TA_CENTER|TA_BASELINE);
		LPCTSTR pszText = _T("ATL 3.0 : [!ShortName]");
		TextOut(di.hdcDraw, 
			(rc.left + rc.right) / 2, 
			(rc.top + rc.bottom) / 2, 
			pszText, 
			lstrlen(pszText));
[!crlf]
		return S_OK;
	}

[!endif]
[!endif]
[!endif]

[!if=(SP_APPEARANCE, "TRUE")]	short m_nAppearance;[!endif]
[!if=(SP_BACKCOLOR, "TRUE")]	OLE_COLOR m_clrBackColor;[!endif]
[!if=(SP_BACKSTYLE, "TRUE")]	LONG m_nBackStyle;[!endif]
[!if=(SP_BORDERCOLOR, "TRUE")]	OLE_COLOR m_clrBorderColor;[!endif]
[!if=(SP_BORDERSTYLE, "TRUE")]	LONG m_nBorderStyle;[!endif]
[!if=(SP_BORDERVISIBLE, "TRUE")]	BOOL m_bBorderVisible;[!endif]
[!if=(SP_BORDERWIDTH, "TRUE")]	LONG m_nBorderWidth;[!endif]
[!if=(SP_CAPTION, "TRUE")]	CComBSTR m_bstrCaption;[!endif]
[!if=(SP_DRAWMODE, "TRUE")]	LONG m_nDrawMode;[!endif]
[!if=(SP_DRAWSTYLE, "TRUE")]	LONG m_nDrawStyle;[!endif]
[!if=(SP_DRAWWIDTH, "TRUE")]	LONG m_nDrawWidth;[!endif]
[!if=(SP_ENABLED, "TRUE")]	BOOL m_bEnabled;[!endif]
[!if=(SP_FILLCOLOR, "TRUE")]	OLE_COLOR m_clrFillColor;[!endif]
[!if=(SP_FILLSTYLE, "TRUE")]	LONG m_nFillStyle;[!endif]
[!if=(SP_FONT, "TRUE")]	CComPtr<IFontDisp> m_pFont;[!endif]
[!if=(SP_FORECOLOR, "TRUE")]	OLE_COLOR m_clrForeColor;[!endif]
[!if=(SP_MOUSEICON, "TRUE")]	CComPtr<IPictureDisp> m_pMouseIcon;[!endif]
[!if=(SP_MOUSEPOINTER, "TRUE")]	LONG m_nMousePointer;[!endif]
[!if=(SP_PICTURE, "TRUE")]	CComPtr<IPictureDisp> m_pPicture;[!endif]
[!if=(SP_READYSTATE, "TRUE")]	LONG m_nReadyState;[!endif]
[!if=(SP_TABSTOP, "TRUE")]	BOOL m_bTabStop;[!endif]
[!if=(SP_TEXT, "TRUE")]	CComBSTR m_bstrText;[!endif]
[!if=(SP_VALID, "TRUE")]	BOOL m_bValid;[!endif]

[!if=(CompositeControl, "TRUE")]
[!crlf]
	enum { IDD = [!IDD_DIALOGID] };
[!endif]
[!if=(HTMLControl, "TRUE")]
[!crlf]
// [!InterfaceName]UI
public:
	// Example method called by the HTML to change the <BODY> background color
	STDMETHOD(OnClick)(IDispatch* pdispBody, VARIANT varColor)
	{
		CComQIPtr<IHTMLBodyElement> spBody(pdispBody);
		if (spBody != NULL)
			spBody->put_bgColor(varColor);
		return S_OK;
	}

[!crlf]
	LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		CAxWindow wnd(m_hWnd);
		HRESULT hr = wnd.CreateControl([!IDH_HTMLID]);
		if (SUCCEEDED(hr))
			hr = wnd.SetExternalDispatch(static_cast<[!InterfaceName]UI*>(this));
		if (SUCCEEDED(hr))
			hr = wnd.QueryControl(IID_IWebBrowser2, (void**)&m_spBrowser);
		return SUCCEEDED(hr) ? 0 : -1;
	}
[!if=(ISERVICEPROVIDER, "TRUE")]
[!crlf]
	STDMETHOD(_InternalQueryService)(REFGUID guidService, REFIID riid, void** ppvObject)
	{
		return E_NOTIMPL;
	}
[!endif]
[!crlf]
	CComPtr<IWebBrowser2> m_spBrowser;
[!endif]

};

[!crlf]
[!if=(FileExists, "FALSE")]
#endif //__[!UpperShortName]_H_
[!endif]

⌨️ 快捷键说明

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