Problem with preview position

Knowledge exchange related to the VPE Report Engine and PDF Library

Moderator: IDEAL Software Support

Problem with preview position

Postby Daves1 » Mon Feb 09, 2015 3:18 pm

Hello,
I use VPE 6.1 C#.
I have a VPE Control on a Win-Form, where a vpe preview is shown.
I need to remember the current Preview Position Y coordinate (vertical Scroll Position) in order to set it later again.
I have the option to set the preview position by the function SetPreviewPosition. This works very well.
My problem is now, I cant find any opportunity to get the preview position. There is not GetPreviewPosition function, and also other properties like VerticalScroll.value dont work.
Can someone help me? Is there any way to read the current preview position?
Thanks a lot.
Daves1
 
Posts: 5
Joined: Mon Feb 09, 2015 1:19 pm

Re: Problem with preview position

Postby IDEAL Software Support » Tue Feb 10, 2015 11:58 am

There is no way to retrieve the scroll position. We implemented the SetPreviewPosition() method, to allow to position onto a specific area in your document, from which you know that it is interesting for your end-users. We couldn't think of any use case, where you need to retrieve the current scroll position.
IDEAL Software Support
 
Posts: 1621
Joined: Thu Nov 18, 2004 4:03 pm

Re: Problem with preview position

Postby Daves1 » Fri Feb 13, 2015 4:19 pm

Thanks for your quick answer.
My problem is, that I have a VPE preview, where the user can scroll to specific parts of the print. While the vpe preview is still open, he has the opportunity to change data that influences the data of the print.
At that moment, I need to reprint the preview to show the new data. After that, I wanted to set the old scroll position the user had before so he dont need to scroll to that area again.
Daves1
 
Posts: 5
Joined: Mon Feb 09, 2015 1:19 pm

Re: Problem with preview position

Postby IDEAL Software Support » Mon Feb 16, 2015 10:38 am

We have not tested it, but it should be possible to implement a workaround using the WINAPI.

To backup the current scroll position:
  • Retrieve the current preview zoom scale using the property VPE.Scale (for .NET it is VPE.PreviewScale, because "Scale" is reserved).
  • Retrieve the window handle of the preview using VPE.hWndPreview.
  • Call the WINAPI function GetScrollPos() using the window handle from above to retrieve the current scroll positions (use SB_HORZ once and then SB_VERT).

To restore the saved scroll position:
  • Set the preview zoom scale to the backup value. This sets internally the correct scroll range, etc.
  • Retrieve the window handle of the preview using VPE.hWndPreview.
  • Call the WINAPI function SetScrollPos() to restore the backup values for the scroll positions.

Please let us know, if this works.
IDEAL Software Support
 
Posts: 1621
Joined: Thu Nov 18, 2004 4:03 pm

Re: Problem with preview position

Postby Daves1 » Wed Jun 17, 2015 10:05 am

I´ve had the chance to try your advice now, after working on other projects.
Unfortunately GetScrollPos of the vpe.hWndPreview Window Handle always returns 0.
Also using SB_HORZ once and then SB_VERT doesn´t change that.
So this also doesn´t work. But thanks anyway.
Daves1
 
Posts: 5
Joined: Mon Feb 09, 2015 1:19 pm

Re: Problem with preview position

Postby IDEAL Software Support » Wed Jun 17, 2015 1:53 pm

We made a mistake. You need to work with a child window (the client window) of the VPE main window.

This can be retrieved using:
hWndClient = FindWindowEx(VPE.hWndPreview, NULL, "Virtual Print Engine Client", NULL)

All operations described in the previous posting need to use hWndClient.
IDEAL Software Support
 
Posts: 1621
Joined: Thu Nov 18, 2004 4:03 pm

Re: Problem with preview position

Postby Daves1 » Fri Jun 19, 2015 11:32 am

Well..this works a bit now ;)
I get the correct Scroll position.
When i set the new scroll position to the hwndClient after reprint, the scroll position is set correctly.
But the new problem is, then my print output starts at this scroll position.
The first print lines start at that position, and when I scroll up, the preview above the scroll position that was set is empty.
Can that also be solved?

Thanks a lot
Daves1
 
Posts: 5
Joined: Mon Feb 09, 2015 1:19 pm

Re: Problem with preview position

Postby IDEAL Software Support » Fri Jun 19, 2015 4:06 pm

The document layout and the position of objects are in no way related to the scroll position of the preview. I assume you have a bug in your code when you recreate the document.
IDEAL Software Support
 
Posts: 1621
Joined: Thu Nov 18, 2004 4:03 pm

Re: Problem with preview position

Postby Daves1 » Fri Jun 19, 2015 11:03 pm

Alright, I will check that next time and report the result.
Have a great weekend.
Daves1
 
Posts: 5
Joined: Mon Feb 09, 2015 1:19 pm


Return to VPE Open Forum

Who is online

Users browsing this forum: No registered users and 4 guests

cron