473,326 Members | 2,111 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,326 software developers and data experts.

Transparent GIF in a transparent container. Easy right?!?!?!

I'm a former VB6 coder. Quit a few years ago. Now I'm back and trying
to teach myself VB.NET. I don't remember having this much difficulty
learning VB6. I'm totally stuck on something and need your expert
guidance.

I just want to load a GIF with a transparent background into a
container with a transparent background. So I can move the GIFs over
and under each other. You know, as in basic game stuff. I can load the
transparent GIF no prob, I just -cannot- get any container to have a
transparent background. Yes, I have looked at all the seemingly
obvious container properties. I've set and reset them to
color.transparent and etc. with no luck. I've set the picbox
background to red, loaded the GIF and I can see thru the GIF to the
red background. I know the GIF isn't the problem.

This seems so silly/simple/basic I can't understand why I haven't
found any examples. Perhaps my search words are suspect. Not sure. Can
someone please post the three or four lines of code and/or steps
necessary to do this?

Thank you, thank you, thank you, thank you for your help,

Mark :-)
Nov 20 '05 #1
5 6429
Hi Mark,

It is amazingly easy to do what you want. - if you use .NET's WinApi-ish
overrides.

I say easy, not 'cos I've done it, but because I've read the article - and
the juicy bit is only a few lines long.

Bob Powell's the man who knows.
http://www.bobpowell.net/transcontrols.htm

Regards,
Fergus
Nov 20 '05 #2
> It is amazingly easy to do what you want. - if you use .NET's WinApi-ish
overrides.

I say easy, not 'cos I've done it, but because I've read the article - and
the juicy bit is only a few lines long.

Bob Powell's the man who knows.
http://www.bobpowell.net/transcontrols.htm


Wow, so I'm actually not a moron. Read through Bob's example. I had no
idea it would be so tough. Let me ask a quick follow up question. Can
I load, display, and move a GIF around on the main form without
putting it in a container? In other words, is the container necessary?

Thanks for replying Fergus.

Mark :-)
Nov 20 '05 #3
Hi Mark,

Let's be pedantic first. A gif is a file format which will be transformed
into a bitmap. A bitmap is just that - a block of bits, although a .NET Bitmap
is a bit more, but still just a fancy data structure. Nothing new to you, I
reckon - you were just hoping it might be different. When it comes to the
screen we need Windowy things which a Bitmap doesn't have.

So, yes, you do need the container - because that's the one that knows a
thing or two about being visible.

Now, let's get a bit more useful, perhaps - but I'm only guessing from the
use of that word 'game'

I imagine that you want to have several sprites dancing around. You could
do it with each sprite fitting neatly inside its own container, and I'm no
expert so this may be the best way. But you could also do it with a couple or
several game arena sized 'layers' and have more than one sprite on that layer.
This would be best suited for static images, but it may be useful even with
moving images depending on what, and how, and when's tea.

The Graphics of a container can be drawn on at any point and within given
bounds, so you are not just restricted to loading a gif into a PictureBox. You
can load an image into a Bitmap (which will just be a dumb resource waiting to
be used) and then copy it or parts of it into your 'layer' as required.

Now I guess, I sound like I know what I'm talking about ;-) but I haven't
done this. I've seen it done and know enough bits and pieces to give you a
thirst for more. But when you start asking me for more details, I'll start
umming and aahing.

But I will suggest making friends with Graphics.DrawImage as this has
loads of overloads. If it's not enough for what you want, though, you can
still use the WinApi BitBlt. The .NET declaration is below.

Have fun.

Regards,
Fergus

Public Declare Function BitBlt Lib "gdi32" ( _
ByVal hDestDC As IntPtr, _
ByVal x As Integer, _
ByVal y As Integer, _
ByVal nWidth As Integer, _
ByVal nHeight As Integer, _
ByVal hSrcDC As IntPtr, _
ByVal xSrc As Integer, _
ByVal ySrc As Integer, _
ByVal dwRop As Integer _
) As Integer

Const SRCCOPY As Integer = &HCC0020
Nov 20 '05 #4
Bob Powells example on how to make a transparent control is in C#.
Helps a bit but not enough.

I definitely appreciate your words of wisdom. I'll see what I can
learn about using DrawImage. I'll also be very happy when I find some
VB.NET code which accomplishes what Bob talks about in his transparent
control C# example.

Mark :-)

"Fergus Cooney" <fi*****@post.com> wrote in message news:<Ou**************@TK2MSFTNGP11.phx.gbl>...
Hi Mark,

Let's be pedantic first. A gif is a file format which will be transformed
into a bitmap. A bitmap is just that - a block of bits, although a .NET Bitmap
is a bit more, but still just a fancy data structure. Nothing new to you, I
reckon - you were just hoping it might be different. When it comes to the
screen we need Windowy things which a Bitmap doesn't have.

So, yes, you do need the container - because that's the one that knows a
thing or two about being visible.

Now, let's get a bit more useful, perhaps - but I'm only guessing from the
use of that word 'game'

