CStockPropImpl Class

 

For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.

For the latest documentation on Visual Studio 2017, see CStockPropImpl Class on docs.microsoft.com. This class provides methods for supporting stock property values.

System_CAPS_ICON_important.jpg Important

This class and its members cannot be used in applications that execute in the Windows Runtime.

template <class T, class InterfaceName,
    const IID* piid = &_ATL_IIDOF(InterfaceName),
    const GUID* plibid = &CComModule::m_libid,
    WORD wMajor = 1,
    WORD wMinor = 0, class tihclass = CcomTypeInfoHolder>  
class ATL_NO_VTABLE CStockPropImpl : public IDispatchImpl<InterfaceName, piid,
 plibid,
    wMajor,
 wMinor,
    tihclass>

Parameters

T
The class implementing the control and deriving from CStockPropImpl.

InterfaceName
A dual interface exposing the stock properties.

piid
A pointer to the IID of InterfaceName.

plibid
A pointer to the LIBID of the type library containing the definition of InterfaceName.

wMajor
The major version of the type library. The default value is 1.

wMinor
The minor version of the type library. The default value is 0.

tihclass
The class used to manage the type information for T. The default value is CComTypeInfoHolder.

Public Methods

get_AppearanceCall this method to get the paint style used by the control, for example, flat or 3D.
get_AutoSizeCall this method to get the status of the flag that indicates if the control cannot be any other size.
get_BackColorCall this method to get the control's background color.
get_BackStyleCall this method to get the control's background style, either transparent or opaque.
get_BorderColorCall this method to get the control's border color.
get_BorderStyleCall this method to get the control's border style.
get_BorderVisibleCall this method to get the status of the flag that indicates if the control's border is visible or not.
get_BorderWidthCall this method to get the width (in pixels) of the control's border.
get_CaptionCall this method to get the text specified in an object's caption.
get_DrawModeCall this method to get the control's drawing mode, for example, XOR Pen or Invert Colors.
get_DrawStyleCall this method to get the control's drawing style, for example, solid, dashed, or dotted.
get_DrawWidthCall this method to get the drawing width (in pixels) used by the control's drawing methods.
get_EnabledCall this method to get the status of the flag that indicates if the control is enabled.
get_FillColorCall this method to get the control's fill color.
get_FillStyleCall this method to get the control's fill style, for example, solid, transparent, or cross-hatched.
get_FontCall this method to get a pointer to the control's font properties.
get_ForeColorCall this method to get the control's foreground color.
get_HWNDCall this method to get the window handle associated with the control.
get_MouseIconCall this method to get the picture properties of the graphic (icon, bitmap, or metafile) to be displayed when the mouse is over the control.
get_MousePointerCall this method to get the type of mouse pointer displayed when the mouse is over the control, for example, arrow, cross, or hourglass.
get_PictureCall this method to get a pointer to the picture properties of a graphic (icon, bitmap, or metafile) to be displayed.
get_ReadyStateCall this method to get the control's ready state, for example, loading or loaded.
get_TabStopCall this method to get the flag that indicates if the control is a tab stop or not.
get_TextCall this method to get the text that is displayed with the control.
getvalidCall this method to get the status of the flag that indicates if the control is valid or not.
get_WindowCall this method to get the window handle associated with the control. Identical to CStockPropImpl::get_HWND.
put_AppearanceCall this method to set the paint style used by the control, for example, flat or 3D.
put_AutoSizeCall this method to set the value of the flag that indicates if the control cannot be any other size.
put_BackColorCall this method to set the control's background color.
put_BackStyleCall this method to set the control's background style.
put_BorderColorCall this method to set the control's border color.
put_BorderStyleCall this method to set the control's border style.
put_BorderVisibleCall this method to set the value of the flag that indicates if the control's border is visible or not.
put_BorderWidthCall this method to set the width of the control's border.
put_CaptionCall this method to set the text to be displayed with the control.
put_DrawModeCall this method to set the control's drawing mode, for example, XOR Pen or Invert Colors.
put_DrawStyleCall this method to set the control's drawing style, for example, solid, dashed, or dotted.
put_DrawWidthCall this method to set the width (in pixels) used by the control's drawing methods.
put_EnabledCall this method to set the flag that indicates if the control is enabled.
put_FillColorCall this method to set the control's fill color.
put_FillStyleCall this method to set the control's fill style, for example, solid, transparent, or cross-hatched.
put_FontCall this method to set the control's font properties.
put_ForeColorCall this method to set the control's foreground color.
put_HWNDThis method returns E_FAIL.
put_MouseIconCall this method to set the picture properties of the graphic (icon, bitmap, or metafile) to be displayed when the mouse is over the control.
put_MousePointerCall this method to set the type of mouse pointer displayed when the mouse is over the control, for example, arrow, cross, or hourglass.
put_PictureCall this method to set the picture properties of a graphic (icon, bitmap, or metafile) to be displayed.
put_ReadyStateCall this method to set the control's ready state, for example, loading or loaded.
put_TabStopCall this method to set the value of the flag that indicates if the control is a tab stop or not.
put_TextCall this method to set the text that is displayed with the control.
putvalidCall this method to set the flag that indicates if the control is valid or not.
put_WindowThis method calls CStockPropImpl::put_HWND, which returns E_FAIL.
putref_FontCall this method to set the control's font properties, with a reference count.
putref_MouseIconCall this method to set the picture properties of the graphic (icon, bitmap, or metafile) to be displayed when the mouse is over the control, with a reference count.
putref_PictureCall this method to set the picture properties of a graphic (icon, bitmap, or metafile) to be displayed, with a reference count.

