The Window-Class Macros

[Previous] [Next]

To declare a window class, the CWindowImpl-derived class needs to supply an implementation of the function GetWndClassInfo, which returns a CWndClassInfo reference. CWndClassInfo is essentially an encapsulation of the WNDCLASSEX structure. GetWndClassInfo is called in the CWindowImpl::Create function. ATL provides an implementation of GetWndClassInfo in the DECLARE_WND_CLASS(WndClassName) macro. You provide the window class name as an argument to DECLARE_WND_CLASS, and ATL provides defaults for the rest. If you don't want to supply the class name, you can pass in NULL for the class name and ATL will generate one for you. The generated name has the format "ATL:XXXXXXXX," in which X is a hex digit based on the address of the WNDCLASSEX structure contained in CWndClassInfo. When you use the macro, the code to declare a new window class named by ATL is trivial:

 DECLARE_WND_CLASS(NULL); 

By default, the class gets the class styles CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS and system background color COLOR_WINDOW. To supply your own styles and background color, use the DECLARE_WND_CLASS_EX(WndClassName, style, bkgnd) macro instead.

If you want to create a window class based on an existing window class, use the DECLARE_WND_SUPERCLASS(WndClassName, OrigWndClassName) macro. For example, you might want to extend the Win32 common tab control to encapsulate your own flavor of owner-drawn tabs. You can get all the default common control message processing—plus your own custom processing—by declaring a new tab window class, like this:

 #include <commctrl.h>  DECLARE_WND_SUPERCLASS(_T("InsideATLTabCtrl"),     _T("SysTabControl32")) 



Inside Atl
Inside ATL (Programming Languages/C)
ISBN: 1572318589
EAN: 2147483647
Year: 1998
Pages: 127

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net