#3582 closed Bug (Fixed)
Bug in _WinAPI_GetGUIThreadInfo with caret rectangle
Reported by: | linton.miller@… | Owned by: | Jon |
---|---|---|---|
Milestone: | 3.3.14.3 | Component: | AutoIt |
Version: | 3.3.14.2 | Severity: | None |
Keywords: | Cc: |
Description
The _WinAPI_GetGUIThreadInfo does not return correct information for the caret bounding rectangle, in elements 7-10 of the return array. That can be observed using the demo program from the help documentation for _WinAPI_GetGUIThreadInfo, or the following block
#include <WinAPISys.au3> Local $iPID Local $aInfo[11] $aInfo = _WinAPI_GetGUIThreadInfo(_WinAPI_GetWindowThreadProcessId(WinGetHandle('[ACTIVE]'), $iPID)) MsgBox(0, "_WinAPI_GetGUIThreadInfo Bug", _ "Active window caret: "&$ainfo[7]&" "&$ainfo[8]&" "&$ainfo[9]&" "&$ainfo[10] & @CRLF & _ "Caret window "&$ainfo[6]&" incorrectly equals caret x pos "&$ainfo[7])
The bug is a straightforward error in the UDF, referencing the wrong element of the DLL return struct.
For $i = 1 To 4 $aResult[6 + $i] = DllStructGetData($tGTI, 6 + 2, $i) ;<-- Second arg should be element 9, not 8 Next
Also noted, for strict compliance, the $tagGUITHREADINFO DLLStruct should be properly declared with struct to ensure alignment of the rcCaret rect.
While a slightly more verbose DLLStruct definition, spelling out each of the rect members results in simpler code to copy the data out of the struct (and solves the bug by simply getting rid of the need for the loop with the buggy reference).
Func _WinAPI_GetGUIThreadInfo($iThreadId) Local Const $tagGUITHREADINFO = 'dword Size;dword Flags;hwnd hWndActive;hwnd hWndFocus;hwnd hWndCapture;hwnd hWndMenuOwner;hwnd hWndMoveSize;hwnd hWndCaret;struct rcCaret;long left;long top;long right;long bottom;endstruct' Local $tGTI = DllStructCreate($tagGUITHREADINFO) DllStructSetData($tGTI, 1, DllStructGetSize($tGTI)) Local $aRet = DllCall('user32.dll', 'bool', 'GetGUIThreadInfo', 'dword', $iThreadId, 'struct*', $tGTI) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Local $aResult[11] For $i = 0 To 10 $aResult[$i] = DllStructGetData($tGTI, $i + 2) Next For $i = 9 To 10 $aResult[$i] -= $aResult[$i - 2] Next Return $aResult EndFunc ;==>_WinAPI_GetGUIThreadInfo
Attachments (0)
Change History (2)
comment:1 Changed 7 years ago by Jpm
- Milestone set to 3.3.15.1
- Owner set to Jpm
- Resolution set to Fixed
- Status changed from new to closed
comment:2 Changed 7 years ago by Jon
- Milestone changed from 3.3.15.1 to 3.3.14.3
- Owner changed from Jpm to Jon
Fixed by revision [11942] in version: 3.3.14.3
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
Fixed by revision [11941] in version: 3.3.15.1