Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PictureBox and Transparent

Posted on 2003-12-09
14
Medium Priority
?
924 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

618 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