Sign in to follow this  
Followers 0
BBs19

_WinAPI_DefSubclassProc not working properly

3 posts in this topic

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>


OnAutoItExitRegister('OnAutoItExit')

; 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)
GUICtrlCreateTabItem("Search")
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) ;
GUISetState(@SW_SHOW)


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

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

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)
    DllCallbackFree($g_hDll)
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)

with

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

 

1 person likes this

Share this post


Link to post
Share on other sites
39 minutes ago, LarsJ said:

This is an old and well known issue. Just replace

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

with

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

 

Seems to be working fine, thanks. What a strange bug tho...

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  
Followers 0