// DDRadioButton.h : Declaration of the CDDRadioButton
//
// Author : David Shepherd
// Copyright (c) 2003, DaeDoe-Software
//
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include "resource.h" // main symbols
#include <atlctl.h>
/////////////////////////////////////////////////////////////////////////////
// IDDRadioButton
[
object,
uuid("9F42CED4-55C0-478C-BEA4-0E06F400A13F"),
dual,
helpstring("IDDRadioButton Interface"),
pointer_default(unique)
]
__interface IDDRadioButton : public IDispatch
{
////////////////////////////////////////
// enabled
[propget, requestedit, bindable,
id(DISPID_ENABLED),
helpstring("")]
HRESULT Enabled([out, retval] VARIANT_BOOL* pVal);
[propput, requestedit, bindable,
id(DISPID_ENABLED),
helpstring("")]
HRESULT Enabled([in] VARIANT_BOOL newVal);
////////////////////////////////////////
// background color
[propget, requestedit, bindable,
id(DISPID_BACKCOLOR),
helpstring("")]
HRESULT BackColor([out, retval] OLE_COLOR* pVal);
[propput, requestedit, bindable,
id(DISPID_BACKCOLOR),
helpstring("")]
HRESULT BackColor([in] OLE_COLOR newVal);
////////////////////////////////////////
// foreground color
[propget, requestedit, bindable,
id(DISPID_FORECOLOR),
helpstring("")]
HRESULT ForeColor([out, retval] OLE_COLOR* pVal);
[propput, requestedit, bindable,
id(DISPID_FORECOLOR),
helpstring("")]
HRESULT ForeColor([in] OLE_COLOR newVal);
////////////////////////////////////////
// font
[propget, requestedit, bindable,
id(DISPID_FONT),
helpstring("")]
HRESULT Font([out, retval] IFontDisp** pVal);
[propput, requestedit, bindable,
id(DISPID_FONT),
helpstring("")]
HRESULT Font([in] IFontDisp* newVal);
[propputref, requestedit, bindable,
id(DISPID_FONT),
helpstring("")]
HRESULT Font([in] IFontDisp* newVal);
////////////////////////////////////////
// text
[propget, requestedit, bindable,
id(DISPID_TEXT),
helpstring("")]
HRESULT Text([out, retval] BSTR* pVal);
[propput, requestedit, bindable,
id(DISPID_TEXT),
helpstring("")]
HRESULT Text([in] BSTR newVal);
////////////////////////////////////////
// text align
[propget, requestedit, bindable,
id(DISPID_TEXTALIGN),
helpstring("")]
HRESULT TextAlign([out, retval] ddcpTextAlign* pVal);
[propput, requestedit, bindable,
id(DISPID_TEXTALIGN),
helpstring("")]
HRESULT TextAlign([in] ddcpTextAlign newVal);
////////////////////////////////////////
// value
[propget, requestedit, bindable,
id(DISPID_VALUE_NOTDEFAULT),
helpstring("")]
HRESULT Value([out, retval] LONG* pVal);
[propput, requestedit, bindable,
id(DISPID_VALUE_NOTDEFAULT),
helpstring("")]
HRESULT Value([in] LONG newVal);
////////////////////////////////////////
// default property
[propget, nonbrowsable,
id(DISPID_VALUE),
helpstring("")]
HRESULT _Default([out, retval] LONG* pVal);
[propput, nonbrowsable,
id(DISPID_VALUE),
helpstring("")]
HRESULT _Default([in] LONG newVal);
};
/////////////////////////////////////////////////////////////////////////////
// _IDDRadioButtonEvents
[
uuid("0DCB1C9E-B853-412C-93CB-F6BEE5DEB1BF"),
dispinterface,
helpstring("_IDDRadioButtonEvents Interface")
]
__interface _IDDRadioButtonEvents
{
[id(1), helpstring("")] HRESULT Click();
};
/////////////////////////////////////////////////////////////////////////////
// CDDRadioButton
[
coclass,
threading("apartment"),
vi_progid("DDControlPack.DDRadioButton"),
progid("DDControlPack.DDRadioButton.1"),
version(1.0),
uuid("D4D424C4-1C19-4C1C-A644-4A0F9ECEA2C1"),
helpstring("DDRadioButton Class"),
event_source("com"),
support_error_info(IDDRadioButton),
registration_script("control.rgs")
]
class ATL_NO_VTABLE CDDRadioButton :
public IDispatchImpl<IDDRadioButton>,
public IPersistStreamInitImpl<CDDRadioButton>,
public IOleControlImpl<CDDRadioButton>,
public IOleObjectImpl<CDDRadioButton>,
public IOleInPlaceActiveObjectImpl<CDDRadioButton>,
public IViewObjectExImpl<CDDRadioButton>,
public IOleInPlaceObjectWindowlessImpl<CDDRadioButton>,
public IPersistStorageImpl<CDDRadioButton>,
public ISpecifyPropertyPagesImpl<CDDRadioButton>,
public IQuickActivateImpl<CDDRadioButton>,
public IDataObjectImpl<CDDRadioButton>,
public CComControl<CDDRadioButton>
{
private:
CContainedWindow m_ctlButton;
__event __interface _IDDRadioButtonEvents;
/////////////////////////////////////////////////////////////////////////////
// properties
LONG m_Reserved0; // reserved
LONG m_Reserved1; // reserved
VARIANT_BOOL m_Enabled; // enabled
OLE_COLOR m_BackColor; // background color
OLE_COLOR m_ForeColor; // foreground color
CComPtr<IFontDisp> m_spFontDisp; // font
CComBSTR m_Text; // text
ddcpTextAlign m_TextAlign; // text align
LONG m_Value; // value
/////////////////////////////////////////////////////////////////////////////
// property change validators
HRESULT OnTextAlignChanging(ddcpTextAlign newVal);
HRESULT OnValueChanging(LONG newVal);
/////////////////////////////////////////////////////////////////////////////
// property change handlers
void OnEnabledChanged();
/////////////////////////////////////////////////////////////////////////////
// draws the button
void DrawButton(CDCHandle hDC,CRect Rect,BOOL HasFocus,BOOL IsSelected);
public:
CDDRadioButton();
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct();
void FinalRelease();
static const TCHAR* GetObjectFriendlyName();
DECLARE_OLEMISC_STATUS(
OLEMISC_RECOMPOSEONRESIZE |
OLEMISC_CANTLINKINSIDE |
OLEMISC_INSIDEOUT |
OLEMISC_ACTIVATEWHENVISIBLE |
OLEMISC_SETCLIENTSITEFIRST)
BEGIN_PROP_MAP(CDDRadioButton)
PROP_DATA_ENTRY("_reserved0", m_Reserved0, VT_I4)
PROP_DATA_ENTRY("_reserved1", m_Reserved1, VT_I4)
PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
PROP_ENTRY("Enabled", DISPID_ENABLED, CLSID_NULL)
PROP_ENTRY("BackColor", DISPID_BACKCOLOR, CLSID_NULL)
PROP_ENTRY("ForeColor", DISPID_FORECOLOR, CLSID_NULL)
PROP_ENTRY("Font", DISPID_FONT, CLSID_NULL)
PROP_ENTRY("Text", DISPID_TEXT, CLSID_NULL)
PROP_ENTRY("TextAlign", DISPID_TEXTALIGN, CLSID_NULL)
PROP_ENTRY("Value", DISPID_VALUE_NOTDEFAULT, CLSID_NULL)
// Example entries
// PROP_ENTRY("Property Description", dispid, clsid)
// PROP_PAGE(CLSID_StockColorPage)
END_PROP_MAP()
BEGIN_MSG_MAP(CDDRadioButton)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
MESSAGE_HANDLER(WM_DRAWITEM, OnDrawItem)
COMMAND_CODE_HANDLER(BN_CLICKED, OnBNClicked)
CHAIN_MSG_MAP(CComControl<CDDRadioButton>)
ALT_MSG_MAP(1)
// Replace this with message map entries for superclassed Button
MESSAGE_HANDLER(WM_ERASEBKGND, OnButtonEraseBkgnd)
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);
// base class overrides
HRESULT FireViewChange();
// message handlers
LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnDrawItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnBNClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
// button message handlers
LRESULT OnButtonEraseBkgnd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
// IOleObject
STDMETHOD(SetClientSite)(IOleClientSite *pClientSite);
// IOleInPlaceObjectWindowless
STDMETHOD(SetObjectRects)(LPCRECT prcPos,LPCRECT prcClip);
// IViewObjectEx
DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
// IDDRadioButton
IMPLEMENT_CUSTOM_BOOL_PROPERTY(Enabled,m_Enabled,DISPID_ENABLED);
IMPLEMENT_CUSTOM_COLOR_PROPERTY(BackColor,m_BackColor,DISPID_BACKCOLOR);
IMPLEMENT_CUSTOM_COLOR_PROPERTY(ForeColor,m_ForeColor,DISPID_FORECOLOR);
IMPLEMENT_CUSTOM_FONT_PROPERTY(Font,m_spFontDisp,DISPID_FONT);
IMPLEMENT_CUSTOM_TEXT_PROPERTY(Text,m_Text,DISPID_TEXT);
IMPLEMENT_CUSTOM_PROPERTY(ddcpTextAlign,TextAlign,m_TextAlign,DISPID_TEXTALIGN);
IMPLEMENT_CUSTOM_PROPERTY(LONG,Value,m_Value,DISPID_VALUE_NOTDEFAULT);
STDMETHOD(get__Default)(LONG* pVal);
STDMETHOD(put__Default)(LONG newVal);
};