Solved

PictureBox and Transparent

Posted on 2003-12-09
14
919 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

 
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
 
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

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 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