Results 1 to 5 of 5

Thread: [RESOLVED] Problem with picturebox hdc

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    160

    Resolved [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.

  2. #2
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Problem with picturebox hdc

    try putting:
    VB Code:
    1. [i]labelname[/i].Refresh
    after you Blt the picture

  3. #3
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Problem with picturebox hdc

    If you use PaintPicture you won't have this problem
    VB Code:
    1. Picture1.PaintPicture YourPic, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    160

    Re: Problem with picturebox hdc

    Quote Originally Posted by bushmobile
    try putting:
    VB Code:
    1. [i]labelname[/i].Refresh
    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:
    1. 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.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    160

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width