[RESOLVED] Problem with picturebox hdc
In order to make some visual enhacements into a program I decided to load and stretch a picture into a picturebox directly from memory (using different APIs like BitBlt, StretchBlt, CreateCompatibleDC, etc). However when doing this the picture is loaded on top of the labels I've placed over the picturebox.
For example: I have a label with caption "HELLO" over the picturebox, it's shown correctly both in the IDE, if I don't load any picture into the picbox, or I load one directly from the IDE. When I load a picture into the picbox using the APIs and its hDc property the label stays behind the picture.
How can I fix this without changing the zorder of the label? like some sort of API or message that forces the picture to show at the back of any control.
Re: Problem with picturebox hdc
try putting:after you Blt the picture
Re: Problem with picturebox hdc
If you use PaintPicture you won't have this problem
VB Code:
Picture1.PaintPicture YourPic, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight
Re: Problem with picturebox hdc
Quote:
Originally Posted by bushmobile
try putting:
after you Blt the picture
That doesn't work well either, plus I'd prefer to make this code so I don't have to worry about the control that are over the picbox, and so make it more portable.
Quote:
Originally Posted by jcis
If you use PaintPicture you won't have this problem
VB Code:
Picture1.PaintPicture YourPic, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight
Uhm, right now what I do is creating directly a DC, and using StretchBlt with picture1.hdc. Your method would imply using a Image and its LoadPicture method, wouldn't it? or do you mean some other thing? I'll give a try to this.
Re: Problem with picturebox hdc
Quote:
Originally Posted by Neverbirth
Uhm, right now what I do is creating directly a DC, and using StretchBlt with picture1.hdc. Your method would imply using a Image and its LoadPicture method, wouldn't it? or do you mean some other thing? I'll give a try to this.
Well, after using the proposed method I was having the same problem, so I thought it was definately not a problem of the original method I was using, and after looking at this more I found out my problem was the autoredraw property being set to false.