1. Rudolf Fürst
  2. PowerBuilder
  3. Friday, 15 January 2021 16:18 PM UTC

Hi,

Is it possible to adjust the scrolling behavior of the mouse for data windows independently of the Windows setting? Page by page or number of lines.

Regards

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 20 January 2021 18:13 PM UTC
  2. PowerBuilder
  3. # 1
0
Votes
Undo

Hi Andrew;

  Right on - that is how the STD framework has addressed this issue for over a decade. :-)

  Note that Custom Visual User Objects, Tab Pages and Window classes - not just DC's - also need this type of wouse wheel scrolling assistance as well.   ;-)

Regards ... Chris

Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Tuesday, 19 January 2021 23:18 PM UTC
  2. PowerBuilder
  3. # 2
1
Votes
Undo

Here's a copy of my datawindow's "other" event that deals with a scrolling problem that exists when working remotely. Appeon says it has been fixed, but when I last tested it, the amount of lines scrolled up or down, was still not according to your windows mouse settings. Any way long story short.

 

The code uses the win API "SystemParametersInfoW" function to obtain the amount of lines it should scroll according to windows settings. If you want to use a different amount of lines for up or down scrolling, simply replace "li_WheelMouseLine" with your value instead of assigning it by calling the API function.

(The declaration for the external API function is available in the code as a comment, just before the call).

If you'd want to scroll page by page, you could use the suggestion made by Andrew Barnes: use the Describe function to determine first and lastVisible rows. That way you can find out your page size (assuming you have enough rows on the datawindow to fill a full page). See the PB help for FirstRowOnPage() and LastRowOnPage().
Example: ll_firstRow = long( dw1.Describe("DataWindow.FirstRowOnPage") )

CONSTANT uint WM_MOUSEWHEEL = 522

CHOOSE CASE message.number
	CASE WM_MOUSEWHEEL
		// v1 and v2, mjl, 13/04/20: Since win8 and w10 totally ignore the mouse settings when working remotely, I've re-introduced the code to scroll:
		// First check the user isn't "zooming" by using CTRL+mouseWheel:
		IF KeyDown( keyControl!) then
			RETURN 0
		END IF
		// v1 and v2, mjl, 19/05/20: shouldn't scroll when there's only one row:
		if this.rowcount() = 1 then
			message.processed = true // has to be the last command before doing the RETURN 0
			RETURN 0
		end if

		CONSTANT uint SPI_GETWHEELSCROLLLINES = 104
		CONSTANT Long WM_VSCROLL = 277
		CONSTANT Long SB_LINEDOWN = 1
		CONSTANT Long SB_LINEUP = 0
		
		int li_WheelMouseLine, li_index
		int li_lines

		// external function declaration: 
		// Function boolean SystemParametersInfoW(uint wActon, uint wParam, REF int pvParam, uint fUpdateProfile) Library "USER32.DLL"
		SystemParametersInfoW(SPI_GETWHEELSCROLLLINES, 0, ref li_WheelMouseLine, 0)
		li_lines = IntHigh(wParam) / 120
		this.SetRedraw(false)
		IF li_lines > 0 THEN
			FOR li_index = 1 TO li_WheelMouseLine
				Send(Handle(THIS), WM_VSCROLL, SB_LINEUP,0)
			NEXT
		ELSE
			FOR li_index = 1 TO li_WheelMouseLine
				Send(Handle(THIS), WM_VSCROLL, SB_LINEDOWN,0)
			NEXT
		END IF
		this.SetRedraw(true) // has to be before setting message.processed = true, if not it makes the message.processed = true to NOT work
		message.processed = true // has to be the last command before doing the RETURN 0
		RETURN 0
END CHOOSE
Comment
BTW: the reason why the above code doesn't scroll when there's "only one row", is because when we (in our applications) have a Freeform datawindow (not grid or tabular) and show only one row, then for resizing purposes, our detail bands are pretty low. If we'd allow scrolling on those particular datawindows, the columns would scroll of the screen and we don't want that. So this is just to avoid those type of datawindows to scroll down.
  1. Miguel Leeuwe
  2. Tuesday, 19 January 2021 23:52 PM UTC
There are no comments made yet.
Andrew Barnes Accepted Answer Pending Moderation
  1. Friday, 15 January 2021 16:49 PM UTC
  2. PowerBuilder
  3. # 3
1
Votes
Undo

If you code the ScrollVertical event (pbm_dwnvscroll event id), you should be able to scroll the DataWindow as you see fit.  You will probably want to use Describe to figure out the first and last line on the page. 

Comment
Hi Miguel,

that solves our problem - perfectly

thanks



Rudi

  1. Rudolf Fürst
  2. Wednesday, 20 January 2021 17:56 PM UTC
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.