|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionI've been using Almond and Maunder's
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 The CAniDialog class
First of all, the heart and soul of this class is the
The Public Methods of the CAniDialog class// construction CAniDialog(UINT nDlgID, CWnd* pParent); CAniDialog(CPoint pt, UINT nDlgID, CWnd* pParent); // operation // access frame number UINT GetFrameNum() const; void SetFrameNum(UINT nFrames); // access animation speed UINT GetAniSpeed() const; void SetAniSpeed(UINT nMillSec); // access the reference point CPoint GetRefPt() const; void SetRefPt(CPoint pt); // access animation styles WORD GetOpenStyle() const; WORD GetCloseStyle() const; void SetAniStyles(WORD wOpenStyle, WORD wCloseStyle); WORD GetDispStyle() const; void SetDispStyle(WORD wDispStyle); // temporarily enable/disable animation void EnableAni(BOOL bEnable = TRUE); // check object status BOOL IsAniValid() const; Animation StylesPredefined animation style flags: // animation styles // animate from/to the refer point #define AS_REFER 0 // animate from/to center #define AS_CENTER 1 // animate from/to corners #define AS_TOPLEFT 2 #define AS_TOPRIGHT 3 #define AS_BOTTOMLEFT 4 #define AS_BOTTOMRIGHT 5 // animate from/to sides #define AS_LEFT 6 #define AS_TOP 7 #define AS_RIGHT 8 #define AS_BOTTOM 9 // animate from/to a random point inside of dialog #define AS_RANDOM 10 // define displaying style // call "DrawWireRects" #define DS_WIRE 0 // call "::DrawAnimatedRects" #define DS_CAPTION 1 How To Use
To use the
// CMyDlg(CWnd* pParent = NULL); // original CMyDlg(CPoint pt, CWnd* pParent = NULL); // now CMyDlg::CMyDlg(CPoint pt, CWnd* pParent /*=NULL*/) : // CDialog(CMyDlg::IDD, pParent) // original CAniDialog(pt, CMyDlg::IDD, pParent) // now { //{{AFX_DATA_INIT(CDemoPopupDlg) // NOTE: the ClassWizard will add // member initialization here //}}AFX_DATA_INIT }
That's it! Now the // If you are going to use the AS_REFER flag, // you must provide a valid CPoint. // If you are not going to use the AS_REFER flag, // then the value of this CPoint // does not matter at all, in that case, // just give it one so the compiler won't // complain. CPoint pt; // we are going to use the AS_REFER flag so // we need a valid CPoint value. ::GetCursorPos(&pt); // fetch current cursor position CMyDlg dlg(pt); // optional // you can specify animation styles, displaying // styles, animation speed, animation // frame numbers etc. // the dialog will pop up from you cursor dlg.SetAniStyles(AS_REFER, AS_CENTER); // position and close inwards its own center dlg.DoModal(); // watch the animation!
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||