CStockPropImpl provides put and get methods for each stock property. These methods provide the code necessary to set or get the data member associated with each property and to notify and synchronize with the container when any property changes.

Visual C++ provides support for stock properties through its wizards. For more information about adding stock properties to a control, see the ATL Tutorial.

For backward compatibility, CStockPropImpl also exposes get_Window and put_Window methods that simply call get_HWND and put_HWND, respectively. The default implementation of put_HWND returns E_FAIL since HWND should be a read-only property.

The following properties also have a putref implementation:

  • Font

  • MouseIcon

  • Picture

The same three stock properties require their corresponding data member to be of type CComPtr or some other class that provides correct interface reference counting by means of the assignment operator.

T

IDispatchImpl

CStockPropImpl

Header: atlctl.h

Call this method to get the paint style used by the control, for example, flat or 3D.

HRESULT STDMETHODCALLTYPE get_Appearance(SHORT pnAppearance);

Parameters

pnAppearance
Variable that receives the control's paint style.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the status of the flag that indicates if the control cannot be any other size.

HRESULT STDMETHODCALLTYPE get_Autosize(VARIANT_BOOL* pbAutoSize);

Parameters

pbAutoSize
Variable that receives the flag status. TRUE indicates that the control cannot be any other size.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the control's background color.

HRESULT STDMETHODCALLTYPE get_BackColor(OLE_COLOR* pclrBackColor);

Parameters

pclrBackColor
Variable that receives the control's background color.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the control's background style, either transparent or opaque.

HRESULT STDMETHODCALLTYPE get_BackStyle(LONG* pnBackStyle);

Parameters

pnBackStyle
Variable that receives the control's background style.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the control's border color.

HRESULT STDMETHODCALLTYPE get_BorderColor(OLE_COLOR* pclrBorderColor);

Parameters

pclrBorderColor
Variable that receives the control's border color.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the control's border style.

HRESULT STDMETHODCALLTYPE get_BorderStyle(LONG* pnBorderStyle);

Parameters

pnBorderStyle
Variable that receives the control's border style.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the status of the flag that indicates if the control's border is visible or not.

HRESULT STDMETHODCALLTYPE get_BorderVisible(VARIANT_BOOL* pbBorderVisible);

Parameters

pbBorderVisible
Variable that receives the flag status. TRUE indicates that the control's border is visible.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the width of the control's border.

HRESULT STDMETHODCALLTYPE get_BorderWidth(LONG* pnBorderWidth);

Parameters

pnBorderWidth
Variable that receives the control's border width.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the text specified in an object's caption.

HRESULT STDMETHODCALLTYPE get_Caption(BSTR* pbstrCaption);

Parameters

pbstrCaption
The text to be displayed with the control.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the control's drawing mode, for example, XOR Pen or Invert Colors.

HRESULT STDMETHODCALLTYPE get_DrawMode(LONG* pnDrawMode);

Parameters

pnDrawMode
Variable that receives the control's drawing mode.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the control's drawing style, for example, solid, dashed, or dotted.

HRESULT STDMETHODCALLTYPE get_DrawStyle(LONG* pnDrawStyle);

Parameters

pnDrawStyle
Variable that receives the control's drawing style.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the drawing width (in pixels) used by the control's drawing methods.

HRESULT STDMETHODCALLTYPE get_DrawWidth(LONG* pnDrawWidth);

Parameters

pnDrawWidth
Variable that receives the control's width value, in pixels.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the status of the flag that indicates if the control is enabled.

HRESULT STDMETHODCALLTYPE get_Enabled(VARIANT_BOOL* pbEnabled);

Parameters

pbEnabled
Variable that receives the flag status. TRUE indicates that the control is enabled.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the control's fill color.

HRESULT STDMETHODCALLTYPE get_FillColor(OLE_COLOR* pclrFillColor);

Parameters

pclrFillColor
Variable that receives the control's fill color.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the control's fill style, for example, solid, transparent, or crosshatched.

HRESULT STDMETHODCALLTYPE get_FillStyle(LONG* pnFillStyle);

Parameters

pnFillStyle
Variable that receives the control's fill style.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get a pointer to the control's font properties.

HRESULT STDMETHODCALLTYPE get_Font(IFontDisp** ppFont);

Parameters

ppFont
Variable that receives a pointer to the control's font properties.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the control's foreground color.

HRESULT STDMETHODCALLTYPE get_ForeColor(OLE_COLOR* pclrForeColor);

Parameters

pclrForeColor
Variable that receives the controls foreground color.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the window handle associated with the control.

HRESULT STDMETHODCALLTYPE get_HWND(LONG_PTR* phWnd);

Parameters

phWnd
The window handle associated with the control.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the picture properties of the graphic (icon, bitmap, or metafile) to be displayed when the mouse is over the control.

HRESULT STDMETHODCALLTYPE get_MouseIcon(IPictureDisp** ppPicture);

Parameters

ppPicture
Variable that receives a pointer to the picture properties of the graphic.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the type of mouse pointer displayed when the mouse is over the control, for example, arrow, cross, or hourglass.

HRESULT STDMETHODCALLTYPE get_MousePointer(LONG* pnMousePointer);

Parameters

pnMousePointer
Variable that receives the type of mouse pointer.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get a pointer to the picture properties of a graphic (icon, bitmap, or metafile) to be displayed.

HRESULT STDMETHODCALLTYPE get_Picture(IPictureDisp** ppPicture);

Parameters

ppPicture
Variable that receives a pointer to the picture's properties. See IPictureDisp for more details.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the control's ready state, for example, loading or loaded.

HRESULT STDMETHODCALLTYPE get_ReadyState(LONG* pnReadyState);

Parameters

pnReadyState
Variable that receives the control's ready state.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the status of the flag that indicates if the control is a tab stop or not.

HRESULT STDMETHODCALLTYPE get_TabStop(VARIANT_BOOL* pbTabStop);

Parameters

pbTabStop
Variable that receives the flag status. TRUE indicates that the control is a tab stop.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the text that is displayed with the control.

HRESULT STDMETHODCALLTYPE get_Text(BSTR* pbstrText);

Parameters

pbstrText
The text that is displayed with the control.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the status of the flag that indicates if the control is valid or not.

HRESULT STDMETHODCALLTYPE getvalid(VARIANT_BOOL* pbValid);

Parameters

pbValid
Variable that receives the flag status. TRUE indicates that the control is valid.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to get the window handle associated with the control. Identical to CStockPropImpl::get_HWND.

HRESULT STDMETHODCALLTYPE get_Window(LONG_PTR* phWnd);

Parameters

phWnd
The window handle associated with the control.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the paint style used by the control, for example, flat or 3D.

HRESULT STDMETHODCALLTYPE put_Appearance(SHORT nAppearance);

Parameters

nAppearance
The new paint style to be used by the control.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the value of flag that indicates if the control cannot be any other size.

HRESULT STDMETHODCALLTYPE put_AutoSize(VARIANT_BOOL bAutoSize,);

Parameters

bAutoSize
TRUE if the control cannot be any other size.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the control's background color.

HRESULT STDMETHODCALLTYPE put_BackColor(OLE_COLOR clrBackColor);

Parameters

clrBackColor
The new control background color.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the control's background style.

HRESULT STDMETHODCALLTYPE put_BackStyle(LONG nBackStyle);

Parameters

nBackStyle
The new control background style.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the control's border color.

HRESULT STDMETHODCALLTYPE put_BorderColor(OLE_COLOR clrBorderColor);

Parameters

clrBorderColor
The new border color. The OLE_COLOR data type is internally represented as a 32-bit long integer.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the control's border style.

HRESULT STDMETHODCALLTYPE put_BorderStyle(LONG nBorderStyle);

Parameters

nBorderStyle
The new border style.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the value of the flag that indicates if the control's border is visible or not.

HRESULT STDMETHODCALLTYPE put_BorderVisible(VARIANT_BOOL bBorderVisible);

Parameters

bBorderVisible
TRUE if the border is to be visible.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the width of the control's border.

HRESULT STDMETHODCALLTYPE put_BorderWidth(LONG nBorderWidth);

Parameters

nBorderWidth
The new width of the control's border.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the text to be displayed with the control.

HRESULT STDMETHODCALLTYPE put_Caption(BSTR bstrCaption);

Parameters

bstrCaption
The text to be displayed with the control.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the control's drawing mode, for example, XOR Pen or Invert Colors.

HRESULT STDMETHODCALLTYPE put_DrawMode(LONG nDrawMode);

Parameters

nDrawMode
The new drawing mode for the control.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the control's drawing style, for example, solid, dashed, or dotted.

HRESULT STDMETHODCALLTYPE put_DrawStyle(LONG pnDrawStyle);

Parameters

nDrawStyle
The new drawing style for the control.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the width (in pixels) used by the control's drawing methods.

HRESULT STDMETHODCALLTYPE put_DrawWidth(LONG nDrawWidth);

Parameters

nDrawWidth
The new width to be used by the control's drawing methods.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the value of the flag that indicates if the control is enabled.

HRESULT STDMETHODCALLTYPE put_Enabled(VARIANT_BOOL bEnabled);

Parameters

bEnabled
TRUE if the control is enabled.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the control's fill color.

HRESULT STDMETHODCALLTYPE put_FillColor(OLE_COLOR clrFillColor);

Parameters

clrFillColor
The new fill color for the control.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the control's fill style, for example, solid, transparent, or cross-hatched.

HRESULT STDMETHODCALLTYPE put_FillStyle(LONG nFillStyle);

Parameters

nFillStyle
The new fill style for the control.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the control's font properties.

HRESULT STDMETHODCALLTYPE put_Font(IFontDisp* pFont);

Parameters

pFont
A pointer to the control's font properties.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the control's foreground color.

HRESULT STDMETHODCALLTYPE put_ForeColor(OLE_COLOR clrForeColor);

Parameters

clrForeColor
The new foreground color of the control.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

This method returns E_FAIL.

HRESULT STDMETHODCALLTYPE put_HWND(LONG_PTR /* hWnd */);

Parameters

/* hWnd */
Reserved.

Return Value

Returns E_FAIL.

Remarks

The window handle is a read-only value.

Call this method to set the picture properties of the graphic (icon, bitmap, or metafile) to be displayed when the mouse is over the control.

HRESULT STDMETHODCALLTYPE put_MouseIcon(IPictureDisp* pPicture);

Parameters

pPicture
A pointer to the picture properties of the graphic.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the type of mouse pointer displayed when the mouse is over the control, for example, arrow, cross, or hourglass.

HRESULT STDMETHODCALLTYPE put_MousePointer(LONG nMousePointer);

Parameters

nMousePointer
The type of mouse pointer.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the picture properties of a graphic (icon, bitmap, or metafile) to be displayed.

HRESULT STDMETHODCALLTYPE put_Picture(IPictureDisp* pPicture);

Parameters

pPicture
A pointer to the picture's properties. See IPictureDisp for more details.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the control's ready state, for example, loading or loaded.

HRESULT STDMETHODCALLTYPE put_ReadyState(LONG nReadyState);

Parameters

nReadyState
The control's ready state.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the flag that indicates if the control is a tab stop or not.

HRESULT STDMETHODCALLTYPE put_TabStop(VARIANT_BOOL bTabStop);

Parameters

bTabStop
TRUE if the control is a tab stop.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the text that is displayed with the control.

HRESULT STDMETHODCALLTYPE put_Text(BSTR bstrText);

Parameters

bstrText
The text that is displayed with the control.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Call this method to set the flag that indicates if the control is valid or not.

HRESULT STDMETHODCALLTYPE getvalid(VARIANT_BOOL bValid);

Parameters

bValid
TRUE if the control is valid.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

This method calls CStockPropImpl::put_HWND, which returns E_FAIL.

HRESULT STDMETHODCALLTYPE put_Window(LONG_PTR hWnd);

Parameters

hWnd
The window handle.

Return Value

Returns E_FAIL.

Remarks

The window handle is a read-only value.

Call this method to set the control's font properties, with a reference count.

HRESULT STDMETHODCALLTYPE putref_Font(IFontDisp* pFont);

Parameters

pFont
A pointer to the control's font properties.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Remarks

The same as CStockPropImpl::put_Font, but with a reference count.

Call this method to set the picture properties of the graphic (icon, bitmap, or metafile) to be displayed when the mouse is over the control, with a reference count.

HRESULT STDMETHODCALLTYPE putref_MouseIcon(IPictureDisp* pPicture);

Parameters

pPicture
A pointer to the picture properties of the graphic.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Remarks

The same as CStockPropImpl::put_MouseIcon, but with a reference count.

Call this method to set the picture properties of a graphic (icon, bitmap, or metafile) to be displayed, with a reference count.

HRESULT STDMETHODCALLTYPE putref_Picture(IPictureDisp* pPicture);

Parameters

pPicture
A pointer to the picture's properties. See IPictureDisp for more details.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Remarks

The same as CStockPropImpl::put_Picture, but with a reference count.

Class Overview
IDispatchImpl Class

Show: