Name

SetWindowLongPtr

Synopsis

Modifies the properties of a window:

Declare Function SetWindowLongPtr Lib "user32" Alias "SetWindowLongA" _
			(ByVal hwnd As Long, _
			ByVal nIndex As Long, _
			ByVal dwNewLong As Long) As Long

Parameters

hwnd

The handle of the window whose attribute is to be modified. 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 replace a window procedure is GWLP_WNDPROC, or -4.

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

If successful, the function returns the original value before replacement (in this case, the original address of the window procedure). If it fails, it returns 0.

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.