Results 1 to 9 of 9

Thread: PDF Control

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    203

    PDF Control

    I am looking for a control that will do the following

    1) Load and display an image in a PDF format
    2) Load the next and last page of a multiple image file.
    3) ZoomIn and ZoomOut of the image
    4) Horizontal and vertical scrolling for images larger than the screen
    5) A MouseDown event that returns the X and Y position of the cursor
    6) DrawLine function onto the image
    7) The ability to save the image with any added lines

    I have a control that does all of this and does it well but here is the problem. When I click a point on the Image I can get the X and Y coordinates of where the cursor is on the screen. If I try to plot this point on the image, it uses the x and y coordinates of the screen to plot the point at the x and y coordinates of the image. I think maybe this would work if the screen and the image were the same size. Unfortunately they aren't.

    What I need is a way to have the x and y coordinates of the point clicked on the image returned to me. All I am currently getting are the x and y coordinates of the screen.

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: PDF Control

    If I understand your question correctly, you need this function: https://docs.microsoft.com/en-us/win...screentoclient.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    203

    Re: PDF Control

    That is real similar to what I need.

    Instead of the screen x, y coordinates, I am getting the x and y coordinates from the ImageViewer control in the mouse_down event. They are the same as the x, y coordinates in the Form_MouseDown event. The idea is the same, the x, y coordinates of the ImageViewer control need to be mapped to the image that is being displayed.

  4. #4
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: PDF Control

    Quote Originally Posted by sneakers View Post
    I am getting the x and y coordinates from the ImageViewer control in the mouse_down event. They are the same as the x, y coordinates in the Form_MouseDown event. The idea is the same, the x, y coordinates of the ImageViewer control need to be mapped to the image that is being displayed.
    I think you need to describe your problem a bit better ...

    A ScreenShot would help, as well as an info:
    - what kind of control you use to show your "preview"
    - and if it *is* a preview at all (perhaps it has drawing-functions built-in)

    Anyways, in the same category as ScreenToClient, there's also CientToScreen and MapWindowPoints:
    https://docs.microsoft.com/en-us/win...apwindowpoints

    But if your plan is, to:
    - "catch Mouse-Coords directly on the Viewer-Control" (in case it does not support direct drawing, like a VB-PicBox)
    - then use these coords to draw on an "InMemory-representation" of the same image, the ViewerCtl currently shows
    - and then finally refresh the Viewer-Control, to reflect your changes from the InMem-Bitmap in the Viewer...
    that could get a bit more complicated, when the size of the Viewer-rendered Image differs from your InMemory-Bitmap.

    Olaf

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    203

    Re: PDF Control

    I just looked at this link again.

    https://docs.microsoft.com/en-us/win...screentoclient

    That is what I need it to do. The sample of the syntax used is in C++ which I know nothing about. Is there any way that this can be done using VB6?
    Last edited by sneakers; Apr 2nd, 2021 at 02:02 PM.

  6. #6
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,116

    Re: PDF Control

    Unless I'm missing something, it seems like this is a relatively simple solution.

    If x and y are screen coordinates, then to turn them into coordinates within the control itself:

    Code:
    xControl = x - (Form.Left + Control.Left)
    yControl = y - (Form.Top + Control.Top)
    assuming that the control in question has the Form as its container and making sure you are ensuring that all values used in calculations are in pixels rather than twips.

    Good luck.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    203

    Re: PDF Control

    Quote Originally Posted by OptionBase1 View Post
    Unless I'm missing something, it seems like this is a relatively simple solution.

    If x and y are screen coordinates, then to turn them into coordinates within the control itself:

    Code:
    xControl = x - (Form.Left + Control.Left)
    yControl = y - (Form.Top + Control.Top)
    assuming that the control in question has the Form as its container and making sure you are ensuring that all values used in calculations are in pixels rather than twips.

    Good luck.
    Not quite. I am trying to use the x, y coordinates returned from the control and map them to an x, y point on an image. The control and the image are different widths and heights.

    The control is the width of the maximized form, 20,000 + pixels. The image is 4000 + pixels wide but the image is much larger than the form. Scroll bars are required for the control to view the image.

    It should be easy but it isn't. X should equal x of the control divided by the width of the image.

    x = x / (control.width / image.width)

    Over the last few days I have busted my head trying to figure out why that didn't work. I had to divide the above result by 3 and some change to get the actual point I need on the image. Where did that 3 come from. I couldn't explain it.

    Just this morning I got a response from the control maker answering the question of how I can set the zoom level for the control to 0. I am pretty sure that I was trying to calculate that point with a zoom level of 3. That might be where the 3 came from.

  8. #8
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,116

    Re: PDF Control

    Got it (I think...). So the true point (0, 0) on the image might not even be on screen if the person is scrolled over to the right and down a bit. And the "as-is currently displayed" visible upper-left corner of the image isn't guaranteed to be (0, 0) of the image if, again, it is scrolled over and down a bit. And then factoring in zooming as well, it obviously isn't as easy as I first suspected.

    Since I don't have the control you are working with, I can't offer any further attempted assistance.

    Good luck.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    203

    Re: PDF Control

    Monday morning I am going to set the zoom level to 0, keep the scroll bars to the left and top and try and plot that line on the image. If I can plot that point without needing to consider zoom and scroll. it will be much easier.

    You are correct. When scrolled, 0, 0 of the image isn't even visible. The kicker is this. The 20,000 + wide control has to scroll to view a 4,000 + wide image. Apparently the screen has a much higher resolution than the image.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width