Click here to Skip to main content
11,704,315 members (63,201 online)
Click here to Skip to main content

A simple transparent CStatic-derived class

, 16 Dec 2002 190.4K 7.5K 58
Rate this:
Please Sign up or sign in to vote.
This class allows you to create transparent static controls. For instance, you can add text on a bitmap in a dialog.

Description

Sometimes, transparent static controls are very useful. For example, you have a dialog with a bitmap in it and want to add some text in the picture. If you create a static control, your text will appear on an opaque background, even if you've selected the WS_EX_TRANSPARENT style (this style is *very* buggy).

How to implement

To use the class in your application you need to do the following:

  1. Insert the .h and .cpp files into your project.
  2. Add a static control into your dialog resource.
  3. Add a member variable for that static control.
  4. Modify the variable declaration.
    Change this:
    CStatic m_Static
    To this:
    CTransparentStatic m_Static
  5. Don't forget the #include at the top of the include file:
    #include "TransparentStatic.h"

That's it. You should now have a transparent background.

Features

The following Static Styles are implemented:

  • SS_LEFT
  • SS_LEFTNOWORDWRAP
  • SS_RIGHT
  • SS_CENTER
  • SS_CENTERIMAGE (center text vertically)
  • SS_NOPREFIX
  • SS_WORDELLIPSIS
  • SS_ENDELLIPSIS
  • SS_PATHELLIPSIS

The various borders (SS_SUNKEN, WS_EX_CLIENTEDGE, ...) are also supported.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Zorglab
Web Developer
Belgium Belgium
No Biography provided

You may also be interested in...

Comments and Discussions

 
QuestionHow to use it in VC6.0??? Pin
qingqingcao22-Dec-11 20:02
memberqingqingcao22-Dec-11 20:02 
QuestionWhat's the license of this article? Pin
Xueyan4-Sep-11 18:49
memberXueyan4-Sep-11 18:49 
GeneralGUI Bug Pin
Ain Bahadur Mor7-Oct-08 22:20
memberAin Bahadur Mor7-Oct-08 22:20 
GeneralNot Working.. Pin
renjith_sree29-Jun-04 20:22
memberrenjith_sree29-Jun-04 20:22 
GeneralRe: Not Working.. Pin
Jaime Stuardo21-Nov-04 3:53
memberJaime Stuardo21-Nov-04 3:53 
Questionwhere are the resource fiiles? Pin
gundamchen9-Jun-04 16:22
membergundamchen9-Jun-04 16:22 
GeneralHelp - filckering when repeatly redraw Pin
lily0lin7-May-04 8:29
memberlily0lin7-May-04 8:29 
GeneralRe: Help - filckering when repeatly redraw Pin
eric feng17-May-04 4:33
membereric feng17-May-04 4:33 
GeneralGarbled text on a redraw Pin
AAntix12-Jan-04 4:25
memberAAntix12-Jan-04 4:25 
QuestionHow to change static text color? Pin
jameslauta11-Dec-03 13:50
memberjameslauta11-Dec-03 13:50 
GeneralGood, How about Icon or Bitmap Pin
liuhoihing26-Nov-03 16:20
memberliuhoihing26-Nov-03 16:20 
GeneralSimple Enhancement Pin
liuhoihing26-Nov-03 17:00
memberliuhoihing26-Nov-03 17:00 
Questionwhy "ss_sunken" don't work?? Pin
send_ch17-Aug-03 2:04
membersend_ch17-Aug-03 2:04 
GeneralWM_ERASEBKGND Pin
MarkovAlex6-Aug-03 15:08
memberMarkovAlex6-Aug-03 15:08 
QuestionWhat if you need to redraw the text? Pin
Arash Salarian5-May-03 6:46
memberArash Salarian5-May-03 6:46 
AnswerRe: What if you need to redraw the text? Pin
use_id3-Jul-03 3:29
memberuse_id3-Jul-03 3:29 
AnswerRe: What if you need to redraw the text? Pin
tong_du8-Jul-03 10:03
membertong_du8-Jul-03 10:03 
GeneralRe: What if you need to redraw the text? Pin
Ye Fenglei21-Jul-03 21:37
memberYe Fenglei21-Jul-03 21:37 
GeneralRe: What if you need to redraw the text? Pin
imaudi8-Sep-03 18:48
memberimaudi8-Sep-03 18:48 
GeneralRe: What if you need to redraw the text? Pin
Sick@work2-Feb-04 3:29
memberSick@work2-Feb-04 3:29 
GeneralRe: What if you need to redraw the text? Pin
eric feng17-May-04 4:30
membereric feng17-May-04 4:30 
GeneralRe: What if you need to redraw the text? Pin
K(arl)1-Dec-05 21:38
memberK(arl)1-Dec-05 21:38 
GeneralRe: What if you need to redraw the text? Pin
Nic Wilson6-Jul-10 15:02
memberNic Wilson6-Jul-10 15:02 
GeneralRe: What if you need to redraw the text? Pin
wlburgess21-Oct-05 6:46
memberwlburgess21-Oct-05 6:46 
GeneralI use it in windowsce.net,but error has happened Pin
Tony.Xu27-Mar-03 21:08
memberTony.Xu27-Mar-03 21:08 
GeneralRe: I use it in windowsce.net,but error has happened Pin
Zorglab28-Mar-03 7:28
memberZorglab28-Mar-03 7:28 
QuestionCan it make Bitmap transparent? Pin
Jack_Cai20-Mar-03 18:46
memberJack_Cai20-Mar-03 18:46 
AnswerRe: Can it make Bitmap transparent? Pin
Zorglab21-Mar-03 19:24
memberZorglab21-Mar-03 19:24 
GeneralGreat, but..... Pin
mgargett28-Feb-03 2:34
membermgargett28-Feb-03 2:34 
GeneralRe: Great, but..... Pin
Zorglab21-Mar-03 19:25
memberZorglab21-Mar-03 19:25 
GeneralRe: Great, but..... Pin
Olaf Gramkow19-Dec-03 7:35
memberOlaf Gramkow19-Dec-03 7:35 
GeneralRe: Great, but..... (SetWindowText problem) Pin
Erin Loy14-Mar-05 13:30
sussErin Loy14-Mar-05 13:30 
GeneralRe: Great, but..... Pin
RancidCrabtree29-Sep-05 7:09
memberRancidCrabtree29-Sep-05 7:09 
GeneralIt Does Not Work with Multiple Inheritance Pin
Julio Fabio Chagas14-Feb-03 4:59
memberJulio Fabio Chagas14-Feb-03 4:59 
GeneralRe: It Does Not Work with Multiple Inheritance Pin
Zorglab14-Feb-03 9:07
memberZorglab14-Feb-03 9:07 
GeneralRe: It Does Not Work with Multiple Inheritance Pin
Julio Fabio Chagas17-Feb-03 1:49
memberJulio Fabio Chagas17-Feb-03 1:49 
GeneralWS_EX_TRANSPARENT Pin
Marc Clifton18-Dec-02 0:52
memberMarc Clifton18-Dec-02 0:52 
GeneralRe: WS_EX_TRANSPARENT Pin
Zorglab18-Dec-02 1:44
memberZorglab18-Dec-02 1:44 
GeneralRe: WS_EX_TRANSPARENT Pin
Marc Clifton18-Dec-02 1:50
memberMarc Clifton18-Dec-02 1:50 
GeneralRe: WS_EX_TRANSPARENT Pin
Zorglab18-Dec-02 22:54
memberZorglab18-Dec-02 22:54 
GeneralRe: WS_EX_TRANSPARENT Pin
Paolo Messina18-Dec-02 14:56
memberPaolo Messina18-Dec-02 14:56 
GeneralRe: WS_EX_TRANSPARENT Pin
Zorglab18-Dec-02 22:46
memberZorglab18-Dec-02 22:46 
GeneralRe: WS_EX_TRANSPARENT Pin
Paolo Messina19-Dec-02 0:23
memberPaolo Messina19-Dec-02 0:23 
GeneralRe: WS_EX_TRANSPARENT Pin
Zorglab2-Apr-03 7:14
memberZorglab2-Apr-03 7:14 
GeneralRe: WS_EX_TRANSPARENT Pin
RancidCrabtree29-Sep-05 7:13
memberRancidCrabtree29-Sep-05 7:13 
GeneralRe: WS_EX_TRANSPARENT Pin
AndrewSmirnov11-Aug-03 16:12
memberAndrewSmirnov11-Aug-03 16:12 
GeneralRe: WS_EX_TRANSPARENT Pin
lbs7516-Nov-05 18:28
memberlbs7516-Nov-05 18:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150819.1 | Last Updated 17 Dec 2002
Article Copyright 2002 by Zorglab
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid