Solved

PictureBox and Transparent

Posted on 2003-12-09
14
912 Views
Last Modified: 2008-02-01
Hi,

I am using VC.net 2003.  I have a WinForm and on that I put a picturebox.  I am trying to show a round LED with a 16x16 bmp.  The problem is, since the corners are some color, in my case olive, the picture doesn't look right.  I am used to Delphi/Borland C++ Builder where I just need to set the Transparent property to true.  How do I accomplish the same thing in VC.net?  I want to be able to change the color of the form (or whatever I eventually place the picturebox on) and still only see the round image.

Thank you,
Joe
0
Comment
Question by:joeslow
  • 8
  • 6
14 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9915128
I am a VB programmer, with a little experience with C++.  I wouldn't be afraid to try to help, since no one else seems to want to get involved, if you are still having problems?
0
 

Author Comment

by:joeslow
ID: 9915524
I think I figured it out how to do it programmatically:

First, I load the image in an imagelist because that lets me select the transparent color (olive in my case).  Then I assign it to the picture box at runtime like this:

pictureBox1->Image = imageList1->Images->Item[0];

This seems to work.  I don't see a way to do it at design time however.  If you have any ideas, let me know.

Thanks,
Joe
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9915530
My first question would be, could you use a transparent GIF?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9930609
Are you still having a problem with this?  Did my question make sense?
0
 

Author Comment

by:joeslow
ID: 9941936
I guess so.  Although I have access to more bmp files...
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9942598
I can't think of any other way to do it in design-mode right now.
0
 

Author Comment

by:joeslow
ID: 9945020
So, the solution I came up with is OK?

Joe
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 96

Expert Comment

by:Bob Learned
ID: 9945107
Most of the time I don't concern myself with design-time issues, and I get into placing controls where I want them at run-time.  Your solution is OK as far as I am concerned.  I was just trying to show you an alternative with transparent GIFs or icons that would give you the transparency that you want at design time.  I understand, though, having bitmaps, and not wanting to convert them all.

My normal mode of operation is to keep around a huge collection of 16 x 16 bit icons whenever I need them, and not to use bitmaps.
0
 

Author Comment

by:joeslow
ID: 9950866
Go ahead and show me.  I'm not opposed to icons or gifs I just don't have as many to choose from (maybe you know of some good free sources).

Thanks,
Joe
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9950882
Show you what?  How to convert bitmaps to transparent GIFs/Icons?
0
 

Author Comment

by:joeslow
ID: 9951205
Are you saying you can create icons and gifs that are already have transparent regions and you can't do that with bitmaps?  If that's the case, I guess you don't have to do anything when you add them to a picture box...

Joe
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 200 total points
ID: 9951240
Icons and GIFs have the ability for transparency, where bitmaps do not.  I have tools, such as ImageEdit (from VB6), and the image editor in VS.NET (I don't use this one very much), to create icons.

When I need to create a transparent GIF, then I use something like Micro$oft's PhotoDraw 2000.  It has the ability to set transparency for GIF files.

With images that have a transparency, the picture box will draw them with the transparency, so what you see is what you get.
0
 

Author Comment

by:joeslow
ID: 9952167
Thanks for the info - I guess I'll try to find some good ones for my app, otherwise, I'll set it at run time...

Joe
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9952178
Have fun!

Bob
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now