Jump to content
Sign in to follow this  

_WinAPI_DefSubclassProc not working properly

Recommended Posts


Hi guys,

I ran into a problem with _WinAPI_DefSubclassProc. It seems like it is not properly calling the next handler as it should.

The below example is from the help file but with a Tab + Listview. When you switch between the tabs, the listview dissapears/is not painted properly. Only when you move over it with the mouse it appears back. Something is not properly handled here.

Is there something wrong the way I use it or the way it is used in the help file? Shouldn't _WinAPI_DefSubclassProc call the needed handlers so that everything works as it should?


#include <WinAPIShellEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>
#include <ListViewConstants.au3>


; Create GUI
Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'))

; Register DLL callback that will be used as window subclass procedure
Global $g_hDll = DllCallbackRegister('_SubclassProc', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr')
Global $g_pDll = DllCallbackGetPtr($g_hDll)
GUISetFont(12, 0, 0, "Segoe UI")
GUICtrlCreateTab(0, 50, 989, 574)
GUICtrlCreateListView("a|a|a|a|a|a|a", 5, 109, 981, 540) ;
GUICtrlCreateTabItem("Data Entry")
GUICtrlCreateListView("b|b|b|b|b|b|b", 5, 109, 981, 540) ;

; Install window subclass callback
_WinAPI_SetWindowSubclass($g_hForm, $g_pDll, 1000, 0)



Func _SubclassProc($hWnd, $iMsg, $wParam, $lParam, $iID, $pData)
    #forceref $iID, $pData
    ;Do stuff....
    Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>_SubclassProc

Func OnAutoItExit()
    _WinAPI_RemoveWindowSubclass($g_hForm, $g_pDll, 1000)
EndFunc   ;==>OnAutoItExit

Share this post

Link to post
Share on other sites

This is an old and well known issue. Just replace

Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)


Return DllCall( "comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam )[0]


  • Like 1

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.