MyDlg.cpp 5.5 KB

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