MyDlg.cpp 5.6 KB

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