473,740 Members | 6,250 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Second PictureBox's background goes white when placed over anotherPictureB ox

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 Transparent.
This so far, works perfect.

I now, would like to put another PNG image(an arrow showing
positioning on the map) over the last PictureBox. The problem i'm
having, the background for this second PictureBox only stays
transparent when it is over the form. As soon as I move this second
PictureBox over the first PictureBox, the background turns white.

Am I missing a setting for the second PictureBox or implementing this
wrong?
Thanks.
Jan 29 '08 #1
3 5372
On Mon, 28 Jan 2008 20:56:31 -0800, kirk <ki****@gmail.c omwrote:
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 Transparent.
This so far, works perfect.

I now, would like to put another PNG image(an arrow showing
positioning on the map) over the last PictureBox. The problem i'm
having, the background for this second PictureBox only stays
transparent when it is over the form. As soon as I move this second
PictureBox over the first PictureBox, the background turns white.

Am I missing a setting for the second PictureBox or implementing this
wrong?
I don't know why the background color _changes_. But you're not going to
get the PictureBox to really be transparent. In .NET forms applications,
"transparen t" actually just means "use my parent's background color".

You can search this newsgroup for words like "transparen t control" and see
previous threads discussing the issue. The short answer is that if you
want to transparently layer two PNG images on top of each other, the
simplest way to do that is to composite them outside the control.

If I recall correctly, I was able to come up with a hack that faked
transparency in a .NET forms control, but I was never really happy with
the technique. It involved copying the underlying control contents into a
bitmap and using that as the background for the control that's supposed to
be transparent. I can't say I'd suggest it except where there are really
no other alternatives. It's got a lot of overhead, and is very fragile
(easy to get it wrong and/or get rendering artifacts).

Pete
Jan 29 '08 #2
On Jan 28, 9:13*pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:
On Mon, 28 Jan 2008 20:56:31 -0800, kirk <kir...@gmail.c omwrote:
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 Transparent.
This so far, works perfect.
I now, would like to put another PNG image(an arrow showing
positioning on the map) over the last PictureBox. *The problem i'm
having, the background for this second PictureBox only stays
transparent when it is over the form. *As soon as I move this second
PictureBox over the first PictureBox, the background turns white.
Am I missing a setting for the second PictureBox or implementing this
wrong?

I don't know why the background color _changes_. *But you're not going to *
get the PictureBox to really be transparent. *In .NET forms applications, *
"transparen t" actually just means "use my parent's background color".

You can search this newsgroup for words like "transparen t control" and see*
previous threads discussing the issue. *The short answer is that if you *
want to transparently layer two PNG images on top of each other, the *
simplest way to do that is to composite them outside the control.

If I recall correctly, I was able to come up with a hack that faked *
transparency in a .NET forms control, but I was never really happy with *
the technique. *It involved copying the underlying control contents intoa *
bitmap and using that as the background for the control that's supposed to*
be transparent. *I can't say I'd suggest it except where there are really *
no other alternatives. *It's got a lot of overhead, and is very fragile *
(easy to get it wrong and/or get rendering artifacts).

Pete
Thanks for the info Pete.

I attempted deriving from PictureBox and overriding various members,
setting the ExStyle, etc. Seems ok, the overlay image i'm using is an
animated GIF, so i'm getting flicker however. I notice setting
ExStyle to transparent does this quite often. So one option down the
drain.

Another thing i'm experimenting with which I almost having working.
If I set the .BackgroundImag e to the US Map, and the .Image to the
animated GIF that is a marker of where I want to indicate selections
on the map, this works. The only thing I can't figure out is how to
move .Image to new X,Y coordinates within the the PictureBox. I
know .SizeMode moves it around to limited spots, so I know there may
be a good possibility if there is something not published or in
Reflection? Any ideas?

