We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

How do I remotely DoubleClick an Item in a ListBox

Medium Priority
402 Views
Last Modified: 2013-12-20
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,
Comment
Watch Question

CERTIFIED EXPERT

Commented:
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.
Dana SeamanDana Seaman (danaseaman)

Commented:
Try this:

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

Author

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

Author

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
Dana Seaman (danaseaman)
Commented:
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.