Click to Rate and Give Feedback
MSDN
MSDN Library
User Interface
Windows Shell
Shell Reference
Shell Functions
 SetWindowSubclass Function

  Switch on low bandwidth view
SetWindowSubclass Function

Installs or updates a window subclass callback.

Syntax

BOOL SetWindowSubclass(      
    HWND hWnd,     SUBCLASSPROC pfnSubclass,     UINT_PTR uIdSubclass,     DWORD_PTR dwRefData );

Parameters

hWnd
[in] The handle of the window being subclassed.
pfnSubclass
[in] A pointer to a window procedure. This pointer and the subclass ID uniquely identify this subclass callback. For the callback function prototype, see SUBCLASSPROC.
uIdSubclass
[in] The subclass ID. This ID together with the subclass procedure uniquely identify a subclass. To remove a subclass, pass the subclass procedure and this value to the RemoveWindowSubclass function. This value is passed to the subclass procedure in the uIdSubclass parameter.
dwRefData
[in] DWORD_PTR to reference data. The meaning of this value is determined by the calling application. This value is passed to the subclass procedure in the dwRefData parameter. A different dwRefData is associated with each combination of window handle, subclass procedure and uIdSubclass.

Return Value

TRUE if the subclass callback was successfully installed; otherwise, FALSE.

Remarks

Subclass callbacks are identified by the combination of the callback address and the caller-defined subclass ID. If the callback address and ID pair have not yet been installed, then this function installs the subclass. If the pair has already been installed, then this function just updates the reference data.

Each callback can store a single DWORD of reference data, which is passed to the callback function when it is called to filter messages. No reference counting is performed for the callback; it may repeatedly call SetWindowSubclass to alter the value of its reference data element.

Warning  You cannot use the subclassing helper functions to subclass a window across threads.

Function Information

Minimum DLL Versioncomctl32.dll version 5.8 or later
Custom ImplementationNo
Headercommctrl.h
Import librarycomctl32.lib
Minimum operating systems Windows XP

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker