Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Scrolling using the mouse wheel
Message
From
02/11/2004 07:32:09
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Miscellaneous
Thread ID:
00956928
Message ID:
00956950
Views:
16
>There seems to be a strange quirk in how VFP handles scrolling of edit boxes with the mouse wheel which is driving my customers crazy. The code sample below shows a simple example of what I mean and also includes some text which describes the problem.
>
>
>LOCAL oFrm
>
>oFrm= CREATEOBJECT("TestForm")
>TEXT TO oFrm.Edit1.Value NOSHOW PRETEXT 1 + 2
>	The problem displayed here is to do with
>	using the mouse wheel to scroll the edit
>	box. When the edit box has focus and the
>	edit box is scrolled, any attempt to
>	select text with the mouse will work
>	as expected. However, when the edit box
>	does not have focus and the edit box is
>	scrolled, any attempt to select text with
>	the mouse will jump the box back to its
>	original position. The selection doesn't
>	begin where you would expect.
>	
>	This drives my users crazy. In all their
>	other applications (eg MS Outlook) this
>	works as expected. However in our VFP
>	application it jumps around in a very
>	illogical fashion.
>ENDTEXT
>
>oFrm.Show(1)
>
>************************************
>DEFINE CLASS TestForm AS Form
>	ADD OBJECT Text1 AS TextBox WITH ;
>		Height= 37, ;
>		Left= 36, ;
>		TabIndex= 1, ;
>		Top= 12, ;
>		Width= 289
>
>	ADD OBJECT Edit1 AS EditBox WITH ;
>		Height= 109, ;
>		Left= 36, ;
>		ReadOnly= .t., ;
>		TabIndex= 2, ;
>		Top= 84, ;
>		Width= 289, ;
>		Value= ""
>ENDDEFINE
>
>
>Ken Senter suggested modifying the SelStart property of the edit box in the MouseWheel event but there doesn't seem to be nearly enough information passed into the MouseWheel event to make this work cleanly. For example, if I configure my mouse wheel in the mouse control panel to scroll one line at a time I get exactly the same parameters to the MouseWheel event as I do when it is set to scroll three lines at a time.
>
>David Bower suggested adding code that would force the focus onto the edit box when the MouseWheel event fired but that wasn't particularly successful either (and has some horrid side effects in some of our forms!).
>
>I think this is a VFP bug. However I'd love to hear any ideas on how to fix it or work around it. It occurs in VFP 8.0 SP1 (as that is what we use now) but it still happens in VFP 9.0 beta as well.
>
>Thanks!

This worked good for me:
  Procedure Edit1.MouseWheel
  Lparameters nDirection, nShift, nXCoord, nYCoord
  If Empty(This.Tag)
    This.Tag='set'
    This.SetFocus()
  Endif
  Endproc

  Procedure Edit1.LostFocus
  This.Tag=''
  Endproc
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform