PreviewDlg.cpp 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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. int i = 0;
  65. for( i=0; i<m_pPathArray->GetSize (); i++)
  66. {
  67. path=m_pPathArray->ElementAt(i);
  68. pos=path.ReverseFind('\\');
  69. str=path.Right(path.GetLength()-pos-1);
  70. str.TrimLeft("m");
  71. m_patharray.Add(path.Left(pos)+"\\s"+str);
  72. }
  73. m_pPathArray=&m_patharray;
  74. if(m_pPathArray->GetSize ()%7==0)
  75. m_npages=m_pPathArray->GetSize ()/7;
  76. else
  77. m_npages=m_pPathArray->GetSize ()/7+1;
  78. CRect rc;
  79. GetWindowRect(rc);
  80. int wid=rc.Width ();
  81. int hei=rc.Height ();
  82. CRect rc2;
  83. rc2.left =25;
  84. rc2.right =wid-5;
  85. rc2.top =30;
  86. int pichei=(hei-6*5-rc2.top*2)/7;
  87. int dt=pichei+5;
  88. rc2.bottom =rc2.top +pichei;
  89. for( i=0; i<7; i++)
  90. {
  91. m_picctrl[i].Create(_T(""), WS_VISIBLE|WS_CHILD|SS_BITMAP, rc2, this);
  92. rc2.top +=dt;
  93. rc2.bottom +=dt;
  94. /* if(m_pPathArray->GetSize()>i)
  95. {
  96. path=m_pPathArray->ElementAt(i);
  97. m_picctrl[i].SetPicPath(path);
  98. }*/
  99. }
  100. rc.left=10;
  101. rc.right=rc.left+10;
  102. rc.top=10;
  103. rc.bottom=25;
  104. m_link1.Create ("¡Ä", WS_CHILD|WS_VISIBLE, rc, this, 100);//¡Å
  105. m_link1.PositionWindow();
  106. m_link1.GetWindowRect (rc);ScreenToClient(rc);
  107. dt=wid/2-rc.left-rc.Width()/2+10;
  108. rc.left +=dt;
  109. rc.right +=dt;
  110. m_link1.MoveWindow(rc);
  111. rc.bottom=hei-5;
  112. rc.top=hei-25;
  113. m_link2.Create ("¡Å", WS_CHILD|WS_VISIBLE, rc, this, 100);
  114. m_link2.PositionWindow();
  115. ////////////////
  116. rc.left=5;
  117. rc.right=rc.left+10;
  118. rc.top=0;
  119. rc.bottom=hei;
  120. m_link3.Create ("£¼", WS_CHILD|WS_VISIBLE, rc, this, 100);//£¾
  121. m_link3.PositionWindow();
  122. m_link3.GetWindowRect (rc);ScreenToClient(rc);
  123. dt=hei/2-rc.top-rc.Height()/2;
  124. rc.top +=dt;
  125. rc.bottom +=dt;
  126. m_link3.MoveWindow(rc);
  127. m_link1.m_bBlackBk=1;
  128. m_link2.m_bBlackBk=1;
  129. m_link3.m_bBlackBk=1;
  130. //////////////////////////////////////////////////////////
  131. // CRect rc;
  132. GetClientRect(rc);
  133. CRgn rgn1, rgn2, rgn3;
  134. rgn1.CreateRectRgn (0,0, rc.Width (), rc.Height ());
  135. // rgn2.CreateRectRgn (0,0, 10, 10);
  136. // rgn3. CreateEllipticRgn(0,0,20,20);
  137. // rgn2.CombineRgn (&rgn2, &rgn3, RGN_DIFF);
  138. m_link1.GetWindowRect (rc);
  139. ScreenToClient(rc);
  140. rgn2.CreateRectRgn (rc.left,rc.top, rc.right, rc.bottom);
  141. rgn1.CombineRgn (&rgn1, &rgn2, RGN_DIFF);
  142. rgn2.DeleteObject ();
  143. m_link2.GetWindowRect (rc);
  144. ScreenToClient(rc);
  145. rgn2.CreateRectRgn (rc.left,rc.top, rc.right, rc.bottom);
  146. rgn1.CombineRgn (&rgn1, &rgn2, RGN_DIFF);
  147. rgn2.DeleteObject ();
  148. m_link3.GetWindowRect (rc);
  149. ScreenToClient(rc);
  150. rgn2.CreateRectRgn (rc.left,rc.top, rc.right, rc.bottom);
  151. rgn1.CombineRgn (&rgn1, &rgn2, RGN_DIFF);
  152. rgn2.DeleteObject ();
  153. for( i=0; i<7; i++)
  154. {
  155. m_picctrl[i].GetWindowRect (rc);
  156. ScreenToClient(rc);
  157. rgn2.CreateRectRgn (rc.left,rc.top, rc.right, rc.bottom);
  158. rgn1.CombineRgn (&rgn1, &rgn2, RGN_DIFF);
  159. rgn2.DeleteObject ();
  160. }
  161. GetClientRect(rc);
  162. rgn2.CreateRectRgn (0,0, rc.Width (), rc.Height ());
  163. rgn2.CombineRgn (&rgn2, &rgn1, RGN_DIFF);
  164. rgn1.DeleteObject ();
  165. ::SetWindowRgn (m_hWnd, rgn2, 0);
  166. }
  167. void PreviewDlg::OnDestroy()
  168. {
  169. CDialog::OnDestroy();
  170. // TODO: Add your message handler code here
  171. delete g_pBlackBrush;
  172. delete g_pRedBrush;
  173. if(g_pImgStaBuf)delete g_pImgStaBuf;g_pImgStaBuf=NULL;
  174. }
  175. void PreviewDlg::ShowMin()
  176. {
  177. m_bMin=1;
  178. m_link3.SetWindowText ("£¼");
  179. CRect rc;
  180. rc.top =50;
  181. rc.bottom =g_screenhei-50;
  182. rc.right =g_screenwid-10;
  183. rc.left =rc.right -100;
  184. ///////////////////////////
  185. rc.left=g_screenwid-20;
  186. rc.right=rc.left+100;
  187. ///////////////////////////
  188. MoveWindow (rc);
  189. }
  190. void PreviewDlg::ShowNormal()
  191. {
  192. if(((ShowPic22*)GetParent())->m_bauto)
  193. {
  194. return;
  195. }
  196. m_bMin=0;
  197. m_link3.SetWindowText ("£¾");
  198. CRect rc;
  199. rc.top =50;
  200. rc.bottom =g_screenhei-50;
  201. rc.right =g_screenwid-10;
  202. rc.left =rc.right -100;
  203. ///////////////////////////
  204. // rc.left=g_screenwid-20;
  205. // rc.right=rc.left+100;
  206. ///////////////////////////
  207. MoveWindow (rc);
  208. ShowPic(((ShowPic22*)GetParent())->m_pos);
  209. }
  210. void PreviewDlg::LinkClick(CString str)
  211. {
  212. if(str=="£¼")
  213. {
  214. ShowNormal();
  215. }
  216. else if(str=="£¾")
  217. {
  218. ShowMin();
  219. }
  220. else if(str=="¡Ä")
  221. {
  222. PrePage();
  223. }
  224. else if(str=="¡Å")
  225. {
  226. NextPage();
  227. }
  228. }
  229. void PreviewDlg::ShowPic(int pos)
  230. {
  231. if(m_bMin)return;
  232. CString path;
  233. m_pos=pos;
  234. m_ncurpage=pos/7;
  235. for(int i=0; i<7; i++)
  236. {
  237. if(m_pos%7==i)
  238. {
  239. m_picctrl[i].m_nFrameMode=100;
  240. }
  241. else
  242. m_picctrl[i].m_nFrameMode=0;
  243. pos=m_ncurpage*7+i;
  244. if(m_pPathArray->GetSize()>pos)
  245. {
  246. path=m_pPathArray->ElementAt(pos);
  247. m_picctrl[i].SetPicPath(path);
  248. }
  249. else
  250. m_picctrl[i].SetPicPath("");
  251. }
  252. }
  253. void PreviewDlg::ShowPic2()
  254. {
  255. CString path;
  256. m_pos=m_ncurpage*7;
  257. for(int i=0; i<7; i++)
  258. {
  259. if(m_pos%7==i)
  260. {
  261. m_picctrl[i].m_nFrameMode=100;
  262. }
  263. else
  264. m_picctrl[i].m_nFrameMode=0;
  265. int pos=m_ncurpage*7+i;
  266. if(m_pPathArray->GetSize()>pos)
  267. {
  268. path=m_pPathArray->ElementAt(pos);
  269. m_picctrl[i].SetPicPath(path);
  270. }
  271. else
  272. m_picctrl[i].SetPicPath("");
  273. }
  274. }
  275. void PreviewDlg::PrePage()
  276. {
  277. try
  278. {
  279. if(m_ncurpage==0)
  280. m_ncurpage=m_npages-1;
  281. else
  282. m_ncurpage--;
  283. ShowPic2();
  284. }
  285. catch(...)
  286. {
  287. }
  288. }
  289. void PreviewDlg::NextPage()
  290. {
  291. try
  292. {
  293. if(m_ncurpage==m_npages-1)
  294. m_ncurpage=0;
  295. else
  296. m_ncurpage++;
  297. ShowPic2();
  298. }
  299. catch(...)
  300. {
  301. }
  302. }
  303. void PreviewDlg::OnLButtonDown(UINT nFlags, CPoint point)
  304. {
  305. // TODO: Add your message handler code here and/or call default
  306. CRect rc;
  307. for(int i=0; i<7; i++)
  308. {
  309. m_picctrl[i].GetWindowRect(rc);
  310. ScreenToClient(rc);
  311. if(rc.PtInRect (point))
  312. {
  313. int pos=m_ncurpage*7+i;
  314. if(m_pPathArray->GetSize()>pos)
  315. {
  316. // ShowPic(pos);
  317. int oldpos=m_pos;
  318. m_pos=pos;
  319. for(int i=0; i<7; i++)
  320. {
  321. if(m_pos%7==i)
  322. {
  323. m_picctrl[i].m_nFrameMode=100; m_picctrl[i].Invalidate();
  324. }
  325. else if(oldpos%7==i)
  326. {
  327. m_picctrl[i].m_nFrameMode=0;
  328. m_picctrl[i].Invalidate();
  329. }
  330. }
  331. ((ShowPic22*)GetParent())->m_pos=m_pos-1;
  332. ((ShowPic22*)GetParent())->Next();
  333. }
  334. break;
  335. }
  336. }
  337. CDialog::OnLButtonDown(nFlags, point);
  338. }