Thanks, Marco. I did eventually find this method and now have a nice
usercontrol that lets the user zoom in and out of a picture and scroll
around it as required.
Mark
-----Original Message-----
From: Marco Straforini [mailto:marco@c...]
Sent: 31 January 2002 14:20
To: professional vb
Subject: [pro_vb] Re: StretchBlt of an HDC
Mark,
if you use the hdc of an hidden component, you do not get anything, as
you suspected. You can try to create your own dc context, and assign to it
the bitmap loaded into the hidden picture box. It is possible but it is a
real pain (I did it and I would not do it again). I strongly suggest you
to use the PaintPicture method of the PictureBox object, that does all the
dc handling for you (you can find a complete example in the vb help). Try
it and see if the performances you get are ok.
This is how I use it:
pctImage.PaintPicture pctBuffer.Picture, xx, yy, w, h
where xx,yy,w,h are the destination position and size (I copy the whole
image, thus I do not specify the source parameters). Just keep in mind
that the size of a loaded image that you get from the
picturebox.Picture.Width and Height properties are in HiMetric, and you
have to convert them to the units you use in the destination picture box.
Good luck,
m.
>
> Hi everyone,
>
> I'm trying to write a ActiveX control that lets the user view a jpg. User
> can scroll around it and zoom in and out. I am doing it using 2 picture
> boxes, a hidden one and a visible one. The hidden one has the
> autoresize=true, and gets the entire picture loaded into it. The visible
one
> has parts of the hdc from the hidden one bitblt'd onto using stretchblt
> (like bitblt, but more flexible).
>
> Problem is, the HDC of a picturebox seems to comprise only of the visible
> portion of a picturebox. i.e. if a stretchblt from the hidden one nothing
> happens. If I make it visible, I get some of the picture coming across,
but
> other bits of screen as well. Is this just the way hdcs work. How can I
> StretchBlt from the picture itself, instead of the picturebox's device
> context? Any suggestions welcome.
>
> Many thanks,
>
> Mark
>