Name

SetClassLongPtr

Synopsis

Replaces the specified member of the WNDCLASSEX structure of a window:

Public Declare Function SetClassLongPtr Lib "user32" Alias "SetClassLongA" _
		(ByVal hwnd As Long, ByVal nIndex As Long, _
		ByVal dwNewLong As Long) As Long

Parameters

hwnd

The handle to a window that was created using the class we want to modify. You can obtain it by retrieving the value of a form or control’s hWnd property.

nIndex

A Long indicating the window attribute to be modified. A number of values are possible, though the value used to modify the window procedure is GCLP_WNDPROC, or -24.

dwNewLong

The replacement value. For a subclassed window, this parameter represents the address of the new window procedure. You can get the address of your new window procedure by passing its name as an argument to the AddressOf operator.

Return Value

The return value of this function will be the original value in the class structure that was replaced with the value in the dwNewLong argument. For our purposes, this function will return a zero if an error occurred, or the address of the original class window procedure if it was successful.

Get Subclassing and Hooking with Visual Basic now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.