Uredi

Deli z drugimi prek


Window Class Macros

These macros define window class utilities.

Name Description
DECLARE_WND_CLASS Allows you to specify the name of a new window class.
DECLARE_WND_CLASS2 (Visual Studio 2017) Allows you to specify the name of a new window class and the enclosing class whose window procedure the new class will use.
DECLARE_WND_SUPERCLASS Allows you to specify the name of an existing window class on which a new window class will be based.
DECLARE_WND_CLASS_EX Allows you to specify the parameters of a class.

Requirements

Header: atlwin.h

DECLARE_WND_CLASS

Allows you to specify the name of a new window class. Place this macro in an ATL ActiveX control's control class.

DECLARE_WND_CLASS( WndClassName )

Parameters

WndClassName
[in] The name of the new window class. If NULL, ATL will generate a window class name.

Remarks

If you are using the /permissive- compiler option, then DECLARE_WND_CLASS will cause a compiler error; use DECLARE_WND_CLASS2 instead.

DECLARE_WND_CLASS allows you to specify the name of a new window class whose information will be managed by CWndClassInfo. DECLARE_WND_CLASS defines the new window class by implementing the following static function:

static CWndClassInfo& GetWndClassInfo();

DECLARE_WND_CLASS specifies the following styles for the new window:

  • CS_HREDRAW

  • CS_VREDRAW

  • CS_DBLCLKS

DECLARE_WND_CLASS also specifies the default window's background color. Use the DECLARE_WND_CLASS_EX macro to provide your own styles and background color.

CWindowImpl uses the DECLARE_WND_CLASS macro to create a window based on a new window class. To override this behavior, use the DECLARE_WND_SUPERCLASS macro, or provide your own implementation of the GetWndClassInfo function.

For more information about using windows in ATL, see the article ATL Window Classes.

DECLARE_WND_CLASS2

(Visual Studio 2017) Similar to DECLARE_WND_CLASS, but with an extra parameter that avoids a dependent name error when compiling with the /permissive- option.

DECLARE_WND_CLASS2( WndClassName, EnclosingClass )

Parameters

WndClassName
[in] The name of the new window class. If NULL, ATL will generate a window class name.

EnclosingClass
[in] The name of the window class that encloses the new window class. Cannot be NULL.

Remarks

If you are using the /permissive- option, then DECLARE_WND_CLASS will cause a compilation error because it contains a dependent name. DECLARE_WND_CLASS2 requires you to explicitly name the class that this macro is used in and does not cause the error under the /permissive- flag. Otherwise this macro is identical to DECLARE_WND_CLASS.

DECLARE_WND_SUPERCLASS

Allows you to specify the parameters of a class. Place this macro in an ATL ActiveX control's control class.

DECLARE_WND_SUPERCLASS( WndClassName, OrigWndClassName )

Parameters

WndClassName
[in] The name of the window class that will superclass OrigWndClassName. If NULL, ATL will generate a window class name.

OrigWndClassName
[in] The name of an existing window class.

Remarks

This macro allows you to specify the name of a window class that will superclass an existing window class. CWndClassInfo manages the information of the superclass.

DECLARE_WND_SUPERCLASS implements the following static function:

static CWndClassInfo& GetWndClassInfo();

By default, CWindowImpl uses the DECLARE_WND_CLASS macro to create a window based on a new window class. By specifying the DECLARE_WND_SUPERCLASS macro in a CWindowImpl-derived class, the window class will be based on an existing class but will use your window procedure. This technique is called superclassing.

Besides using the DECLARE_WND_CLASS and DECLARE_WND_SUPERCLASS macros, you can override the GetWndClassInfo function with your own implementation.

For more information about using windows in ATL, see the article ATL Window Classes.

DECLARE_WND_CLASS_EX

Allows you to specify the name of an existing window class on which a new window class will be based. Place this macro in an ATL ActiveX control's control class.

DECLARE_WND_CLASS_EX( WndClassName, style, bkgnd )

Parameters

WndClassName
[in] The name of the new window class. If NULL, ATL will generate a window class name.

style
[in] The style of the window.

bkgnd
[in] The background color of the window.

Remarks

This macro allows you to specify the class parameters of a new window class, whose information will be managed by CWndClassInfo. DECLARE_WND_CLASS_EX defines the new window class by implementing the following static function:

static CWndClassInfo& GetWndClassInfo();

If you want to use the default styles and background color, use the DECLARE_WND_CLASS macro. For more information about using windows in ATL, see the article ATL Window Classes.

See also

Macros