?
Solved

PictureBox and Transparent

Posted on 2003-12-09
14
Medium Priority
?
925 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
Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month15 days, 17 hours left to enroll

850 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