473,769 Members | 6,107 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 5374
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
1485
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
2294
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
1936
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
14820
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
8791
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
10235
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
2205
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
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9994
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
9863
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
8870
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7408
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
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
5298
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...
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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.