Link to home
Start Free TrialLog in
Avatar of ttobin333
ttobin333

asked on

Picturebox picture sizing problem

Dear Experts,

If I drag and drop an image into a VB6 picturebox, the image keeps its correct proportions even if it is bigger than the picturebox and only part of it can be seen.

If I copy and paste an image into the same picturebox, it automatically changes proportions so that the entire image can be seen, but it is distorted to the shape and size of the pciturebox.

I know that copy/pasting uses the clipboard and drag/dropping uses the data object, and this probably explains the different behavior.

Question: How can I copy/paste the image without distorting it to fit my picturebox? I don't want to make the picturebox autosize, or resize. It must stay at a fixed size, even if only part of the image inside it can be seen.

Thanks!
Avatar of 23637269
23637269
Flag of United States of America image

You can have a picturebox with its visible property set to false.
This will allow you to load a picture auto size and get the exact dimensions so that you know what size to make the display picturebox before you load the image.

If you want to scale it you can preprocess on the invisible picturebox to test then transfer.

Hope this helps.

Thanks
Roger
Avatar of ttobin333
ttobin333

ASKER

Thanks, Roger, but it didn't work.

When the PictureBox is resized back to the size it needs to be, the picture becomes distorted again. There seems to be something different about an image that is pasted from the clipboard--it stretches/shrinks to fit the size of the picturebox. Could it be a different format that can be converted?

Drag and dropped images behave much better. They stay at their original size and you can see a "window " of the entire image through the picturebox, which is what I want. How can we make the pasted image behave the same way?

Tobin
OK, new info: the file type causing the problem seems to be Windows Meta File image. Can this be converted to bmp/gif/jpg programmatically within VB6?
Yes, that would cause problems.  
Let me check.

Thanks
Roger
ASKER CERTIFIED SOLUTION
Avatar of 23637269
23637269
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry for the delayed response, Roger, and thank you. Can you recommend your favorite one of these third pary addons?

Thanks.