I've been using Almond and Maunder's
DrawWireRects function because
I always like my programs to look cool. That function is great and all, however,
to use it I need to overload
OnDestroy functions in
EVERY dialog class which I want it to be effected, there are a few inconvenience
on directly reusing the
- If there are many (well, let's say 5) different kind of Dialog boxes I will be using in a
project, each of which has to be a new class due to their different functionalities, then
I need to overload
OnDestroy functions in every class
and add some other members which are needed to complement the animation effect. Those
will be quite a lot of duplicated code.
- Other than animating the dialogs, I may also want to make some adjustment from time to time,
for example, I want a dialog with class name of
CMyDialog open from
center and close towards its bottom-right corner, then a few minutes later I
change my mind and want it close towards the system tray... anyway, I should
be able to do those kind of stuff by simply using the
DrawWireRects, but quickly I'll find out size of
up rapidly, and so do other dialog classes in that project.
It would be nice if there was an existing class that encapsulates all those necessary stuff,
I could just derive my classes from it and it does all the dirty work for me.
So that's where the
CAniDialog class came from.
The CAniDialog class
First of all, the heart and soul of this class is the
which was written by Almond and Maunder, so credits go there. I tried to
leave that function as intact as possible, some small changes were necessary to be done,
however, in order to make it cooperate with other class members well.
CAniDialog class is derived from
aim of this class is to make using animated dialog boxes as simple as using
MessageBox function, the only thing that really needed to be
provided by the user is a
CPoint object, which specifies where the dialog box should pop up from
and close towards if you are going to use the
AS_REFER animation style flag.
All other elements have default values and, in most case, are already optimized and need not be changed.
Public Methods of the CAniDialog class
CAniDialog(UINT nDlgID, CWnd* pParent);
CAniDialog(CPoint pt, UINT nDlgID, CWnd* pParent);
UINT GetFrameNum() const;
void SetFrameNum(UINT nFrames);
UINT GetAniSpeed() const;
void SetAniSpeed(UINT nMillSec);
CPoint GetRefPt() const;
void SetRefPt(CPoint pt);
WORD GetOpenStyle() const;
WORD GetCloseStyle() const;
void SetAniStyles(WORD wOpenStyle, WORD wCloseStyle);
WORD GetDispStyle() const;
void SetDispStyle(WORD wDispStyle);
void EnableAni(BOOL bEnable = TRUE);
BOOL IsAniValid() const;
Predefined animation style flags:
#define AS_REFER 0
#define AS_CENTER 1
#define AS_TOPLEFT 2
#define AS_TOPRIGHT 3
#define AS_BOTTOMLEFT 4
#define AS_BOTTOMRIGHT 5
#define AS_LEFT 6
#define AS_TOP 7
#define AS_RIGHT 8
#define AS_BOTTOM 9
#define AS_RANDOM 10
#define DS_WIRE 0
#define DS_CAPTION 1
How To Use
To use the
CAniDialog class, you need to:
- Add AniDialog.h and AniDialog.cpp into your project and
include AniDialog.h where needed.
- Use resource editor to create a new dialog, draw whatever controls on the dialog box as you
wish, then use class wizard to create a new class for it, for example, name the new
CMyDlg and let
CDialog be its base class.
- Go to MyDlg.h and use the Replace feature of your code editor to
CAniDialog in whole file.
- Go to MyDlg.cpp and use the "Replace" feature of your code editor to
CAniDialog in whole file. At this point you have changed the base
- Modify the constructor of
CMyDlg class so it looks like this:
CMyDlg(CPoint pt, CWnd* pParent = NULL);
And the body of the constructor becomes this:
CMyDlg::CMyDlg(CPoint pt, CWnd* pParent )
CAniDialog(pt, CMyDlg::IDD, pParent)
That's it! Now the
CMyDlg class is ready to go.
When you create a
CMyDlg object, you need to pass it a
object which tells the dialog where to pop up from and where to close towards.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.