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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

StretchBlt trouble 1

Status
Not open for further replies.

MikeCox

Programmer
Jun 4, 2001
340
US
Hi!

I'm having trouble making StretchBlt work as advertised. Consider the following code:
--------------------------
With frmPics.picLogo
StretchBlt picMain.hdc, 50, 50, .width, .height, .hdc, 0, 0, .width, .height, vbMergePaint
End With
--------------------------

This passes arguments that make it work just like BitBlt (i.e. no stretching, just a one for one).

Here's my problem:
--------------------------
'THIS WORKS:
Dim width As Long
Dim height As Long

width = frmPics.picLogo.width
height = frmPics.picLogo.height

With frmPics.picLogo
StretchBlt picMain.hdc, 50, 50, width, height, .hdc, 0, 0, .width, .height, vbMergePaint
End With

THIS DOES NOT:
Dim width As Long
Dim height As Long

width = frmPics.picLogo.width + 1
height = frmPics.picLogo.height + 1

With frmPics.picLogo
StretchBlt picMain.hdc, 50, 50, width, height, .hdc, 0, 0, .width, .height, vbMergePaint
End With

--------------------------

It doesn't seem to matter what I store into width and height, nothing gets painted if it is different than the source width and height. I've tried several different raster operations, AutoRedraw is True on all pictureboxes, refreshing pictureboxes only cause the first two examples to stop working (no change in the problem code), and I've simply run out of things to try. Examples on all websites seem to indicate I'm doing nothing wrong. Can anyone give any suggestions?

Thanks!

-Mike
Any man willing to sacrifice liberty for security deserves neither liberty nor security.

-Ben Franklin
 
But why would you want to have it that way? Can't you simply adjust the size of the picturebox then if you don't like it? Or put a picturebox in a picturebox to get a 'zoom-effect'?

LuCkY
 
Yes, or I could store the whole picture in an Image control, set Stretch = True, and resize the image, too. But I'm blitting from a source pic to a dest pic, and I want the result to be a flanged copy of the origional (i.e. bottom of pic is same size, and pic gets smaller toward the top as if it's scrolling away from you like the Star Wars intro dialogue). This means I have to StretchBlt each row to a smaller size than the previous row, starting with the bottom. The above code was only illustrative of the problem I was having, and I think it may have had something to do with my ScaleMode. I restarted the project from scratch, set ScaleMode of all pictureboxes to Pixel (wish it would default to that), and somehow it's working now (at least the stretching part, still have work to do...). It seems like it was painting all along, just off the screen. I haven't plugged in the above code to see if that was it, but since I made that change, everything seems to work as expected.

Thanks for your reply!

-Mike
Any man willing to sacrifice liberty for security deserves neither liberty nor security.

-Ben Franklin
 
"Wish it would default": set scale mode of hosting form to the scale mode you want before adding controls...
 
Thanks strogm, never knew that!
:) Any man willing to sacrifice liberty for security deserves neither liberty nor security.

-Ben Franklin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top