// LoadRect.cpp : implementation file // #include "stdafx.h" #include "LoadRect.h" #include "LYFZIPManage.h" extern RESDATA2 g_resdata2; extern BOOL g_bAlphaWnd; ///////////////////////////////////////////////////////////////////////////// // LoadRect dialog LoadRect::LoadRect(CWnd* pParent /*=NULL*/) : CDialog(LoadRect::IDD, pParent) { //{{AFX_DATA_INIT(LoadRect) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_pBk=NULL; m_pParent=NULL; m_dtx=0; m_dty=0; } LoadRect::LoadRect(DWORD id, CWnd* pParent) : CDialog(id, pParent) { //{{AFX_DATA_INIT(LoadRect) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_pBk=NULL; m_pParent=NULL; m_dtx=0; m_dty=0; } void LoadRect::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(LoadRect) //}}AFX_DATA_MAP} } BEGIN_MESSAGE_MAP(LoadRect, CDialog) //{{AFX_MSG_MAP(LoadRect) ON_WM_PAINT() ON_WM_DESTROY() ON_WM_ERASEBKGND() //}}AFX_MSG_MAP ON_MESSAGE(WM_USER+1101,OnBtnClick) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // LoadRect message handlers extern void SizeToContent(HWND hwnd, Image *img); void LoadRect::OnBtnClick (WPARAM wParam, LPARAM lParam) { } BOOL LoadRect::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here return false; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void LoadRect::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(((LoadRect*)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 LoadRect::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 LoadRect::OnDestroy() { try { CDialog::OnDestroy(); if(m_pBk)delete m_pBk; MyBmpButton2 *pic=NULL; for(int i=0; iDestroyWindow(); delete pic; } } m_picarray.RemoveAll(); } catch(...) { } } BOOL LoadRect::OnEraseBkgnd(CDC* pDC) { // TODO: Add your message handler code here and/or call default return 1; } void LoadRect::OnOK() { // TODO: Add extra validation here } void LoadRect::OnCancel() { // TODO: Add extra cleanup here CDialog::OnCancel(); } void LoadRect::SetLiaPath(CString path) { m_liapath=path; } BOOL LoadRect::PreTranslateMessage(MSG* pMsg) { return CDialog::PreTranslateMessage(pMsg); return 1; } BEGIN_EVENTSINK_MAP(LoadRect, CDialog) //{{AFX_EVENTSINK_MAP(LoadRect) ON_EVENT(LoadRect, 100, 150 /* FSCommand */, OnFSCommandShockwaveflash1, VTS_BSTR VTS_BSTR) //}}AFX_EVENTSINK_MAP END_EVENTSINK_MAP() void LoadRect::OnFSCommandShockwaveflash1(LPCTSTR command, LPCTSTR args) { // TODO: Add your control notification handler code here } BOOL LoadRect::Load() { HGLOBAL hGlobal = NULL; HRSRC hSource = NULL; LPVOID lpVoid = NULL; int nSize = 0; BOOL bResult=FALSE; if(m_liapath=="4.lia") hSource = FindResource(NULL, MAKEINTRESOURCE(IDR_LIA1), "LIA"); else if(m_liapath=="5.lia") hSource = FindResource(NULL, MAKEINTRESOURCE(IDR_LIA2), "LIA"); else if(m_liapath=="6.lia") hSource = FindResource(NULL, MAKEINTRESOURCE(IDR_LIA3), "LIA"); else if(m_liapath=="7.lia") hSource = FindResource(NULL, MAKEINTRESOURCE(IDR_LIA4), "LIA"); else if(m_liapath=="8.lia") hSource = FindResource(NULL, MAKEINTRESOURCE(IDR_LIA5), "LIA"); else if(m_liapath=="9.lia") hSource = FindResource(NULL, MAKEINTRESOURCE(IDR_LIA6), "LIA"); else return 0; if(hSource == NULL)return 0; hGlobal = LoadResource(NULL, hSource); if(hGlobal == NULL)return 0; lpVoid = LockResource(hGlobal); if(lpVoid == NULL)return 0; nSize = (UINT)SizeofResource(NULL, hSource); BYTE *pData=new BYTE[nSize]; memcpy(pData, (BYTE*)hGlobal, nSize); UnlockResource(hGlobal); // 16Bit Windows Needs This FreeResource(hGlobal); // 16Bit Windows Needs This (32Bit - Automatic Release) BYTE *pDataBegin=pData; ///////////// 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); } 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); pic->m_childpath =childarray.ElementAt (i); } else m_picarray.Add (NULL); g_resdata2.rect[i].left +=m_dtx; g_resdata2.rect[i].right +=m_dtx; g_resdata2.rect[i].top +=m_dty; g_resdata2.rect[i].bottom +=m_dty; m_rcarray.Add(g_resdata2.rect[i]); } delete []pDataBegin; return 1; } void LoadRect::SetMargins(int dtx, int dty) { m_dtx=dtx; m_dty=dty; }