Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with PaintPicture method

Status
Not open for further replies.

TheVampire

Programmer
Joined
May 1, 2002
Messages
828
Location
US
Good Day all,

I have a small problem getting the PaintPicture method to work for me, and looking for some help.

What I am doing, is pasting a Metafile from the clipboard into a picturebox like this:

Dim frmt As Variant
For Each frmt In Array(vbCFBitmap, vbCFMetafile, vbCFDIB, vbCFPalette)
If Clipboard.GetFormat(frmt) Then
Set Picture2.Picture = Clipboard.GetData(frmt)
Exit For
End If
Next

So far so good. This works fine and I can see the picture in the picturebox on the screen. Next, I want to use Paintpicture to adjust this image to a specific size. I use the following code to transfer the data from one picturebox to another.

SRCPic.PaintPicture Picture2.Picture, 0, 0, 33600, 24000, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight

SRCPic.Refresh


OK, we are still working fine to this point. I have the original ( small ) image in one picturebox, and the same image ( enlarged ) in a second picturebox.

Now here is where my problem begins. I want to display a specific section of the enlarged image in a third picturebox. I use Paintpicture to cut out the portion I want.

Picture1.PaintPicture SRCPic.Picture, 0, 0, 9600, 6000, PosX, PosY, 9600, 6000

And I get an error, "Invalid Picture".

If I use debug to look at the value of Picture2.Picture, I see the single value that is the pointer to the picture. if I look at the value for SRCPic.Picture, I see 0.

All of the pictureboxes have AutoRedraw set to True.

What gives? I'm "seeing" the picture in SRCPic when I run the program, but it says that there is no picture for that control. Does Paintpicture create a new picture for the control, or does it just point at the picture that was in the original picturebox?

Thanks for any help I can get,

Robert
 
Never mind. I figured it out.

What I have to do is use this line after I use Paintpicture to draw in the picturebox

SRCPic.Picture = SRCPic.Image

And then it works fine.

Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top