Results 1 to 4 of 4

Thread: [RESOLVED] Problem of picturebox backgroud transparent

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2016
    Posts
    30

    Resolved [RESOLVED] Problem of picturebox backgroud transparent

    I face a simple problem but i couldn't fix it in recent days,


    Name:  Untitled_zpsowospcmj.jpg
Views: 251
Size:  46.2 KB

    as the pic on about link, the "black ship" background color is set to "transparent ",
    however it covered the red square and show the background color. what should i do?

  2. #2
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: Problem of picturebox backgroud transparent

    Transparency of Windows Forms controls means "show my Parent control's background". In the image you posted, the parent control of the PictureBox is the Form. Not the red rectangle. You can't have both.

    You get complete freedom to superimpose images with transparency by painting them with Graphics.DrawImage etc and other graphics commands. For example you could leave the "school" image as the Form's background, and paint the red rectangle and the ship picture in the form's Paint event (using e.Graphics.FillRectangle and then e.Graphics.DrawImage).

    You will need to call the form's Invalidate or Refresh method to trigger repainting when the positions change.

    BB

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2016
    Posts
    30

    Re: Problem of picturebox backgroud transparent

    Quote Originally Posted by boops boops View Post
    Transparency of Windows Forms controls means "show my Parent control's background". In the image you posted, the parent control of the PictureBox is the Form. Not the red rectangle. You can't have both.

    You get complete freedom to superimpose images with transparency by painting them with Graphics.DrawImage etc and other graphics commands. For example you could leave the "school" image as the Form's background, and paint the red rectangle and the ship picture in the form's Paint event (using e.Graphics.FillRectangle and then e.Graphics.DrawImage).

    You will need to call the form's Invalidate or Refresh method to trigger repainting when the positions change.

    BB
    sounds like i need to make a timer to refresh the image if i move them, right?

    Would u tell me how to coding in this part? because i hvn't use Graphic Draw before.. =P
    Thanks for replying

  4. #4
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: Problem of picturebox backgroud transparent

    You shouldn't need a timer to refresh the image when you move them.
    Whatever method you're using to move them should be able to call the Invalidate method of the form to schedule a paint event.
    Don't know if this will help, but this post has an example card game which is implemented by drawing card images on the form, and you drag the images around with the mouse. It uses rectangle objects to keep track of the bounds of where the card images should be drawn, and when you click on the form, it searches the list of rectangles to find which was clicked in.
    You'll probably want something similar for dragging your images since you won't be using a control.
    Last edited by passel; Jul 29th, 2016 at 02:26 PM.

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