Results 1 to 19 of 19

Thread: Picturebox not showing correct coordinates....HELP PLEASE

  1. #1

    Thread Starter
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    Talking Picturebox not showing correct coordinates....HELP PLEASE

    I have 2 forms. One form functions as the File navigator to select the .JPG or .BMP and finally show the picture in a picbox. To get the part of the picture the User wants to see in the first form, I have a 2nd form that loads the full picture into a picbox. Within this picbox I have made a little Framing tool that is esentially 4 black rectangle to look like an actual picture frame and a transparent label over the top of the 4 rectangle shapes. The user can click on the transparent label and move the 4 shapes around to frame the part of the picture they want to show on the first form. I am using the PaintPicture function to paint the picture into the first form picbox but it always paints the top left of the picture. here is my code

    The following code is attached to the "Okay" button on the second form.
    Code:
    Private Sub lblOk_Click()
        PicPath = FirstForm.DirPhotos + "\" + FirstForm.flbPhotos
        XSETTINGFORPIC = TransparentLabel.Left
        YSETTINGFORPIC = TransparentLabel.Top
        FirstForm.picboxClient.Picture = LoadPicture(PicPath)
        FirstForm.picboxClient.PaintPicture SecondForm.picbxMain.Picture, 0, 0, SecondForm.TransparentLabel.Width, SecondForm.TransparentLabel.Height, XSETTINGFORPIC, YSETTINGFORPIC, SecondForm.TransparentLabel.Width, SecondForm.TransparentLabel.Height
        Unload Me
    End Sub
    I step trough the code and I see that the correct coordinates do go into the Function. My ScaleMode is Twips.

    Any help would be awesome. Thanks in advance
    Last edited by Avatarp; Apr 22nd, 2004 at 11:51 AM.

  2. #2

    Thread Starter
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    Picture Selecting techniques..

    Well if nobody has any suggestions how about a couple suggestions for alternatives.

    I have a picture box that shows the entire picture.
    A Selecting tooling that the user moves to frame the desired area.
    Once the area is framed the User clicks okay and the form unloads after it has loaded the statically sized picture box on the other form.

    Sounds easy but I can't get this simple little program to work. Perhaps if some smart person has 5 minutes they could show me an example of this or even program this themselves.

  3. #3
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    The 2nd and 3rd agruments of the PaintPicture method are the destination coordinates. You have set them to be always 0, 0.

  4. #4

    Thread Starter
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    Hey Brucevde

    I had the 2nd and 3rd arguements set to the x and y coordinates of the Transparent label and it still gave the the top left. I do believe that the 2nd and 3rd arguements are the coordinates of where the picture is placed within the picturebox.

    Its the 6th and 7th arguements that are used to select within the picture.

    Am I wrong?

  5. #5
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    You are correct. The 6th and 7th arguments indicate the starting position of the clipping region within the source picture.

    If a user were to select the bottom right quarter of a picture how do they specifiy where to draw this selection? Whatever mechanism you are using the coordinates must be placed in the 2nd and 3rd arguments.


    Damn Flames!

  6. #6

    Thread Starter
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826
    so 2nd Arg = X coordinate of In Picture Selection
    3rd Arg = Y coordinate of In Picture Selection

    Hey Brucevde try to do the following:

    Create 2 Forms:

    1 form has:

    1. DriveListBox
    2. DirListBox
    3. FileListBox
    4. PictureBox

    Double click on the FileListBox item opens the second Form which contains

    1. PictureBox (4 Black thin rectangle shapes organised into a frame, 1 Transparent Label with its dimensions set to exatly the same size as the pictureBox on the first form over the top of the 4 Rectangles)

    3. Okay button
    4. Cancel button.

    The MouseDown Event on the Label set the global x and y coordinates. The MouseMove Event set the X and Y positions of each Rectangle and the label so that you esentially can move the Label and Shapes around the PictureBox.

    clicking the Okay button records the X and Y coordinates of the Transparent label and uses those values to PaintPicture the Selected Image into the First Form PictureBox.


    It is really a simple idea. I'm sure you could mock something up in 5 minutes. Here let me do it for you

  7. #7

    Thread Starter
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    I think I got it!!!!

    For some reason it is kind of working now. Weird thing is though each time I reselect the pic the first picbox shows more and more the wrong selection after selecting the correct area first

    Weird. Let me see if I can jimmy this up. When I get it I'll post it for you to check it out. first thing first...Gotta watch the flames kick some Red Wing Azzz tonight


    L8A

    Thanks for helpin out

  8. #8
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Gotta watch the flames kick some Red Wing Azzz
    Damn Flames
    Damn losing another 50 bucks.
    Damn Canucks!

  9. #9

    Thread Starter
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    Very weird :S

    Still not working right very sketchy looking doesnt repaint the whole picbox with my correct coordinates
    Last edited by Avatarp; Apr 23rd, 2004 at 01:35 AM.

  10. #10
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Can you post a sample project?

  11. #11

    Thread Starter
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    Here is the small Application for you to try to help me with.

    Complete with .vbp file
    Attached Files Attached Files
    Last edited by Avatarp; Apr 23rd, 2004 at 03:20 AM.

  12. #12

    Thread Starter
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    Brucevde...

    you'll see that I save some settings to your registry. I never put the DeleteSettings commands in the code. You may want to do that if you are concerned about having your registry clean

  13. #13

    Thread Starter
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    ...

    Ignore the label and the poor layout. This is just a little application I am trying to get to work so I can integrate it into another application

  14. #14

    Thread Starter
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    FLAMES RULE!!!!

    2-1 Win over Detroit in OT!!!!!

  15. #15

    Thread Starter
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    Anybody want to help me with this?

    Look up about 5 messages and down load my little 2 form application. Included is the .vbp and the 2 forms. You will notice how my picturebox doesnt work consistently correctly at all.

  16. #16
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Are you trying to make a zoom control? I still don't understand what you want. When I move the label and click ok, what should happen. Where should the graphic be drawn? No where is there a place to let the user choose.

  17. #17
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246
    I think the problem lies in the ScaleMode. Wouldn't it cause problems if he has the ScaleMode set to Twip and not Pixel, while trying to use PaintPicture?

    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  18. #18
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    No PaintPicture works no matter the scale mode. Actually, I better research that some more.

    His program works, just not the way he wants.

  19. #19

    Thread Starter
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    thanks Brucevde

    Thanks for checking it out. I still don't have a final solution for this so if anybody wants to download my little application please do but you must have VB Studio 6.0 to view this project.

    Thanks all

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