I imagine that you want to have several sprites dancing around. You could
do it with each sprite fitting neatly inside its own container, and I'm no
expert so this may be the best way. But you could also do it with a couple or
several game arena sized 'layers' and have more than one sprite on that layer.
This would be best suited for static images, but it may be useful even with
moving images depending on what, and how, and when's tea.

The Graphics of a container can be drawn on at any point and within given
bounds, so you are not just restricted to loading a gif into a PictureBox. You
can load an image into a Bitmap (which will just be a dumb resource waiting to
be used) and then copy it or parts of it into your 'layer' as required.

Now I guess, I sound like I know what I'm talking about ;-) but I haven't
done this. I've seen it done and know enough bits and pieces to give you a
thirst for more. But when you start asking me for more details, I'll start
umming and aahing.

But I will suggest making friends with Graphics.DrawImage as this has
loads of overloads. If it's not enough for what you want, though, you can
still use the WinApi BitBlt. The .NET declaration is below.

Have fun.

Regards,
Fergus

Public Declare Function BitBlt Lib "gdi32" ( _
ByVal hDestDC As IntPtr, _
ByVal x As Integer, _
ByVal y As Integer, _
ByVal nWidth As Integer, _
ByVal nHeight As Integer, _
ByVal hSrcDC As IntPtr, _
ByVal xSrc As Integer, _
ByVal ySrc As Integer, _
ByVal dwRop As Integer _
) As Integer

Const SRCCOPY As Integer = &HCC0020

Nov 20 '05 #5
md******@mailblocks.com (Mark Deibert) wrote in message news:<cf**************************@posting.google. com>...
I'm a former VB6 coder. Quit a few years ago. Now I'm back and trying
to teach myself VB.NET. I don't remember having this much difficulty
learning VB6. I'm totally stuck on something and need your expert
guidance.

I just want to load a GIF with a transparent background into a
container with a transparent background. So I can move the GIFs over
and under each other. You know, as in basic game stuff. I can load the
transparent GIF no prob, I just -cannot- get any container to have a
transparent background. Yes, I have looked at all the seemingly
obvious container properties. I've set and reset them to
color.transparent and etc. with no luck. I've set the picbox
background to red, loaded the GIF and I can see thru the GIF to the
red background. I know the GIF isn't the problem.

This seems so silly/simple/basic I can't understand why I haven't
found any examples. Perhaps my search words are suspect. Not sure. Can
someone please post the three or four lines of code and/or steps
necessary to do this?

Thank you, thank you, thank you, thank you for your help,

Mark :-)

Mark - if you are still struggling here, let me know if you would
consider using a commercial component. Our MetaDraw control (
available for either VB 6 or .NET Winforms ) will allow you to have
one or multiple transparent GIF's within a container which itself has
a transparent background ( you can even scroll, zoom, draw upon, and
print the container plus lots more )

Write to me by e-mail if you are interested.
I'd be happy to answer any questions and get you
started with evaluation
Please include a copy of this message with your reply.
Jeff Bennett
Je**@Bennet-Tec.Com

Bennet-Tec Information Systems, Inc
50 Jericho Tpk, Jericho, NY 11753
Phone 516 997 5596, Fax - 5597
WWW.Bennet-Tec.Com

RELIABLE Component Software
and Software Development Services
* TList/Pro * ALLText HT/Pro * MetaDraw *

====================== ======================
Nov 20 '05 #6

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

Similar topics

2
by: Henrik | last post by:
Hi how can i make the backcolor of a form transparent best regards Henrik
1
by: Richard Saville | last post by:
I am trying to make a transparent pictureBox. MSDN says to use this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); for the form and this.pictureBox1.BackColor = Color.Transparent; for...
2
by: Jaikumar | last post by:
Hi, 1) I have created one windows application, In the main form ( form1) i have added one usercontrol (usercontrol1), In that user control i am drawing one image. 2) In the UserControl1 i am...
3
by: °Ë´óɽÈË | last post by:
HI, I create a custom transparent control, set the style is ControlStyles.DoubleBuffer, It display black background. How to create a double buffer transparent control?
7
by: Peter Oliphant | last post by:
Using MakeTransparent one can supposedly turn a color used in a Bitmap to transparent. But, it looks to me like all it does it set these pixels to the color BackColor of the Control it's attached...
8
by: Grahammer | last post by:
Is it possible to set the background of a usercontrol as transparent? I tried setting the background image of the usercontrol to a transparent GIF, but that caused MAJOR problems. I'm making...
0
by: Henry Wu | last post by:
Hi, I am aware that TransparencyKey only works with top-level forms or Non-MDI Child Forms, if one tries to set the opacity or transparencykey property to a MDI-Child form, it will have no effect....
4
by: Joseph Geretz | last post by:
Don't get me wrong - I'm a fan of .NET; I am enthusiastic about the richness and elegance of the environment. However, richness and elegance should be dedicated toward making development easier for...
7
by: ademirzanetti | last post by:
Hi there !!! I would like to listen your opinions about inherit from a STL class like list. For example, do you think it is a good approach if I inherit from list to create something like...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.