123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- // MyDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "MyDlg.h"
- #include "YLGL.h"
- #include "MainFrimDlg2.h"
- HCURSOR g_cursorhand = NULL;
- /////////////////////////////////////////////////////////////////////////////
- // MyDlg dialog
- MyDlg::MyDlg(CWnd* pParent /*=NULL*/)
- : CDialog(MyDlg::IDD, pParent)
- {
- m_pBk = NULL;
- m_pParent = NULL;
- }
- MyDlg::MyDlg(DWORD id, CWnd* pParent)
- : CDialog(id, pParent)
- {
- 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)
- ON_WM_PAINT()
- ON_WM_DESTROY()
- ON_WM_ERASEBKGND()
- //}}AFX_MSG_MAP
- ON_MESSAGE(WM_USER + 1101, OnBtnClick)
- ON_MESSAGE(XTWM_OUTBAR_NOTIFY, OnOutbarNotify)
- 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_screenwid - g_fscalex*img->GetWidth()) / 2, (g_screenhei - g_fscaley*img->GetHeight()) / 2, g_fscalex*img->GetWidth(), g_fscaley*img->GetHeight(), SWP_SHOWWINDOW);
- }
- else
- SetWindowPos(hwnd, HWND_NOTOPMOST, (g_screenwid - g_fscalex*img->GetWidth()) / 2, (g_screenhei - g_fscaley*img->GetHeight()) / 2, g_fscalex*img->GetWidth(), g_fscaley*img->GetHeight(), NULL);
- }
- #ifdef VC60
- void MyDlg::OnOutbarNotify(WPARAM wParam, LPARAM lParam)
- {
- ((MainFrimDlg2*)this)->OnOutbarNotify(wParam, lParam);
- }
- void MyDlg::OnBtnClick(WPARAM wParam, LPARAM lParam)
- {
- BtnClick(wParam, lParam);
- }
- #else
- LRESULT MyDlg::OnOutbarNotify(WPARAM wParam, LPARAM lParam)
- {
- return ((MainFrimDlg2*)this)->OnOutbarNotify(wParam, lParam);
- }
- LRESULT MyDlg::OnBtnClick(WPARAM wParam, LPARAM lParam)
- {
- BtnClick(wParam, lParam);
- return 0;
- }
- #endif
- 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;
- CString path2 = g_mainpath + "\\skin\\" + m_liapath;
- BOOL bReadMain = 0;
- if ("10-red.lia" == m_liapath)
- bReadMain = 1;
- //AfxMessageBox(path2);
- if (PathFileExists(path2) == 0)
- {
- bReadMain = 0;
- path2.Replace("-red", "");
- }
- //path2 += "10.lia";
- if (!LoadLia(path2, &pData, &pDataBegin, &m_pBk, m_hWnd)) // Jeff:Óë·þÎñÆ÷ͨÐÅÁË£¡
- {
- EndDialog(0);
- return false;
- }
- for (int i = 0; i < g_resdata2.nPicCount; i++)
- {
- if (bReadMain && i == 15)
- {
- g_resdata2.rect[i].left += 2;
- g_resdata2.rect[i].right += 2;
- g_resdata2.rect[i].top += 5;
- g_resdata2.rect[i].bottom += 5;
- }
- 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 (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.SetSmoothingMode(SmoothingModeHighQuality);
- 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.SetSmoothingMode(SmoothingModeHighQuality);
- graph.DrawImage(m_pBk, destinationRect, 0, 0, width, height, UnitPixel);
- }
- catch (...)
- {
- }
- }
- void MyDlg::OnDestroy()
- {
- try
- {
- 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(); CDialog::OnDestroy();
- }
- 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)
- {
- if (g_bRedSkin)
- {
- path.MakeLower();
- if (path == "5.lia")
- path = "5-red.lia";
- else if (path == "10.lia")
- path = "10-red.lia";
- }
- m_liapath = path;
- }
- BOOL MyDlg::PreTranslateMessage(MSG* pMsg)
- {
- return PreTransMsg(pMsg);
- }
- 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);
- }
|