123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- // 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; i<m_picarray.GetSize(); i++)
- {
- pic=(MyBmpButton2*)m_picarray.ElementAt(i);
- if(pic)
- {
- pic->DestroyWindow();
- 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; i<g_resdata2.nPicCount; i++)
- {
-
- if(g_resdata2.nPicBmpCount [i])
- {
- MyBmpButton2 *pic=new MyBmpButton2;
- m_picarray.Add((DWORD)pic);
- CRect rc=g_resdata2.rect[i];
- CString str;
- str.Format (_T("%d"), i+1);
- pic->Create(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;
- }
|