// MyDlg.cpp : implementation file // #include "stdafx.h" #include "MyDlg.h" #include "LYFZSendMsg.h" RESDATA2 g_resdata2; BOOL g_bAlphaWnd=0; HCURSOR g_cursorhand=NULL; ///////////////////////////////////////////////////////////////////////////// // MyDlg dialog MyDlg::MyDlg(CWnd* pParent /*=NULL*/) : CDialog(MyDlg::IDD, pParent) { //{{AFX_DATA_INIT(MyDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_pBk=NULL; m_pParent=NULL; } MyDlg::MyDlg(DWORD id, CWnd* pParent) : CDialog(id, pParent) { //{{AFX_DATA_INIT(MyDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_pBk=NULL; m_pParent=NULL; } void MyDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(MyDlg) //}}AFX_DATA_MAP} } BEGIN_MESSAGE_MAP(MyDlg, CDialog) //{{AFX_MSG_MAP(MyDlg) ON_WM_PAINT() ON_WM_DESTROY() ON_WM_ERASEBKGND() //}}AFX_MSG_MAP ON_MESSAGE(WM_USER+1101,OnBtnClick) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // MyDlg message handlers void SizeToContent(HWND hwnd, Image *img) { if(img==NULL)return; if(g_bAlphaWnd) { g_bAlphaWnd=0; SetWindowPos(hwnd, HWND_NOTOPMOST, (g_dm.dmPelsWidth-g_fscalex*img->GetWidth())/2, (g_dm.dmPelsHeight-g_fscaley*img->GetHeight())/2, g_fscalex*img->GetWidth(), g_fscaley*img->GetHeight(), SWP_SHOWWINDOW); } else SetWindowPos(hwnd, HWND_NOTOPMOST, (g_dm.dmPelsWidth-g_fscalex*img->GetWidth())/2, (g_dm.dmPelsHeight-g_fscaley*img->GetHeight())/2, g_fscalex*img->GetWidth(), g_fscaley*img->GetHeight(), NULL); } void MyDlg::OnBtnClick (WPARAM wParam, LPARAM lParam) { BtnClick(wParam, lParam); } BOOL MyDlg::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here if(g_cursorhand==NULL) g_cursorhand=AfxGetApp()->LoadCursor(IDC_CURSORHAND); BYTE *pData=NULL; BYTE *pDataBegin; if(!LoadLia(g_mainpath+"\\skin\\"+m_liapath, &pData, &pDataBegin, &m_pBk, m_hWnd)) { EndDialog(0); return false; } /* CFile fp; if(!fp.Open (g_mainpath+"\\skin\\"+m_liapath, CFile::modeRead)) { AfxMessageBox(_T("liaÎļþδÕÒµ½."), MB_ICONINFORMATION); EndDialog(0); return false; } DWORD count=fp.GetLength (); BYTE *pData=new BYTE[count]; BYTE *pDataBegin=pData; fp.Read (pData, count); fp.Close (); ///////////// CStringArray childarray; DWORD childlength; memcpy(&childlength, pData, sizeof(DWORD)); pData+=sizeof(DWORD); BYTE *pChildData=new BYTE[childlength]; memcpy(pChildData, pData, childlength); pData+=childlength; CMemFile memfile; memfile.Attach (pChildData,childlength); CArchive ar(&memfile, CArchive::load); childarray.Serialize (ar); ar.Close(); memfile.Detach (); delete []pChildData; ////////////////////// memcpy(&g_resdata2, pData, sizeof(RESDATA2)); pData+=sizeof(RESDATA2); if(g_resdata2.bHasBk ) { BYTE *m_pSaveBk=NULL; DWORD leng=0; MyBmpButton2::ReadBK(&pData, &m_pSaveBk, leng); LoadImageFromBuf(&m_pBk, m_pSaveBk, leng); SizeToContent(m_hWnd, m_pBk); if(m_pBk->GetWidth()==1024 && m_pBk->GetHeight()==768) ::SetWindowPos(m_hWnd,HWND_TOP,0 ,0,g_dm.dmPelsWidth,g_dm.dmPelsHeight,SWP_SHOWWINDOW); }*/ for(int i=0; iCreate(str, WS_CHILD|WS_VISIBLE|BS_OWNERDRAW , rc, this, i+100); pic->m_bmpcount =g_resdata2.nPicBmpCount [i]; pic->ReadBmp (&pData, NULL, this); } else m_picarray.Add (NULL); m_rcarray.Add(g_resdata2.rect[i]); } delete []pDataBegin; Init(); return false; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void MyDlg::OnPaint() { try { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here /* if(::FindParent (m_hWnd) ) { CRect rc; GetWindowRect (rc); GetParent()->ScreenToClient(rc); Graphics graph(dc.GetSafeHdc ()); Rect destinationRect(0,0,rc.Width (), rc.Height ()); graph.DrawImage(((MyDlg*)GetParent())->m_pBk, destinationRect, rc.left , rc.top ,rc.Width (), rc.Height (),UnitPixel); }*/ if(m_pBk==NULL) { return ; } CRect rc; GetClientRect(rc); Graphics graph(dc.GetSafeHdc ()); Rect destinationRect(0,0,rc.Width (), rc.Height ()); int width=m_pBk->GetWidth() ; int height=m_pBk->GetHeight() ; graph.DrawImage(m_pBk, destinationRect, 0,0,width,height,UnitPixel); // Do not call CDialog::OnPaint() for painting messages } catch(...) { } } void MyDlg::OnPaint2(CWnd *pWnd) { try { CPaintDC dc(pWnd); // device context for painting // TODO: Add your message handler code here CRect rc; GetClientRect(rc); if(m_pBk==NULL) { return ; } int width=m_pBk->GetWidth() ; int height=m_pBk->GetHeight() ; Graphics graph(dc.GetSafeHdc ()); Rect destinationRect(0,0,rc.Width (), rc.Height ()); graph.DrawImage(m_pBk, destinationRect, 0,0,width,height,UnitPixel); } catch(...) { } } void MyDlg::OnDestroy() { try { CDialog::OnDestroy(); if(m_pBk)delete m_pBk; MyBmpButton2 *pic=NULL; for(int i=0; iDestroyWindow(); delete pic; } } m_picarray.RemoveAll(); Destory(); } catch(...) { } } BOOL MyDlg::OnEraseBkgnd(CDC* pDC) { // TODO: Add your message handler code here and/or call default return 1; } void MyDlg::OnOK() { // TODO: Add extra validation here } void MyDlg::OnCancel() { // TODO: Add extra cleanup here CDialog::OnCancel(); } void MyDlg::SetLiaPath(CString path) { m_liapath=path; } BOOL MyDlg::PreTranslateMessage(MSG* pMsg) { return PreTransMsg(pMsg); // return CDialog::PreTranslateMessage(pMsg); return 1; } BEGIN_EVENTSINK_MAP(MyDlg, CDialog) //{{AFX_EVENTSINK_MAP(MyDlg) ON_EVENT(MyDlg, 100, 150 /* FSCommand */, OnFSCommandShockwaveflash1, VTS_BSTR VTS_BSTR) //}}AFX_EVENTSINK_MAP END_EVENTSINK_MAP() void MyDlg::OnFSCommandShockwaveflash1(LPCTSTR command, LPCTSTR args) { // TODO: Add your control notification handler code here OnFSCommand( command, args); }