Modify

#4090 new Bug

x64 - GUI freezes with Header subclassing in ListView

Reported by: Nine Owned by:
Milestone: Component: AutoIt
Version: 3.3.18.0 Severity: None
Keywords: Cc:

Description (last modified by mLipok)

It is a very basic example. It may takes a little while to get it frozen. You need to modify the size of the columns repeatedly. It happens both x86 and x64 but more often with the later.

#AutoIt3Wrapper_UseX64=y

; From Nine
#include <GuiConstants.au3>
#include <WinAPI.au3>
#include <GuiListView.au3>

Example()

Func Example()
  Local $hGUI = GUICreate("Header issue", 500, 300)

  Local $idListView = GUICtrlCreateListView("Items List|SubItems1|SubItems2", 10, 10, 480, 280, -1, $LVS_EX_DOUBLEBUFFER)
  Local $hListView = GUICtrlGetHandle($idListView)
  Local $hHeader = GUICtrlSendMsg($idListView, $LVM_GETHEADER, 0, 0)

  Local $hSubClass = DllCallbackRegister(WM_NOTIFY, "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr")
  _WinAPI_SetWindowSubclass($hHeader, DllCallbackGetPtr($hSubClass), 1000)

  For $i = 1 To 5
    GUICtrlCreateListViewItem("item" & $i & "|item" & $i & "|item" & $i , $idListview)
  Next

  GUISetState()

  Do
  Until GUIGetMsg() = $GUI_EVENT_CLOSE

  _WinAPI_RemoveWindowSubclass($hHeader, DllCallbackGetPtr($hSubClass), 1000)
  DllCallbackFree($hSubClass)
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam, $iID, $pData)
  Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>WM_NOTIFY

Attachments (0)

Change History (7)

comment:1 by mLipok, on May 10, 2026 at 1:30:23 AM

Description: modified (diff)
Summary: GUI freezes with Header subclassing in ListViewx64 - GUI freezes with Header subclassing in ListView

comment:2 by Jpm, on May 11, 2026 at 5:35:06 PM

I try the script without any success to reproduce
help!!!

comment:3 by mLipok, on May 11, 2026 at 8:39:43 PM

100% Example.

;~ https://www.autoitscript.com/trac/autoit/ticket/4090

#AutoIt3Wrapper_UseX64=y

; From Nine
#include <GuiConstants.au3>
#include <WinAPI.au3>
#include <GuiListView.au3>

Example()

Func Example()
        Local $hGUI = GUICreate("Header issue", 500, 300)
        #forceref $hGUI

        Local $idListView = GUICtrlCreateListView("Items List|SubItems1|SubItems2", 10, 10, 480, 280, -1, $LVS_EX_DOUBLEBUFFER)
        Local $hListView = GUICtrlGetHandle($idListView)
        #forceref $hListView
        Local $hHeader = GUICtrlSendMsg($idListView, $LVM_GETHEADER, 0, 0)

        Local $hSubClass = DllCallbackRegister(WM_NOTIFY, "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr")
        _WinAPI_SetWindowSubclass($hHeader, DllCallbackGetPtr($hSubClass), 1000)

        For $i = 1 To 5
                GUICtrlCreateListViewItem("item" & $i & "|item" & $i & "|item" & $i, $idListView)
        Next

        GUISetState()

        Do
                _GUICtrlListView_SetColumnWidth($hListView, 0, Random(10,200,1))
        Until GUIGetMsg() = $GUI_EVENT_CLOSE

        _WinAPI_RemoveWindowSubclass($hHeader, DllCallbackGetPtr($hSubClass), 1000)
        DllCallbackFree($hSubClass)
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam, $iID, $pData)
        #forceref $iID, $pData
        Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>WM_NOTIFY

comment:4 by mLipok, on May 11, 2026 at 8:43:54 PM

To fix it a little you can add Sleep(50)

        Do
                _GUICtrlListView_SetColumnWidth($hListView, 0, Random(10,200,1))
                Sleep(50)
        Until GUIGetMsg() = $GUI_EVENT_CLOSE

But still drag the window over tittle bar and ListView will hung.

comment:6 by Jpm, on May 12, 2026 at 4:03:12 PM

Trying I understand the pb I use the_WMDEBUG.au3 extras helpfile
and I get the display of the subclass notification
I am impress that for one change so many notifications
So I am sure I cannot find when a notifification will be desynchronised
I propose to close it as "will not be fixed"

with the following script

#AutoIt3Wrapper_UseX64=y
; From Nine
#include <GuiConstants.au3>
#include <WinAPI.au3>
#include <GuiListView.au3>

#include "C:\Program Files (x86)\AutoIt3\Examples\Helpfile\Extras\WMDebug.au3"

Example()

Func Example()
	Local $hGUI = GUICreate("Header issue", 500, 300)
	#forceref $hGUI

	Local $idListView = GUICtrlCreateListView("Items List|SubItems1|SubItems2", 10, 10, 480, 280, -1, $LVS_EX_DOUBLEBUFFER)
	Local $hListView = GUICtrlGetHandle($idListView)
	#forceref $hListView
	Local $hHeader = Ptr(GUICtrlSendMsg($idListView, $LVM_GETHEADER, 0, 0))

;~ 	Local $hSubClass = DllCallbackRegister(WM_NOTIFY, "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr")
;~ 	_WinAPI_SetWindowSubclass($hHeader, DllCallbackGetPtr($hSubClass), 1000)

	For $i = 1 To 1
		GUICtrlCreateListViewItem("item" & $i & "|item" & $i & "|item" & $i, $idListView)
	Next

	GUISetState()

	Local $hSubClass = DllCallbackRegister(WM_NOTIFY, "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr")
	_WinAPI_SetWindowSubclass($hHeader, DllCallbackGetPtr($hSubClass), 1000)

;~ 	Do;
	For $i = 0 To 1
		_GUICtrlListView_SetColumnWidth($hListView, 0, Random(10, 200, 1))
	Next

;~ 	Until GUIGetMsg() = $GUI_EVENT_CLOSE

	ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hHeader = ' & $hHeader & @CRLF & '>Error code: ' & @error & '    Extended code: ' & @extended & ' (0x' & Hex(@extended) & ')' & @CRLF) ;### Debug Console
	_WinAPI_RemoveWindowSubclass($hHeader, DllCallbackGetPtr($hSubClass), 1000)
	DllCallbackFree($hSubClass)
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam, $iID, $pData)
	#forceref $iID, $pData
	_WM_Debug($hWnd, $iMsg, $wParam, $lParam)

	Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>WM_NOTIFY

notifications log

