Adding the class to your project
There are three steps you have to follow before you can use this class in
- Add BDialog.cpp and BDialog.h to your project
- Replace all instances of
this to both the cpp and h file of your dialog class. For example if your
project is called Test, make the changes to TestDlg.cpp and
TestDlg.h. You'll have to use Find and Replace.
#include BDialog.h to your dialog header file
So basically we have derived our dialog class from
CBDialog instead of
CDialog, but since
CBDialog is derived from
won't have any problems with your existing code.
Using the class
Basically there are just two methods that you need to call.
void CBDialog::SetBitmapStyle(int style)
style - This is used to set the bitmap background style. You can
use one of the following three styles.
StyleTile - The background image will be tiled
StyleStretch - The background image will be stretched
StyleCenter - The background image will be centered, if it is smaller than the client area of the dialog
You can call this method either from
OnInitDialog() or from any other
place in your dialog class. If you call it outside
also have to call
Invalidate() to force a repaint of the dialog client
int CBDialog::SetBitmap(UINT nIDResource)
nIDResource - This specifies the resource ID number of the bitmap
The return value is zero on success and non-zero on failure.
Nish is a real nice guy who has been writing code since 1990 when he first got his hands on an 8088 with 640 KB RAM. Originally from sunny Trivandrum in India, he has been living in various places over the past few years and often thinks it’s time he settled down somewhere.
Nish has been a Microsoft Visual C++ MVP since October, 2002 - awfully nice of Microsoft, he thinks. He maintains an MVP tips and tricks web site - www.voidnish.com
where you can find a consolidated list of his articles, writings and ideas on VC++, MFC, .NET and C++/CLI. Oh, and you might want to check out his blog on C++/CLI, MFC, .NET and a lot of other stuff - blog.voidnish.com
Nish loves reading Science Fiction, P G Wodehouse and Agatha Christie, and also fancies himself to be a decent writer of sorts. He has authored a romantic comedy Summer Love and Some more Cricket
as well as a programming book – Extending MFC applications with the .NET Framework
Nish's latest book C++/CLI in Action
published by Manning Publications is now available for purchase. You can read more about the book on his blog.
Despite his wife's attempts to get him into cooking, his best effort so far has been a badly done omelette. Some day, he hopes to be a good cook, and to cook a tasty dinner for his wife.