Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Mouseover Listbox - what is under the cursor?
Message
De
19/07/2004 02:15:22
 
 
À
18/07/2004 23:29:30
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00924946
Message ID:
00925660
Vues:
27
>Cool code. But as you scroll down the list box the accuracy changes. Like I set the list to 120 records and the code was correct upto about 40 then it was inaccurate until, by the time I reached the last record it was displaying the value exactly 1 row up from where it actually was.
>


Sorry, I didn't think about that. Cause I was making this in a hurry so only tested that code once with a few items. Also the codes does no optimization and no checking for the the ItmIndex <*g*>

I had changed the code and tested several times now. Almost accurate, but still for a certain font with certain size, it missed 1 pixel (more/less). So use Cetin's code (dummy label) for best accuracy

Anyway here it is:
** add nRight, nFontHeight & nOldIndex properties to form

** Listbox init event
Local lc_FontSize, ln_Spaces

With This
   lc_FontStyle = iif( .FontBold, 'B', '' ) + iif( .FontItalic, 'I', '' ) + ;
      iif( .FontUnderline, 'U', '' )
   ln_Spaces = FontMetric( 4, .FontName, .FontSize, lc_FontStyle )
   If (ln_Spaces > 2)
      ThisForm.nFontHeight = FontMetric( 1, .FontName, .FontSize, lc_FontStyle ) + ;
         round(ln_Spaces / 2, 0) + FontMetric( 5, .FontName, .FontSize, lc_FontStyle )
   else
      ThisForm.nFontHeight = FontMetric( 1, .FontName, .FontSize, lc_FontStyle ) + ;
         ln_Spaces + FontMetric( 5, .FontName, .FontSize, lc_FontStyle )
   endif

   ThisForm.nRight = (.Left + .Width) - SysMetric(7)
EndWith


** Listbox mousemove event
LPARAMETERS nButton, nShift, nXCoord, nYCoord

Local ln_Index

With This
   If (nXCoord < ThisForm.nRight)   && on Listbox Scrollbar ?
      ln_Index = .TopIndex + int((nYCoord - .Top) / ThisForm.nFontHeight)

      If (ln_Index > .ListCount)
         ln_Index = .ListCount
      endif

     ** Autoselect item
      If (ThisForm.nOldListIndex != ln_Index)
         .ListIndex = ln_Index
         ThisForm.nOldListIndex = ln_Index
      endif

      Wait .List( ln_Index ) window nowait noclear
   endif
EndWith
Sorry again.
Regards
Herman
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform