Microsoft KB Archive/32519

{|
 * width="100%"|

HOWTO: Use SetClassLong Function to Subclass a Window Class

 * }

Q32519

-

The information in this article applies to:


 * Microsoft Windows Software Development Kit (SDK)
 * Microsoft Win32 Software Development Kit (SDK)

-

SUMMARY
It is possible to subclass an entire window class by using the SetClassLong function. However, doing so will only subclass windows of that class created after the call to the SetClassLong function. Windows created before the call to the SetClassLong function are not affected.

In Win32, SetClassLong only affects Windows in the same address space. For example, if you subclass EDIT, only edit controls created in your application will be subclassed.

NOTE: This function has been superceded by the SetClassLongPtr function. To write code that is compatible with both 32-bit and 64-bit versions of Windows, use SetClassLongPtr.

MORE INFORMATION
Calling the SetClassLong function with the GCL_WNDPROC index changes the class function address for that window class, creating a subclass of the window class. When a subsequent window of that class is created, the new class function address is inserted into its window structure, subclassing the new window. Windows created before the call to the SetClassLong function (in other words, before the class function address was changed) are not subclassed.

An application should not use the SetClassLong function to subclass standard Windows controls such as edit controls or buttons. If, for example, an application were to subclass the entire &quot;edit&quot; class, then subsequent edit controls created by other applications would be subclassed.

An application can subclass individual standard Windows controls that it has created by calling the SetWindowLong function.

Additional query words: listbox scrollbar

Keywords : kbOSWinNT kbOSWin2000 kbSDKWin32 kbGrpDSUser kbOSWin kbWndw kbWndwClass kbWndwProc

Issue type : kbhowto

Technology : kbWin32SDKSearch kbAudDeveloper kbSDKSearch kbWin32sSearch kbWinSDKSearch