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.
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.
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.
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.
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
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
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
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.
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.
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?
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.