HOME   DOWNLOADS   ORDER ONLINE   CONTACT US



 OVERVIEW
 
 DOWNLOAD
 
 ORDER ONLINE
 
 KNOWLEDGE
 BASE

How to use the RightButton property

Windows95, NT4 and Win2K are much improved with the use of popup menus, and SBList has a RightButton property to help you take advantage of this feature. A standard list box does not react to right-mouse clicks in the same way it does to left-mouse clicks, so you must first select a list item by left-clicking it, and then right-click it to pop up a menu. SBList allows you to select list items with the right mouse button, which makes life much easier!

When you show a popup menu, it is a Windows convention that any irrelevant menu items are hidden in order to make the menu as compact as possible. To do this, you need to know whether the user has right-clicked on a list item or in the space which follows the last item in the list. To do this, you can use this formula:

Sub SBList1_MouseUp(Button%, Shift%, X&, Y&)
  If ((Y& / Screen.TwipsPerPixelY) > _
     ((SBList1.ListCount - SBList1.TopIndex) _
     * SBList1.ItemHeight)) then
      ' We have not clicked on a list item
  Else
      ' We have clicked on a list item
  End If
End Sub
Note: If the user right-clicks on the space at the bottom of a list instead of on a list item, it does not invalidate the current ListIndex. This can be potentially confusing, because the user might assume that the menu which appears ought to be relevant to the selected item, when in fact it won't be. To avoid this, you could set the ListIndex to -1 as the first line of code after a right-click on empty space is detected.

Topic devised by Andy Groom.

 
Copyright © 2000 Global Components. All rights reserved.