Click here to Skip to main content
13,629,232 members
Click here to Skip to main content
Add your own
alternative version


36 bookmarked
Posted 15 Jul 2004

Implementing compound shadows with CExtWndShadow

, 15 Jul 2004
Rate this:
Please Sign up or sign in to vote.
A CExtWndShadow class, which should enable you to easily draw compound shadows anywhere you want.

Sample Image - ExtWndShadow.gif


This article introduces a CExtWndShadow class, which should enable you to easily draw compound shadows anywhere you want.

The class is partially based on the CExtWndShadow class presented in the freeware version of the Prof-UIS library available here.

How to use it

The CExtWndShadow class is simple to use. To add it to your project, please follow the steps below:

  1. Put its source files (CExtWndShadow.cpp and CExtWndShadow.h) into the proper folder and add their file names to your Visual Studio project.
  2. Include its header to the appropriate header file. If you plan to use CExtWndShadow in more than one place, it's reasonable to add it to the stdafx.h file.
    #include "CExtWndShadow.h"

Method description

bool Paint(
    CDC & dc,
    const CRect & rcWndArea,
    UINT nShadowSize = DEF_SHADOW_SIZE,
    bool bEnablePhotos = true

Draws the shadow.

  • CDC & dc

    Reference to the device context that is used for drawing the shadow.

  • const CRect & rcWndArea

    Reference to the rectangular area in which the shadow is drawn.

  • UINT nShadowSize

    Size of the shadow in pixels, which is the same for the width and height.

  • UINT nBr0

    Minimum brightness of the shadow, which must be in the range 0 to 10.

  • UINT nBr1

    Maximum brightness of the shadow, which must be in the range 0 to 10.

  • bool bEnablePhotos

    If bEnablePhotos is set to true, specifies that the shadow algorithm is used at first and then the image is just displayed; otherwise, the shadow algorithm is used every time.

Return Value
  • Nonzero if successful.


For instance, if you want to draw a shadow for an edit control, use the following code:

CRect rcEdit;
rcEdit.InflateRect( 2, 2, 0, 0 ); // shadow placement adjustment
CExtWndShadow _shadow;
    dcPaint, rcEdit,
    5, // shadow size


The ShadowsTest sample project shows how to apply the class to some controls.

Reporting bugs

Your questions, suggestions, and bug reports may be posted either to the forum below or to the forum at the Prof-UIS website.


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


About the Author

Dmitriy Yakovlev
Software Developer (Senior)
Ukraine Ukraine
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionHow can i create a shadow for a Irregular window ? Pin
qsw123qsw7-Aug-12 6:44
memberqsw123qsw7-Aug-12 6:44 
QuestionPretty good! Pin
a_savant5-Nov-07 11:59
membera_savant5-Nov-07 11:59 
AnswerRe: Pretty good! Pin
Dmitriy Yakovlev6-Nov-07 2:50
memberDmitriy Yakovlev6-Nov-07 2:50 
QuestionWhat if move the controls? Pin
werter113-Dec-04 21:51
memberwerter113-Dec-04 21:51 
AnswerRe: What if move the controls? Pin
Dmitriy Yakovlev13-Dec-04 22:23
memberDmitriy Yakovlev13-Dec-04 22:23 
GeneralShadow for application Window Pin
crappy_sites23-Jul-04 11:29
membercrappy_sites23-Jul-04 11:29 
GeneralRe: Shadow for application Window Pin
th3matr1x9-Jul-05 6:20
memberth3matr1x9-Jul-05 6:20 
GeneralRe: Shadow for application Window Pin
AlexSZhang2-Nov-05 19:23
memberAlexSZhang2-Nov-05 19:23 
GeneralRe: Shadow for application Window Pin
th3matr1x5-Nov-05 1:05
memberth3matr1x5-Nov-05 1:05 
GeneralAny chance... Pin
.dan.g.18-Jul-04 15:30
member.dan.g.18-Jul-04 15:30 
GeneralGood work ! some comments... Pin
minox17-Jul-04 0:49
memberminox17-Jul-04 0:49 
GeneralRe: Good work ! some comments... Pin
Manni Singh4-Aug-06 9:07
memberManni Singh4-Aug-06 9:07 
GeneralBug, using on a button Pin
JimmyO16-Jul-04 2:36
memberJimmyO16-Jul-04 2:36 
GeneralRe: Bug, using on a button Pin
Dmitriy Yakovlev16-Jul-04 3:36
memberDmitriy Yakovlev16-Jul-04 3:36 

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

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

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.180712.1 | Last Updated 16 Jul 2004
Article Copyright 2004 by Dmitriy Yakovlev
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid