[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Deriving a CStatic so it will not paint a specific color...

Posted on 1997-08-13
3
Medium Priority
?
435 Views
Last Modified: 2013-11-20
I want to derive a CStatic class so that it will not display a specific color when  a bitmap is assigned to it.  Should I do this in OnPaint()?  Basically, I've got some bitmaps with a white background that I want to make transparent when it is displayed in a CStatic control.

Source examples are needed and appreciated.

Thanks in advance,
   Dave
0
Comment
Question by:David Gray
[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
  • 2
3 Comments
 

Accepted Solution

by:
kaelin earned 400 total points
ID: 1303699
Dave,

You cannot derive and do your own drawing with a CStatic control,
because the underlying Windows control does not support an
owner-draw flag.  You could do a CButton or CListCtrl, however
there's not much point in deriving from any of these anyway
because a CStatic control is the simplest control there is.
Just make your own replacement class derived directly from CWnd,
and then draw your bitmap from OnPaint.

"Masking" the image to make one color transparent is another
matter.  The easiest way to do this is to convert your bitmaps
to icons and then use CDC::DrawIcon to paint them.  What an
icon has that a bitmap lacks is a mask, which is simply an extra
1-bit deep bitmap where off bits are treated as transparent
parts of the image.  You can easily convert bitmaps to icons
using Developer Studio's resource editor.  Create a new icon resource of the desired size, and then paste the bitmap from the
clipboard and change the areas you want transparent to the
icon's "background" color in the editor.

If for some reason you don't want to let DrawIcon do all the
work, the function to check out is CDC::BitBlt.  It will take
multiple BitBlt calls to do the same thing, with various ROP
codes in a specific order (I don't recall the details off the
top of my head).

I hope you find these tips useful.
0
 

Author Comment

by:David Gray
ID: 1303700
How can you make a icon of a desired size to fit the the size of the bitmap, when I tried before it seemed like it would only let me have the standard 32x32 size.  If I could use the icon class to display bitmaps, this is a totally acceptable solution, if you know a way to make the allowable size for an icon larger.

0
 

Author Comment

by:David Gray
ID: 1303701
Never mind my previous comment, I just discovered the way to customize the size of an icon.  I never noticed the little toolbar icon that allows you to choose a specific size.

Thanks for you help,
    Dave
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

650 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