MyDlg.cpp 5.3 KB

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