473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

picturebox transparency malfunction

EntryTeam
I'm writing turn based logic game, and transparency doesn't seen to work right:
screenshot

Person model is .GIF in picturebox, buildings are .GIF in pictureboxes, mainform background is .bmp file.

Model picbox and building picboxes both have
Expand|Select|Wrap|Line Numbers
  1. .BackColor = System.Drawing.Color.Transparent;
...set.

How do I get this working as it should be?
Oct 9 '09 #1
7 5331
tlhintoq
3,525 Expert 2GB
You don't. It is the nature of a picturebox backgroundcolor to show through to the background color of the control underneath it.

if you put a picturebox on a form whose background color is red, then your picturebox background color is red.

A Form's background color of transparent will work as you are expecting. So instead of making a bunch of pictureboxes on a form you can make a bunch of forms with no border and transparent background and a background image.

This is why it is good to do small-scale experiment to prove one's assumptions before doing the BIG part of the coding.
Oct 9 '09 #2
@tlhintoq
You mean real forms instead of pictureboxes? How's that?
Oct 9 '09 #3
Plater
7,872 Expert 4TB
@tlhintoq
Can you get away with using a panel instead of a Form?
Transparent forms has been a big mess (if you look through post history here in bytes, there's been a few long threads about getting it to work)
Oct 9 '09 #4
tlhintoq
3,525 Expert 2GB
A panel might work. I don't think I've tried for a purpose such as EntryTeam is doing.

Sounds like a good experiment.

EntryTeam: Give it a try. Instead of a bunch of picturebox controls, try it with a bunch of panel controls. They have nearly all the same properties such as 'Image', 'Backcolor', 'Location' etc. so it shouldn't be a huge issue.

If you are creating those pictureboxes programatically you just make a new panel instead of new picturebox
Expand|Select|Wrap|Line Numbers
  1.             PictureBox pbPlayer = new PictureBox();
  2.             // becomes
  3.             Panel pbPlayer = new Panel();
  4.  
If you built them at design time, you can go into the Form1.Designer.cs file and change their type.

Expand|Select|Wrap|Line Numbers
  1.         #region Windows Form Designer generated code
  2.  
  3.         /// <summary>
  4.         /// Required method for Designer support - do not modify
  5.         /// the contents of this method with the code editor.
  6.         /// </summary>
  7.         private void InitializeComponent()
  8.         {
  9.             this.button1 = new System.Windows.Forms.Button();
  10.             this.button2 = new System.Windows.Forms.Button();
  11.             this.pictureBox1 = new System.Windows.Forms.PictureBox();
  12.             ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
  13.             this.SuspendLayout();
  14.  
  15.             // 
  16.             // button1
  17.             // 
  18.             this.button1.Location = new System.Drawing.Point(26, 13);
  19.             this.button1.Name = "button1";
  20.             this.button1.Size = new System.Drawing.Size(75, 23);
  21.             this.button1.TabIndex = 1;
  22.             this.button1.Text = "button1";
  23.             this.button1.UseVisualStyleBackColor = true;
  24.             this.button1.Click += new System.EventHandler(this.button1_Click);
  25.             // 
  26.             // button2
  27.             // 
  28.             this.button2.Location = new System.Drawing.Point(207, 12);
  29.             this.button2.Name = "button2";
  30.             this.button2.Size = new System.Drawing.Size(75, 23);
  31.             this.button2.TabIndex = 2;
  32.             this.button2.Text = "button2";
  33.             this.button2.UseVisualStyleBackColor = true;
  34.             this.button2.Click += new System.EventHandler(this.button2_Click);
  35.             // 
  36.             // pictureBox1
  37.             // 
  38.             this.pictureBox1.Location = new System.Drawing.Point(3, 3);
  39.             this.pictureBox1.Name = "pictureBox1";
  40.             this.pictureBox1.Size = new System.Drawing.Size(100, 50);
  41.             this.pictureBox1.TabIndex = 0;
  42.             this.pictureBox1.TabStop = false;
  43.             // 
  44.             // Form1
  45.             // 
  46.             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
  47.             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  48.             this.ClientSize = new System.Drawing.Size(544, 497);
  49.             this.Controls.Add(this.button2);
  50.             this.Controls.Add(this.button1);
  51.             this.Name = "Form1";
  52.             this.Text = "Form1";
  53.             ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
  54.             this.ResumeLayout(false);
  55.  
  56.         }
  57.  
  58.         #endregion
  59.  
  60.         private System.Windows.Forms.Button button1;
  61.         private System.Windows.Forms.Button button2;
  62.         private System.Windows.Forms.PictureBox pictureBox1;
  63.  
  64.     }
  65.  
This way you don't have to delete controls and make new ones, then attach event handles and so on - you just change the type of the existing control.
Oct 9 '09 #5
2 Plater
2 tlhintoq
I'll rewrite now picturebox code. It's good thing that I have all the controls dynamic.
Oct 9 '09 #6
No, panel doesn't work... The same problem.
Oct 9 '09 #7
Hiii friends i have same problem. If anybody have any idea then please reply me. it is very argent.


Thanks in advance
Mar 4 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: Nathan Sokalski | last post by:
I am trying to create graphics with GDI+ that include transparency. However, the transparency never seems to show up, even though my colors have an alpha value of 0. How can I generate a graphic...
2
by: Alex Gray | last post by:
Hi, I'm trying to make my PictureBox transparent to the BackgroundImage of the Form, not the BackColor of the form. Here's what i have: ---------------------------------------------------...
1
by: Tim Geiges | last post by:
I wrote an image viewer and just added the zoom feature, so when the image is larger than the form scrollbars appear, but when I scroll the image(if it has transparency) it leaves a trail of image...
9
by: SStory | last post by:
I have a picturebox in my About form. would like to have a link to my company website. Wanted the links background to be transparent. It seems that no one knows how to do this. Have asked...
1
by: M West | last post by:
continuation of my previous post, thanks to all those that contributed with answers I am creating a control that will take an image and make parts of it transparent, this is done by creating and...
1
by: Andrew E Chapman | last post by:
I am having a problem with pictureboxes being trasnparent to some form objects, but not others (I want their transparent regions to be transparent to everything). So, say I have a background image...
1
by: bungle | last post by:
Hi, Could anyone give me a way of getting a picturebox in winforms to actually give me a transparent background? I need to layer images on top of one another and obviously can't at the moment. ...
3
by: kirk | last post by:
I have a form with a PictureBox control on it. The .Image property is set to a PNG file(which shows the picture of the US map) with some transparency in it. The .BackColor property is set to...
0
by: =?Utf-8?B?RG9jdG9y?= | last post by:
I am making an application that streams video from a web camera onto the client area of a PictureBox on a Windows CLR Form in MS Visual Studio 2005 (using C++). The streaming video works fine, and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.