WP = 0x0000000000000000 | LP = 0x0000000010DDD4E0 | 0x120B
WP = 0x0000000000000000 | LP = 0x0000000010DDD490 | 0x120C
WP = 0x0000000000000000 | LP = 0x0000000010DD9C80 | 0x120B
WP = 0x00000000F1011140 | LP = 0x0000000000000000 | WM_ERASEBKGND
WP = 0x00000000F1011140 | LP = 0x0000000000000000 | WM_ERASEBKGND
WP = 0x00000000F1011140 | LP = 0x0000000000000000 | WM_ERASEBKGND
WP = 0x00000000F1011140 | LP = 0x0000000000000000 | WM_ERASEBKGND
WP = 0x00000000F1011140 | LP = 0x0000000000000000 | WM_ERASEBKGND
WP = 0x00000000F1011140 | LP = 0x0000000000000000 | WM_ERASEBKGND
WP = 0x00000000F1011140 | LP = 0x0000000000000000 | WM_ERASEBKGND
WP = 0x00000000F1011140 | LP = 0x0000000000000000 | WM_ERASEBKGND
WP = 0x0000000000000000 | LP = 0x0000000000000000 | WM_PAINT
WP = 0x0000000000000000 | LP = 0x0000000010DD9BF0 | 0x1207
WP = 0x0000000000000000 | LP = 0x0000000010DD9978 | 0x1205
WP = 0x0000000000000000 | LP = 0x0000000010DD98D0 | WM_WINDOWPOSCHANGING
WP = 0x0000000000000002 | LP = 0x0000000000000000 | 0x120F
WP = 0x0000000000000002 | LP = 0x0000000010DD96F0 | 0x120B
WP = 0x0000000000000002 | LP = 0x0000000010DD96E0 | 0x1207
WP = 0x0000000000000000 | LP = 0x0000000000000000 | WM_PAINT
WP = 0x00000000F1011140 | LP = 0x0000000000000000 | WM_ERASEBKGND
WP = 0x0000000000000000 | LP = 0x0000000010DD8530 | 0x1207
WP = 0x0000000000000000 | LP = 0x0000000000000000 | 0x120F
WP = 0x0000000000000000 | LP = 0x0000000010DD8910 | 0x120B
WP = 0x0000000000000000 | LP = 0x0000000010DD8400 | 0x1207
WP = 0x0000000000000001 | LP = 0x0000000000000000 | 0x120F
WP = 0x0000000000000001 | LP = 0x0000000010DD8910 | 0x120B
WP = 0x0000000000000001 | LP = 0x0000000010DD8650 | 0x1207
WP = 0x0000000000000002 | LP = 0x0000000000000000 | 0x120F
WP = 0x0000000000000002 | LP = 0x0000000010DD8910 | 0x120B
WP = 0x0000000000000002 | LP = 0x0000000010DD8650 | 0x1207
WP = 0x0000000000000000 | LP = 0x0000000010DD8530 | 0x1207
WP = 0x0000000000000000 | LP = 0x0000000000000000 | 0x120F
WP = 0x0000000000000000 | LP = 0x0000000010DD8910 | 0x120B
WP = 0x0000000000000000 | LP = 0x0000000010DD8400 | 0x1207
WP = 0x0000000000000001 | LP = 0x0000000000000000 | 0x120F
WP = 0x0000000000000001 | LP = 0x0000000010DD8910 | 0x120B
WP = 0x0000000000000001 | LP = 0x0000000010DD8650 | 0x1207
WP = 0x0000000000000002 | LP = 0x0000000000000000 | 0x120F
WP = 0x0000000000000002 | LP = 0x0000000010DD8910 | 0x120B
WP = 0x0000000000000002 | LP = 0x0000000010DD8650 | 0x1207
WP = 0x0000000000000000 | LP = 0x0000000010DDD4E0 | 0x120B
WP = 0x0000000000000000 | LP = 0x0000000010DDD490 | 0x120C
WP = 0x0000000000000000 | LP = 0x0000000010DD9C80 | 0x120B
WP = 0x00000000F1011140 | LP = 0x0000000000000000 | WM_ERASEBKGND
WP = 0x00000000F1011140 | LP = 0x0000000000000000 | WM_ERASEBKGND
WP = 0x00000000F1011140 | LP = 0x0000000000000000 | WM_ERASEBKGND
WP = 0x0000000000000000 | LP = 0x0000000000000000 | WM_PAINT
WP = 0x0000000000000000 | LP = 0x0000000010DD9BF0 | 0x1207
WP = 0x0000000000000000 | LP = 0x0000000010DD9978 | 0x1205
WP = 0x0000000000000000 | LP = 0x0000000010DD98D0 | WM_WINDOWPOSCHANGING
WP = 0x0000000000000002 | LP = 0x0000000000000000 | 0x120F
WP = 0x0000000000000002 | LP = 0x0000000010DD96F0 | 0x120B
WP = 0x0000000000000002 | LP = 0x0000000010DD96E0 | 0x1207
WP = 0x0000000000000000 | LP = 0x0000000000000000 | WM_PAINT
WP = 0x00000000F1011140 | LP = 0x0000000000000000 | WM_ERASEBKGND
WP = 0x0000000000000000 | LP = 0x0000000010DD8530 | 0x1207
WP = 0x0000000000000000 | LP = 0x0000000000000000 | 0x120F
WP = 0x0000000000000000 | LP = 0x0000000010DD8910 | 0x120B
WP = 0x0000000000000000 | LP = 0x0000000010DD8400 | 0x1207
WP = 0x0000000000000001 | LP = 0x0000000000000000 | 0x120F
WP = 0x0000000000000001 | LP = 0x0000000010DD8910 | 0x120B
WP = 0x0000000000000001 | LP = 0x0000000010DD8650 | 0x1207
WP = 0x0000000000000002 | LP = 0x0000000000000000 | 0x120F
WP = 0x0000000000000002 | LP = 0x0000000010DD8910 | 0x120B
WP = 0x0000000000000002 | LP = 0x0000000010DD8650 | 0x1207
WP = 0x0000000000000000 | LP = 0x0000000010DD8530 | 0x1207
WP = 0x0000000000000000 | LP = 0x0000000000000000 | 0x120F
WP = 0x0000000000000000 | LP = 0x0000000010DD8910 | 0x120B
WP = 0x0000000000000000 | LP = 0x0000000010DD8400 | 0x1207
WP = 0x0000000000000001 | LP = 0x0000000000000000 | 0x120F
WP = 0x0000000000000001 | LP = 0x0000000010DD8910 | 0x120B
WP = 0x0000000000000001 | LP = 0x0000000010DD8650 | 0x1207
WP = 0x0000000000000002 | LP = 0x0000000000000000 | 0x120F
WP = 0x0000000000000002 | LP = 0x0000000010DD8910 | 0x120B
WP = 0x0000000000000002 | LP = 0x0000000010DD8650 | 0x1207eher

comment:7 by anonymous, on May 23, 2026 at 5:21:06 PM

https://www.autoitscript.com/forum/topic/213640-how-can-you-customdraw-listview-header-by-state-cdis_hot-etc/#comment-1551835

If subclass the Header control and handle the ListView via GUIRegisterMsg, it works.
but the script crashes if remove GUIRegisterMsg and use two separate DllCallbackRegister for subclassing.
What exactly is happening within the AutoIt internals to cause this?

This worked:

Local $HeaderSubClass = DllCallbackRegister(Header_Subclass, "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr")
_WinAPI_SetWindowSubclass($hHeader, DllCallbackGetPtr($HeaderSubClass), 1001, $hHeader)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

but this Crashed:

Local $ListviewSubClass = DllCallbackRegister(Listview_Subclass, "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr")
Local $HeaderSubClass = DllCallbackRegister(Header_Subclass, "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr")
_WinAPI_SetWindowSubclass($hListview, DllCallbackGetPtr($ListviewSubClass), 5001, $hHeader)
_WinAPI_SetWindowSubclass($hHeader, DllCallbackGetPtr($HeaderSubClass), 1001, $hHeader)

Modify Ticket

Action
as new The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.