Thanks.
Jan 30 '08 #3
On Tue, 29 Jan 2008 19:15:31 -0800, kirk <ki****@gmail.c omwrote:
// one way
Graphics g = PictureBox1.Cre ateGraphics();
g.DrawImage(myI mage, 0, 0); // 0, 0 are the x,y coordinates within the
PictureBox control
PictureBox1.Upd ate();
Don't do this. You should only draw from within an OnPaint() method or a
Paint event handler.
// another way, using PaintEventArgs from an event on PictureBox
PaintEventArgs. Graphics.DrawIm age(myImage, 0, 0);
This way is fine, but it begs the question as to the point of using the
PictureBox control. If you're going to do the drawing yourself, why
bother?
Both of these work, dynamic image positioning over the background map
is perfect. And the GIF is transparent as it should be. The new
problem. Neither option, animates the GIF. I'm wondering, what is so
special about PictureBox.Imag e that makes it animate? And is there
anything at my disposal that I can stub in, in place of or to
supplement the .DrawImage calls to get the image animating?
Not that I know of. For sure, if you are managing your own drawing, by
calling DrawImage yourself (in a Paint event handler, for example), then
it will be up to you to correctly deal with the GIF, getting the animation
interval from the image data and then updating the image at appropriate
intervals, using the different frames withing the GIF in sequence.

It's possible that WPF could be helpful here. Unfortuantely, as I have to
point out any time I mention WPF, I have no first-hand experience with it,
so can't offer anything specific. But the fact that WPF has more of a
"retained" data model (i.e. you specific the objects, it handles all the
drawing behavior for you) suggests that it might provide a more automatic
way to implement this.

Pete
Jan 30 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1484
by: Reiner Block | last post by:
Hi, I installed eric3 and done the settings. But I don't like the white background and changed at Options/Editor/Sourcecode, language Python the background color and font. But it affects just the source text in the editor. After the end of the text in each line is still the white background. But I found no possibility to change that. Does I am blind or is it really not possible?
1
2292
by: CMAR | last post by:
I have a design of a frameless page on my practice website: http://home.ne.rr.com/thespar/designerN.htm The idea is to have a #left navigation bar which is absolutely positioned and which contains a series of vertical placed unordered lists of links. To the right of the #left navigation bar is the #content section. I want the background in the #left section to extend to the bottom of the browser window.
6
1935
by: Mark | last post by:
Hello all - I'm trying to incorporate a stylesheet into an ASP.Net page but everytime I include the "LINK" code to the .css file in the HEADER location of the HTML code, the background color that I have set (which is blue) gets changed to white. Below is my code in the HTML of the ASP.NET page and then my code in the .css file. Any help is sincerely appreciated as I haven't worked with stylesheets alot in my past. Thanks for any...
9
14816
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 many times. VB help says that transparent is possible with a background image but not above a control. So how can I provide a link (URL) that is clickable, but transparent, over the picturebox in my about box?
1
8789
by: Ricardo Furtado | last post by:
in my app i must have several pictureboxes over the others. Some pictureboxes just have a couple of lines or rectangles, and absolutly nothing more but the image is an .BMP. So, my problem is that i need to see whats beind those pictureboxes and at the same time showing, the lines and rectangles that exist on the pictureboxes that are at the top. Because i just can't copy the image to the other picturebox (because i'll have to be able to...
4
10233
by: Yash | last post by:
Have used DrawLine() method to draw some lines in the picturebox (sort of a barcode) in the picturebox paint event. This diagram has to be saved as an image in bmp or tiff format. But the problem is that these lines are not recognized as the image of the picturebox. It shows picturebox.image = nothing. How do we convert these lines drawn as the image of the picturebox so that it can be saved.
11
2203
by: Gérard Talbot | last post by:
Hello, <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <title></title> <style type="text/css"> body {background-color: white; color: black;} #parent_block {background-color: red; width: 100%;} #nested_child_block {margin: 150px 0px; background-color: green; color: white;}
0
1367
by: Jerry West | last post by:
Coming from VB6 a PictureBox was a container for other controls. This doesn't seem to be the case with .NET. In light of that can someone comment on the following.... I'm creating an app that loads a Form to maximum screen size. On the Form I have a PictureBox control that also maxs out to the screen's full resolution. I then randomly load images into the PictureBox. What I was hoping to do is have a Panel inside the PictureBox that...
0
2706
by: ton | last post by:
Hi, I have an Image which is dark grey/black, at the top a white line, at the left site a white line as well. At 192 px from the left of the screen I position a DIV with this image as the background image. In the code I've added a multi line textbox (in my real world it is a treeview). It is placed that I would have to scroll to see the entire textbox. What happens is that the image will repeat itself, this is what you expect. Because...
0
8969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8794
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9272
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9211
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6056
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4572
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3286
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2195
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.