Browses Bug

Post Reply
User avatar
mmercado
Posts: 782
Joined: Wed Dec 19, 2007 7:50 am
Location: Salamanca, Gto., México

Browses Bug

Post by mmercado »

Mouse Wheel acts on focused browse control even when mouse pointer is not over it's client area.

I have fixed that in TSBrowse, here the new MouseWheel method:

Code: Select all

METHOD MouseWheel( nKeys, nDelta, nXPos, nYPos ) CLASS TSBrowse

   Local nWParam, ;
         aPoint := { nYPos, nXPos }

   ScreenToClient( ::hWnd, aPoint )

   If ! IsOverWnd( ::hWnd, aPoint[ 1 ], aPoint[ 2 ] )
      Return Super:MouseWheel( nKeys, nDelta, nXPos, nYPos )
   EndIf

   nDelta /= 120

   If ( nDelta ) > 0

      If ::nWheelLines != Nil
         nWParam := SB_LINEUP
         nDelta  := ::nWheelLines * nDelta
      Else
         nWParam := SB_PAGEUP
      EndIf

   Else

      If ::nWheelLines != Nil
         nWParam := SB_LINEDOWN
         nDelta  := ::nWheelLines * Abs( nDelta )
      Else
         nWParam := SB_PAGEDOWN
         nDelta := Abs( nDelta )
      EndIf

   EndIf

   While nDelta > 1
      ::VScroll( nWParam, 0 )
      nDelta--
   EndDo

Return ::VScroll( nWParam, 0 )
For Antonio, here a proposed MouseWheel method for xBrowse:

Code: Select all

METHOD MouseWheel( nKeys, nDelta, nXPos, nYPos ) CLASS TXBrowse

   Local aPoint := { nYPos, nXPos }

   ScreenToClient( ::hWnd, aPoint )

   if ! IsOverWnd( ::hWnd, aPoint[ 1 ], aPoint[ 2 ] )
      Return Super:MouseWheel( nKeys, nDelta, nXPos, nYPos )
   endif

   if lAnd( nKeys, MK_MBUTTON )
      if nDelta > 0
         ::PageUp()
      else
         ::PageDown()
      endif
   else
      if nDelta > 0
         ::GoUp()
      else
         ::GoDown()
      endif
   endif

Return nil
Regards.

Manuel Mercado
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Antonio,

I see that xBrowse is not using the lines per movement for the mouse wheel that is set in the Windows registry. This would be a nice addition. Browsing a table one line at a time can be very slow and tedious.

You can get the needed value like this:

Code: Select all

   oReg:= Treg32():new( HKEY_CURRENT_USER,"Control Panel\Desktop")
   ::nWheelScrollLines := val( oReg:get("WheelScrollLines") )
   oReg:close()
James
demont frank
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Post by demont frank »

James ,

Very good idea , it is easy to work out , only a few changes are needed.

1) What is the normal behaviour when we are at the end or the beginning from the list , now i have:

Code: Select all

FOR n := 1 TO ::nWheelScrollLines
  IF nDelta <= 0
    IF EVAL(::bKeyNo) = EVAL(::bKeyCount,self) // > EVAL(::bKeyCount,self) - ::nWheelScrollLines 
      EXIT
    END
  ELSE
    IF EVAL(::bKeyNo) == 1 //< ::nWheelScrollLines 
      EXIT
    END
  END 
  IF nDelta > 0 
    ::GoUp() 
  else 
    ::GoDown() 
  endif 
NEXT
GoDown() is not executed on the last row , GoUp() not on the first row
2) Now i have nWheelScrollLines defined as a data , which must receive his value for each instance from xBrowse in method new.
Probably a better aproach is to define a ClassData , which must only receive his value one time

How is this done ?

PROBLEMS :

1) Browsing a DBF , and after Ctrl-PgDn , EVAL(bKeyNo) seems to give a wrong value , so GoDown() is executed
2) Browsing a Array : When we are at the last row from the screen , and executing GoDown , the last 3 rows from the screen are all the same

Frank
James Bott wrote:Antonio,

I see that xBrowse is not using the lines per movement for the mouse wheel that is set in the Windows registry. This would be a nice addition. Browsing a table one line at a time can be very slow and tedious.

You can get the needed value like this:

Code: Select all

   oReg:= Treg32():new( HKEY_CURRENT_USER,"Control Panel\Desktop")
   ::nWheelScrollLines := val( oReg:get("WheelScrollLines") )
   oReg:close()
James
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Frank,
Probably a better aproach is to define a ClassData , which must only receive his value one time

How is this done ?
Just define it as CLASSDATA:

classdata nWheelScrollLines

Then in the new method:

if ::nWheelScrollLines == nil
// define it here
endif

James
Post Reply