Note: The code in this article is restricted to win98 and win2000.
Do you want a cool splash window? Do you think the general splash window is not good enough for your app? Then this sample source is for you.
My semi-transparent splash window uses the AlphaBlend
function. When I found this function, I was so surprised! The function works just like BitBlt
for bitmaps that have transparent or semitransparent pixels. Here is the AlphaBlend
function's syntax.
BOOL AlphaBlend( HDC hdcDest,
int nXOriginDest,
int nYOriginDest,
int nWidthDest,
int nHeightDest,
HDC hdcSrc,
int nXOriginSrc,
int nYOriginSrc,
int nWidthSrc,
int nHeightSrc,
BLENDFUNCTION blendFunction
);
The important parameter is the last one, BLENDFUNCTION
.
typedef struct _BLENDFUNCTION {
BYTE BlendOp;
BYTE BlendFlags;
BYTE SourceConstantAlpha;
BYTE AlphaFormat;
}BLENDFUNCTION;
BlendOp
must be AC_SRC_OVER
BlendFlags
must be 0
SourceConstantAlpha
must be between 0 (transparent) and 255 (semi-transparent) AlphaFormat
must be AC_SRC_ALPHA
MSDN states: The SourceConstantaAlpha
member of BLENDFUNCTION
specifies an alpha transparency value to be used on the entire source bitmap. The SourceConstantAlpha
value is combined with any per-pixel alpha values. If you set SourceConstantAlpha
to 0
, it is assumed that your image is transparent. Set the SourceConstantAlpha
value to 255
(indicates that the image is opaque) when you only want to use per-pixel alpha values.
See the sample application for a demonstration.
Just enjoy!!
Ajou University C.C. 4th member.
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.