BBs19 Posted September 11, 2017 Share Posted September 11, 2017 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? expandcollapse popup#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 Link to comment Share on other sites More sharing options...
LarsJ Posted September 11, 2017 Share Posted September 11, 2017 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] BBs19 1 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
BBs19 Posted September 11, 2017 Author Share Posted September 11, 2017 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... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now