// CrtAnim.cpp : implementation file // #include "stdafx.h" #include "demo.h" #include "CrtAnim.h" #include "ChildFrm.h" #include "DemoDoc.h" #include "DemoView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CCreateAnimation dialog CCreateAnimation::CCreateAnimation(CWnd* pParent /*=NULL*/) : CDialog(CCreateAnimation::IDD, pParent) { //{{AFX_DATA_INIT(CCreateAnimation) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } void CCreateAnimation::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CCreateAnimation) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CCreateAnimation, CDialog) //{{AFX_MSG_MAP(CCreateAnimation) ON_LBN_SELCHANGE(IDC_ANIMATIONSOURCELIST, OnSelchangeAnimationsourcelist) ON_BN_CLICKED(IDC_ANIMATIONADD, OnAnimationadd) ON_BN_CLICKED(IDC_ANIMATIONSUB, OnAnimationsub) ON_LBN_SELCHANGE(IDC_ANIMATIONPLAYLIST, OnSelchangeAnimationplaylist) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CCreateAnimation message handlers L_VOID CCreateAnimation::ChangeFont (HWND hWnd) { HFONT hFont ; LOGFONT LogFont ; HDC hDC ; hDC = ::GetDC ( NULL ) ; //create the default font LogFont.lfHeight = -MulDiv ( 8, GetDeviceCaps ( hDC, LOGPIXELSY ), 72 ) ; ::ReleaseDC ( NULL, hDC ) ; LogFont.lfWidth = 0 ; LogFont.lfEscapement = 0 ; LogFont.lfOrientation = 0 ; LogFont.lfWeight = FW_NORMAL ; LogFont.lfItalic = FALSE ; LogFont.lfUnderline = FALSE ; LogFont.lfStrikeOut = FALSE ; LogFont.lfCharSet = DEFAULT_CHARSET ; LogFont.lfOutPrecision = OUT_STROKE_PRECIS ; LogFont.lfClipPrecision = CLIP_STROKE_PRECIS ; LogFont.lfQuality = DRAFT_QUALITY ; LogFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE ; lstrcpy ( LogFont.lfFaceName, TEXT ( "MS Shell Dlg" ) ) ; hFont = CreateFontIndirect ( &LogFont ) ; ::SendMessage ( hWnd, WM_SETFONT, ( WPARAM ) hFont, ( LPARAM ) 1 ) ; } BOOL CCreateAnimation::OnInitDialog() { CDialog::OnInitDialog(); #ifdef UNICODE ChangeFont (m_hWnd); #endif // TODO: Add extra initialization here CMDIFrameWnd * pWnd = (CMDIFrameWnd *)AfxGetMainWnd(); CWnd * pChild = pWnd->MDIGetActive(); CListBox * pList = (CListBox *) GetDlgItem(IDC_ANIMATIONSOURCELIST); int nIndex; while (pChild) { if (pChild->IsKindOf(RUNTIME_CLASS(CChildFrame))) { CString cstrTitle; pChild->GetWindowText(cstrTitle); nIndex = pList->AddString(cstrTitle); if (nIndex ==LB_ERR) return TRUE; pList->SetItemData(nIndex,(LONG) pChild); } pChild = pChild->GetWindow(GW_HWNDNEXT); } if (pList->GetCount()) { pList->SetSel(0); GetDlgItem(IDC_ANIMATIONADD)->EnableWindow(TRUE); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CCreateAnimation::OnSelchangeAnimationsourcelist() { // TODO: Add your control notification handler code here CListBox * pList = (CListBox *) GetDlgItem(IDC_ANIMATIONSOURCELIST); GetDlgItem(IDC_ANIMATIONADD)->EnableWindow(pList->GetSelCount()); } void CCreateAnimation::OnAnimationadd() { // TODO: Add your control notification handler code here int i, nIndex; CString cstrTitle; CListBox * pSrcList = (CListBox *) GetDlgItem(IDC_ANIMATIONSOURCELIST); CListBox * pDestList = (CListBox *) GetDlgItem(IDC_ANIMATIONPLAYLIST); for (i=0; iGetCount(); i++) { if (pSrcList->GetSel(i)) { pSrcList->GetText(i, cstrTitle); nIndex = pDestList->AddString(cstrTitle); pDestList->SetItemData(nIndex, pSrcList->GetItemData(i)); } } GetDlgItem(IDOK)->EnableWindow(pDestList->GetCount()>1); } void CCreateAnimation::OnAnimationsub() { // TODO: Add your control notification handler code here int i=0, nCount; CString cstrTitle; CListBox * pDestList = (CListBox *) GetDlgItem(IDC_ANIMATIONPLAYLIST); nCount = pDestList->GetCount(); while (iGetSel(i)) { nCount = pDestList->DeleteString(i); } else ++i; } GetDlgItem(IDOK)->EnableWindow(pDestList->GetCount()>1); } void CCreateAnimation::OnSelchangeAnimationplaylist() { // TODO: Add your control notification handler code here CListBox * pList = (CListBox *) GetDlgItem(IDC_ANIMATIONPLAYLIST); GetDlgItem(IDC_ANIMATIONSUB)->EnableWindow(pList->GetSelCount()); } void CCreateAnimation::OnOK() { // TODO: Add extra validation here int i; CChildFrame * pChild; CWnd * pWnd; CListBox * pDestList = (CListBox *) GetDlgItem(IDC_ANIMATIONPLAYLIST); m_BitmapList.Create(); for (i=0; iGetCount(); i++) { pChild = (CChildFrame * ) pDestList->GetItemData(i); pWnd = pChild->GetWindow(GW_CHILD); if (pWnd->IsKindOf(RUNTIME_CLASS(CDemoView))) { CDemoView * pView = (CDemoView * )pWnd; LBitmapBase Bitmap; Bitmap = pView->m_LAniWnd; m_BitmapList.InsertItem(&Bitmap, i); } } m_BitmapList.SetCurrentIndex(0); CDialog::OnOK(); }