Issue with ListView HWND and GetClassName (Can anyone else reproduce this?)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
JFord
Posts: 16
Joined: 11 Oct 2015, 04:56

Issue with ListView HWND and GetClassName (Can anyone else reproduce this?)

07 May 2021, 08:00

My attempt to instantiate an LV_Colors object was failing and it led me to breakdown the cause to the inability of GetClassName to get a handle on the ListView control based on its HWND. The following short code works perfectly on my laptop, but it will fail on less powerful machines randomly, but often.

Code: Select all

Gui Add, ListView, HwndThisHWND, A|B
VarSetCapacity(Class, 512, 0)
DllCall("GetClassName", "Ptr", ThisHWND, "Str", Class, "Int", 256)
If (Class == "")
	MsgBox Failed
Gui Destroy
ExitApp
I have thousands of other observations, but I will stop here and wait for feedback.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Issue with ListView HWND and GetClassName (Can anyone else reproduce this?)

08 May 2021, 09:03

it led me to breakdown the cause to the inability of GetClassName to get a handle on the ListView control based on its HWND.
doubt thats the problem. also how would u even know if thats the case? u arent checking it. and no, If (Class == "") is not checking it
getclassname wrote:If the function fails, the return value is zero. To get extended error information, call GetLastError function.
so check the return val, A_LastError and since its DllCall were talking about might as well check ErrorLevel while ure at it

also, just use WinGetClass theClass, ahk_id %theHwnd% but again - this probably isnt the source of ur issues
JFord
Posts: 16
Joined: 11 Oct 2015, 04:56

Re: Issue with ListView HWND and GetClassName (Can anyone else reproduce this?)

12 May 2021, 17:59

Thanks for your reply. I am not sure why I did not see it earlier.

I improved my error checking to determine that the underlying error is 1400 (0x578) ERROR_INVALID_WINDOW_HANDLE. Don't know how much we learned from that. I did also confirm that using WinGetClass worked perfectly.

The good news (for me) is that this is all moot as I have recognized that I don't need to take this route at all and so my problem is resolved without every understanding why this code failed.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: CrowexBR and 277 guests