PreviewDlg.cpp 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. // PreviewDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "PreviewDlg.h"
  6. #include "ShowPic22.h"
  7. #ifdef _DEBUG
  8. //#define new DEBUG_NEW //wangwenbin modify 2014-04-27
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. extern Bitmap *g_pImgStaBuf;
  13. /////////////////////////////////////////////////////////////////////////////
  14. // PreviewDlg dialog
  15. PreviewDlg::PreviewDlg(CWnd* pParent /*=NULL*/)
  16. : CDialog(PreviewDlg::IDD, pParent)
  17. {
  18. //{{AFX_DATA_INIT(PreviewDlg)
  19. // NOTE: the ClassWizard will add member initialization here
  20. g_pBlackBrush=new SolidBrush(Color(255,0,0,0));
  21. g_pRedBrush=new SolidBrush(Color(255,255,0,0));
  22. m_bMin=1;
  23. m_pos=0;
  24. m_npages=0;
  25. m_ncurpage=0;
  26. //}}AFX_DATA_INIT
  27. }
  28. void PreviewDlg::DoDataExchange(CDataExchange* pDX)
  29. {
  30. CDialog::DoDataExchange(pDX);
  31. //{{AFX_DATA_MAP(PreviewDlg)
  32. // NOTE: the ClassWizard will add DDX and DDV calls here
  33. //}}AFX_DATA_MAP
  34. }
  35. BEGIN_MESSAGE_MAP(PreviewDlg, CDialog)
  36. //{{AFX_MSG_MAP(PreviewDlg)
  37. ON_WM_DESTROY()
  38. ON_WM_ERASEBKGND()
  39. ON_WM_LBUTTONDOWN()
  40. //}}AFX_MSG_MAP
  41. END_MESSAGE_MAP()
  42. /////////////////////////////////////////////////////////////////////////////
  43. // PreviewDlg message handlers ON_WM_PAINT()
  44. BOOL PreviewDlg::OnEraseBkgnd(CDC* pDC)
  45. {
  46. // TODO: Add your message handler code here and/or call default
  47. CRect rc;
  48. GetClientRect (rc);
  49. pDC->FillSolidRect (rc, RGB(0,0,0));
  50. return 1;
  51. }
  52. BOOL PreviewDlg::OnInitDialog()
  53. {
  54. CDialog::OnInitDialog();
  55. // TODO: Add extra initialization here
  56. // m_patharray.Copy(*m_pPathArray);
  57. return TRUE; // return TRUE unless you set the focus to a control
  58. // EXCEPTION: OCX Property Pages should return FALSE
  59. }
  60. void PreviewDlg::InitCtrl()
  61. {
  62. CString path,path2,str;
  63. int pos;
  64. for(int i=0; i<m_pPathArray->GetSize (); i++)
  65. {
  66. path=m_pPathArray->ElementAt(i);
  67. pos=path.ReverseFind('\\');
  68. str=path.Right(path.GetLength()-pos-1);
  69. str.TrimLeft("m");
  70. m_patharray.Add(path.Left(pos)+"\\s"+str);
  71. }
  72. m_pPathArray=&m_patharray;
  73. if(m_pPathArray->GetSize ()%7==0)
  74. m_npages=m_pPathArray->GetSize ()/7;
  75. else
  76. m_npages=m_pPathArray->GetSize ()/7+1;
  77. CRect rc;
  78. GetWindowRect(rc);
  79. int wid=rc.Width ();
  80. int hei=rc.Height ();
  81. CRect rc2;
  82. rc2.left =25;
  83. rc2.right =wid-5;
  84. rc2.top =30;
  85. int pichei=(hei-6*5-rc2.top*2)/7;
  86. int dt=pichei+5;
  87. rc2.bottom =rc2.top +pichei;
  88. for( i=0; i<7; i++)
  89. {
  90. m_picctrl[i].Create(_T(""), WS_VISIBLE|WS_CHILD|SS_BITMAP, rc2, this);
  91. rc2.top +=dt;
  92. rc2.bottom +=dt;
  93. /* if(m_pPathArray->GetSize()>i)
  94. {
  95. path=m_pPathArray->ElementAt(i);
  96. m_picctrl[i].SetPicPath(path);
  97. }*/
  98. }
  99. rc.left=10;
  100. rc.right=rc.left+10;
  101. rc.top=10;
  102. rc.bottom=25;
  103. m_link1.Create ("¡Ä", WS_CHILD|WS_VISIBLE, rc, this, 100);//¡Å
  104. m_link1.PositionWindow();
  105. m_link1.GetWindowRect (rc);ScreenToClient(rc);
  106. dt=wid/2-rc.left-rc.Width()/2+10;
  107. rc.left +=dt;
  108. rc.right +=dt;
  109. m_link1.MoveWindow(rc);
  110. rc.bottom=hei-5;
  111. rc.top=hei-25;
  112. m_link2.Create ("¡Å", WS_CHILD|WS_VISIBLE, rc, this, 100);
  113. m_link2.PositionWindow();
  114. ////////////////
  115. rc.left=5;
  116. rc.right=rc.left+10;
  117. rc.top=0;
  118. rc.bottom=hei;
  119. m_link3.Create ("£¼", WS_CHILD|WS_VISIBLE, rc, this, 100);//£¾
  120. m_link3.PositionWindow();
  121. m_link3.GetWindowRect (rc);ScreenToClient(rc);
  122. dt=hei/2-rc.top-rc.Height()/2;
  123. rc.top +=dt;
  124. rc.bottom +=dt;
  125. m_link3.MoveWindow(rc);
  126. m_link1.m_bBlackBk=1;
  127. m_link2.m_bBlackBk=1;
  128. m_link3.m_bBlackBk=1;
  129. //////////////////////////////////////////////////////////
  130. // CRect rc;
  131. GetClientRect(rc);
  132. CRgn rgn1, rgn2, rgn3;
  133. rgn1.CreateRectRgn (0,0, rc.Width (), rc.Height ());
  134. // rgn2.CreateRectRgn (0,0, 10, 10);
  135. // rgn3. CreateEllipticRgn(0,0,20,20);
  136. // rgn2.CombineRgn (&rgn2, &rgn3, RGN_DIFF);
  137. m_link1.GetWindowRect (rc);
  138. ScreenToClient(rc);
  139. rgn2.CreateRectRgn (rc.left,rc.top, rc.right, rc.bottom);
  140. rgn1.CombineRgn (&rgn1, &rgn2, RGN_DIFF);
  141. rgn2.DeleteObject ();
  142. m_link2.GetWindowRect (rc);
  143. ScreenToClient(rc);
  144. rgn2.CreateRectRgn (rc.left,rc.top, rc.right, rc.bottom);
  145. rgn1.CombineRgn (&rgn1, &rgn2, RGN_DIFF);
  146. rgn2.DeleteObject ();
  147. m_link3.GetWindowRect (rc);
  148. ScreenToClient(rc);
  149. rgn2.CreateRectRgn (rc.left,rc.top, rc.right, rc.bottom);
  150. rgn1.CombineRgn (&rgn1, &rgn2, RGN_DIFF);
  151. rgn2.DeleteObject ();
  152. for( i=0; i<7; i++)
  153. {
  154. m_picctrl[i].GetWindowRect (rc);
  155. ScreenToClient(rc);
  156. rgn2.CreateRectRgn (rc.left,rc.top, rc.right, rc.bottom);
  157. rgn1.CombineRgn (&rgn1, &rgn2, RGN_DIFF);
  158. rgn2.DeleteObject ();
  159. }
  160. GetClientRect(rc);
  161. rgn2.CreateRectRgn (0,0, rc.Width (), rc.Height ());
  162. rgn2.CombineRgn (&rgn2, &rgn1, RGN_DIFF);
  163. rgn1.DeleteObject ();
  164. ::SetWindowRgn (m_hWnd, rgn2, 0);
  165. }
  166. void PreviewDlg::OnDestroy()
  167. {
  168. CDialog::OnDestroy();
  169. // TODO: Add your message handler code here
  170. delete g_pBlackBrush;
  171. delete g_pRedBrush;
  172. if(g_pImgStaBuf)delete g_pImgStaBuf;g_pImgStaBuf=NULL;
  173. }
  174. void PreviewDlg::ShowMin()
  175. {
  176. m_bMin=1;
  177. m_link3.SetWindowText ("£¼");
  178. CRect rc;
  179. rc.top =50;
  180. rc.bottom =g_screenhei-50;
  181. rc.right =g_screenwid-10;
  182. rc.left =rc.right -100;
  183. ///////////////////////////
  184. rc.left=g_screenwid-20;
  185. rc.right=rc.left+100;
  186. ///////////////////////////
  187. MoveWindow (rc);
  188. }
  189. void PreviewDlg::ShowNormal()
  190. {
  191. if(((ShowPic22*)GetParent())->m_bauto)
  192. {
  193. return;
  194. }
  195. m_bMin=0;
  196. m_link3.SetWindowText ("£¾");
  197. CRect rc;
  198. rc.top =50;
  199. rc.bottom =g_screenhei-50;
  200. rc.right =g_screenwid-10;
  201. rc.left =rc.right -100;
  202. ///////////////////////////
  203. // rc.left=g_screenwid-20;
  204. // rc.right=rc.left+100;
  205. ///////////////////////////
  206. MoveWindow (rc);
  207. ShowPic(((ShowPic22*)GetParent())->m_pos);
  208. }
  209. void PreviewDlg::LinkClick(CString str)
  210. {
  211. if(str=="£¼")
  212. {
  213. ShowNormal();
  214. }
  215. else if(str=="£¾")
  216. {
  217. ShowMin();
  218. }
  219. else if(str=="¡Ä")
  220. {
  221. PrePage();
  222. }
  223. else if(str=="¡Å")
  224. {
  225. NextPage();
  226. }
  227. }
  228. void PreviewDlg::ShowPic(int pos)
  229. {
  230. if(m_bMin)return;
  231. CString path;
  232. m_pos=pos;
  233. m_ncurpage=pos/7;
  234. for(int i=0; i<7; i++)
  235. {
  236. if(m_pos%7==i)
  237. {
  238. m_picctrl[i].m_nFrameMode=100;
  239. }
  240. else
  241. m_picctrl[i].m_nFrameMode=0;
  242. pos=m_ncurpage*7+i;
  243. if(m_pPathArray->GetSize()>pos)
  244. {
  245. path=m_pPathArray->ElementAt(pos);
  246. m_picctrl[i].SetPicPath(path);
  247. }
  248. else
  249. m_picctrl[i].SetPicPath("");
  250. }
  251. }
  252. void PreviewDlg::ShowPic2()
  253. {
  254. CString path;
  255. m_pos=m_ncurpage*7;
  256. for(int i=0; i<7; i++)
  257. {
  258. if(m_pos%7==i)
  259. {
  260. m_picctrl[i].m_nFrameMode=100;
  261. }
  262. else
  263. m_picctrl[i].m_nFrameMode=0;
  264. int pos=m_ncurpage*7+i;
  265. if(m_pPathArray->GetSize()>pos)
  266. {
  267. path=m_pPathArray->ElementAt(pos);
  268. m_picctrl[i].SetPicPath(path);
  269. }
  270. else
  271. m_picctrl[i].SetPicPath("");
  272. }
  273. }
  274. void PreviewDlg::PrePage()
  275. {
  276. try
  277. {
  278. if(m_ncurpage==0)
  279. m_ncurpage=m_npages-1;
  280. else
  281. m_ncurpage--;
  282. ShowPic2();
  283. }
  284. catch(...)
  285. {
  286. }
  287. }
  288. void PreviewDlg::NextPage()
  289. {
  290. try
  291. {
  292. if(m_ncurpage==m_npages-1)
  293. m_ncurpage=0;
  294. else
  295. m_ncurpage++;
  296. ShowPic2();
  297. }
  298. catch(...)
  299. {
  300. }
  301. }
  302. void PreviewDlg::OnLButtonDown(UINT nFlags, CPoint point)
  303. {
  304. // TODO: Add your message handler code here and/or call default
  305. CRect rc;
  306. for(int i=0; i<7; i++)
  307. {
  308. m_picctrl[i].GetWindowRect(rc);
  309. ScreenToClient(rc);
  310. if(rc.PtInRect (point))
  311. {
  312. int pos=m_ncurpage*7+i;
  313. if(m_pPathArray->GetSize()>pos)
  314. {
  315. // ShowPic(pos);
  316. int oldpos=m_pos;
  317. m_pos=pos;
  318. for(int i=0; i<7; i++)
  319. {
  320. if(m_pos%7==i)
  321. {
  322. m_picctrl[i].m_nFrameMode=100; m_picctrl[i].Invalidate();
  323. }
  324. else if(oldpos%7==i)
  325. {
  326. m_picctrl[i].m_nFrameMode=0;
  327. m_picctrl[i].Invalidate();
  328. }
  329. }
  330. ((ShowPic22*)GetParent())->m_pos=m_pos-1;
  331. ((ShowPic22*)GetParent())->Next();
  332. }
  333. break;
  334. }
  335. }
  336. CDialog::OnLButtonDown(nFlags, point);
  337. }