123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- // 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; i<g_resdata2.nPicCount; i++)
- {
- g_resdata2.rect[i].left *=g_fscalex;
- g_resdata2.rect[i].right *=g_fscalex;
- g_resdata2.rect[i].top *=g_fscaley;
- g_resdata2.rect[i].bottom *=g_fscaley;
- 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);
- }
- 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; i<m_picarray.GetSize(); i++)
- {
- pic=(MyBmpButton2*)m_picarray.ElementAt(i);
- if(pic)
- {
- pic->DestroyWindow();
- 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);
- }
|