I want to position the cursor on a selected item in a multiple-selection listbox. The following code does not work. What am I doing wrong?
Code:
SUB CursorToLBItem(BYVAL hPrnt AS LONG,_ BYVAL idlist AS LONG) LOCAL hList,cnt AS LONG LOCAL rc AS rect LOCAL pt AS POINTAPI hList = GetDlgItem(hPrnt,idlist) cnt = Sendmessage(hList,%LB_GETCOUNT,0,0) IF cnt THEN DIM selitems(cnt - 1) AS LONG CALL Sendmessage(hList,%LB_GETSELITEMS,cnt,VARPTR(selitems(0))) CALL SendMessage(hList, %LB_GETITEMRECT,selitems(0), VARPTR(rc)) MapWindowPoints hList, hPrnt, rc, 2 pt.x = (rc.nRight - rc.nLeft) / 2 pt.y = rc.nTop + (rc.nBottom - rc.nTop) / 2 SetCursorPos pt.x,pt.y END IF END SUB
Comment