Sometimes we need to right-click a project in ListBox and then bring up a menu to operate on the specified item. However, when right-click a item, it does not show the selected status. Only the left-click button is required, this obviously does not meet our requirements, but we can use an API function to process it a little, which is very convenient and practical.
Option explicit <br/> private declare sub mouse_event lib "USER32" (byval dwflags as long, byval DX as long, byval dy as long, byval cbuttons as long, byval dwextrainfo as long) <br/> private const mouseeventf_leftdown = & H2 'left button down <br/> private const mouseeventf_leftup = & H4 'left button up <br/> private sub form_load () <br/> dim I % <br/> for I = 1 to 5 <br/> list1.additem I <br/> next <br/> end sub <br/> private sub listparts mousedown (button as integer, shift as integer, X as single, y as single) <br/> If Button = 2 then <br/> mouse_event mouseeventf_leftdown, 0, 0, 0, 0 <br/> mouse_event mouseeventf_leftup, 0, 0, 0 <br/> end if <br/> end sub