[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 376
  • Last Modified:

How do I remotely DoubleClick an Item in a ListBox

I am trying to send select an Item in a remote listbox using

Call SendMessageByString(x, LB_SELECTSTRING, 0&, "Item")

and then send

Call SendMessage(x, WM_LBUTTONDBLCLK, 0&, 0&)

so that the listbox item is clicked. However this does not work.

I have tried to use

Call SendMessageByObject(x, WM_LBUTTONUP, 0&, 0)
Call SendMessageByObject(x, WM_LBUTTONDOWN, 0&, 0)
Call SendMessage(x, WM_LBUTTONDBLCLK, 0&, 0&)

But this just selects the first item in the list box, how can I use this sequence to select the item I want?

Thanks,
0
Veeden
Asked:
Veeden
  • 2
  • 2
1 Solution
 
angus_young_acdcCommented:
I'm guessing that the last 0 in the sequence is an index number.  In which case it will go to index 0 (which is generally the first in the list).  Try changing that value to the item you want and it should work.
0
 
danaseamanCommented:
Try this:

Call SendMessageByString(x, LB_SELECTSTRING, -1&, ByVal "Item")
Change "Item" to the caption of Item you want to select.

0
 
VeedenAuthor Commented:
I changed it to the code below. The same effect happens, the listbox opens the row "item" gets selected however, when WM_LBUTTONDBLCLK is issued the selected item does not get clicked.
     Call SendMessageByString(x, LB_SELECTSTRING, -1&, DesktopTitle)
     Call SendMessage(x, WM_LBUTTONDBLCLK, 0&, 0&)

Open in new window

0
 
VeedenAuthor Commented:
Also EddieShipman mentioned ( http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_22637243.html?sfQueryTermInfo=1+click+listbox)

how to do this, but I cant get the mouse coordinates to work properly
0
 
danaseamanCommented:
To get Mouse coordinates relative to a control use this code where m_hWnd is the handle of control:

Private Type POINTAPI    
   x    As Long
   y    As Long
End Type

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long

Dim pt As POINTAPI
GetCursorPos pt
ScreenToClient m_hWnd, pt
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now