Retrieves the 0-based index of the item nearest the specified point
#include <GuiListBox.au3>
_GUICtrlListBox_ItemFromPoint ( $hWnd, $iX, $iY )
$hWnd | Control ID/Handle to the control |
$iX | X coordinate, relative to the upper-left corner of the client area |
$iY | Y coordinate, relative to the upper-left corner of the client area |
Success: | the index of the nearest item. |
Failure: | -1 if the point is outside of the client area. |
#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>
Example()
Func Example()
Local $idListBox
; Create GUI
GUICreate("List Box Item From Point", 400, 296)
$idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
GUISetState(@SW_SHOW)
; Add strings
_GUICtrlListBox_BeginUpdate($idListBox)
For $iI = 1 To 9
_GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
Next
_GUICtrlListBox_EndUpdate($idListBox)
; Item closest to point
MsgBox($MB_SYSTEMMODAL, "Information", "Item Closest to 30, 30: " & _GUICtrlListBox_ItemFromPoint($idListBox, 30, 30))
; Loop until the user exits.
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>Example