MyDlg.cpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. // MyDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "MyDlg.h"
  5. #include "YLGL.h"
  6. #include "MainFrimDlg2.h"
  7. HCURSOR g_cursorhand = NULL;
  8. /////////////////////////////////////////////////////////////////////////////
  9. // MyDlg dialog
  10. MyDlg::MyDlg(CWnd* pParent /*=NULL*/)
  11. : CDialog(MyDlg::IDD, pParent)
  12. {
  13. m_pBk = NULL;
  14. m_pParent = NULL;
  15. }
  16. MyDlg::MyDlg(DWORD id, CWnd* pParent)
  17. : CDialog(id, pParent)
  18. {
  19. m_pBk = NULL;
  20. m_pParent = NULL;
  21. }
  22. void MyDlg::DoDataExchange(CDataExchange* pDX)
  23. {
  24. CDialog::DoDataExchange(pDX);
  25. //{{AFX_DATA_MAP(MyDlg)
  26. //}}AFX_DATA_MAP}
  27. }
  28. BEGIN_MESSAGE_MAP(MyDlg, CDialog)
  29. ON_WM_PAINT()
  30. ON_WM_DESTROY()
  31. ON_WM_ERASEBKGND()
  32. //}}AFX_MSG_MAP
  33. ON_MESSAGE(WM_USER + 1101, OnBtnClick)
  34. ON_MESSAGE(XTWM_OUTBAR_NOTIFY, OnOutbarNotify)
  35. END_MESSAGE_MAP()
  36. /////////////////////////////////////////////////////////////////////////////
  37. // MyDlg message handlers
  38. void SizeToContent(HWND hwnd, Image *img)
  39. {
  40. if (img == NULL)return;
  41. if (g_bAlphaWnd)
  42. {
  43. g_bAlphaWnd = 0;
  44. 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);
  45. }
  46. else
  47. 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);
  48. }
  49. #ifdef VC60
  50. void MyDlg::OnOutbarNotify(WPARAM wParam, LPARAM lParam)
  51. {
  52. ((MainFrimDlg2*)this)->OnOutbarNotify(wParam, lParam);
  53. }
  54. void MyDlg::OnBtnClick(WPARAM wParam, LPARAM lParam)
  55. {
  56. BtnClick(wParam, lParam);
  57. }
  58. #else
  59. LRESULT MyDlg::OnOutbarNotify(WPARAM wParam, LPARAM lParam)
  60. {
  61. return ((MainFrimDlg2*)this)->OnOutbarNotify(wParam, lParam);
  62. }
  63. LRESULT MyDlg::OnBtnClick(WPARAM wParam, LPARAM lParam)
  64. {
  65. BtnClick(wParam, lParam);
  66. return 0;
  67. }
  68. #endif
  69. BOOL MyDlg::OnInitDialog()
  70. {
  71. CDialog::OnInitDialog();
  72. // TODO: Add extra initialization here
  73. if (g_cursorhand == NULL)
  74. g_cursorhand = AfxGetApp()->LoadCursor(IDC_CURSORHAND);
  75. BYTE *pData = NULL;
  76. BYTE *pDataBegin;
  77. CString path2 = g_mainpath + "\\skin\\" + m_liapath;
  78. BOOL bReadMain = 0;
  79. if ("10-red.lia" == m_liapath)
  80. bReadMain = 1;
  81. //AfxMessageBox(path2);
  82. if (PathFileExists(path2) == 0)
  83. {
  84. bReadMain = 0;
  85. path2.Replace("-red", "");
  86. }
  87. //path2 += "10.lia";
  88. if (!LoadLia(path2, &pData, &pDataBegin, &m_pBk, m_hWnd)) // Jeff:Óë·þÎñÆ÷ͨÐÅÁË£¡
  89. {
  90. EndDialog(0);
  91. return false;
  92. }
  93. for (int i = 0; i < g_resdata2.nPicCount; i++)
  94. {
  95. if (bReadMain && i == 15)
  96. {
  97. g_resdata2.rect[i].left += 2;
  98. g_resdata2.rect[i].right += 2;
  99. g_resdata2.rect[i].top += 5;
  100. g_resdata2.rect[i].bottom += 5;
  101. }
  102. g_resdata2.rect[i].left *= g_fscalex;
  103. g_resdata2.rect[i].right *= g_fscalex;
  104. g_resdata2.rect[i].top *= g_fscaley;
  105. g_resdata2.rect[i].bottom *= g_fscaley;
  106. if (g_resdata2.nPicBmpCount[i])
  107. {
  108. MyBmpButton2 *pic = new MyBmpButton2;
  109. m_picarray.Add((DWORD)pic);
  110. CRect rc = g_resdata2.rect[i];
  111. CString str;
  112. str.Format(_T("%d"), i + 1);
  113. pic->Create(str, WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, rc, this, i + 100);
  114. pic->m_bmpcount = g_resdata2.nPicBmpCount[i];
  115. pic->ReadBmp(&pData, NULL, this);
  116. }
  117. else
  118. m_picarray.Add(NULL);
  119. m_rcarray.Add(g_resdata2.rect[i]);
  120. }
  121. delete[]pDataBegin;
  122. Init();
  123. return false; // return TRUE unless you set the focus to a control
  124. // EXCEPTION: OCX Property Pages should return FALSE
  125. }
  126. void MyDlg::OnPaint()
  127. {
  128. try
  129. {
  130. CPaintDC dc(this); // device context for painting
  131. // TODO: Add your message handler code here
  132. if (m_pBk == NULL)
  133. {
  134. return;
  135. }
  136. CRect rc;
  137. GetClientRect(rc);
  138. Graphics graph(dc.GetSafeHdc());
  139. Rect destinationRect(0, 0, rc.Width(), rc.Height());
  140. int width = m_pBk->GetWidth();
  141. int height = m_pBk->GetHeight();
  142. graph.SetSmoothingMode(SmoothingModeHighQuality);
  143. graph.DrawImage(m_pBk, destinationRect, 0, 0, width, height, UnitPixel);
  144. // Do not call CDialog::OnPaint() for painting messages
  145. }
  146. catch (...)
  147. {
  148. }
  149. }
  150. void MyDlg::OnPaint2(CWnd *pWnd)
  151. {
  152. try
  153. {
  154. CPaintDC dc(pWnd); // device context for painting
  155. // TODO: Add your message handler code here
  156. CRect rc;
  157. GetClientRect(rc);
  158. if (m_pBk == NULL)
  159. {
  160. return;
  161. }
  162. int width = m_pBk->GetWidth();
  163. int height = m_pBk->GetHeight();
  164. Graphics graph(dc.GetSafeHdc());
  165. Rect destinationRect(0, 0, rc.Width(), rc.Height());
  166. graph.SetSmoothingMode(SmoothingModeHighQuality);
  167. graph.DrawImage(m_pBk, destinationRect, 0, 0, width, height, UnitPixel);
  168. }
  169. catch (...)
  170. {
  171. }
  172. }
  173. void MyDlg::OnDestroy()
  174. {
  175. try
  176. {
  177. if (m_pBk)delete m_pBk;
  178. MyBmpButton2 *pic = NULL;
  179. for (int i = 0; i < m_picarray.GetSize(); i++)
  180. {
  181. pic = (MyBmpButton2*)m_picarray.ElementAt(i);
  182. if (pic)
  183. {
  184. pic->DestroyWindow();
  185. delete pic;
  186. }
  187. }
  188. m_picarray.RemoveAll();
  189. Destory(); CDialog::OnDestroy();
  190. }
  191. catch (...)
  192. {
  193. }
  194. }
  195. BOOL MyDlg::OnEraseBkgnd(CDC* pDC)
  196. {
  197. // TODO: Add your message handler code here and/or call default
  198. return 1;
  199. }
  200. void MyDlg::OnOK()
  201. {
  202. // TODO: Add extra validation here
  203. }
  204. void MyDlg::OnCancel()
  205. {
  206. // TODO: Add extra cleanup here
  207. CDialog::OnCancel();
  208. }
  209. void MyDlg::SetLiaPath(CString path)
  210. {
  211. if (g_bRedSkin)
  212. {
  213. path.MakeLower();
  214. if (path == "5.lia")
  215. path = "5-red.lia";
  216. else if (path == "10.lia")
  217. path = "10-red.lia";
  218. }
  219. m_liapath = path;
  220. }
  221. BOOL MyDlg::PreTranslateMessage(MSG* pMsg)
  222. {
  223. return PreTransMsg(pMsg);
  224. }
  225. BEGIN_EVENTSINK_MAP(MyDlg, CDialog)
  226. //{{AFX_EVENTSINK_MAP(MyDlg)
  227. ON_EVENT(MyDlg, 100, 150 /* FSCommand */, OnFSCommandShockwaveflash1, VTS_BSTR VTS_BSTR)
  228. //}}AFX_EVENTSINK_MAP
  229. END_EVENTSINK_MAP()
  230. void MyDlg::OnFSCommandShockwaveflash1(LPCTSTR command, LPCTSTR args)
  231. {
  232. // TODO: Add your control notification handler code here
  233. OnFSCommand(command, args);
  234. }