设为首页 加入收藏

TOP

17.9.3 电子相册浏览模块的设计与实现(3)
2013-10-07 14:39:44 来源: 作者: 【 】 浏览:58
Tags:17.9.3 电子相册 浏览 模块 设计 实现

17.9.3  电子相册浏览模块的设计与实现(3)

在对话框的构造函数中对这些变量进行初始化:

  1. 01  CMyBookDlg::CMyBookDlg(CWnd* pParent /*=NULL*/)  
  2. 02      : CDialog(CMyBookDlg::IDD, pParent)  
  3. 03  {  
  4. 04      m_photoFrameLeft = 160;                 //相册距对话框左侧160个像素  
  5. 05      m_photoFrameTop  = 130;                 //相册距对话框上侧130个像素  
  6. 06      PageInit();                             //相册页面初始化  
  7. 07      m_bLtnDown = false;                     //鼠标左键未按下  
  8. 08      m_x = 0;                                //转动轴点距边0个像素  
  9. 09      m_strPage[0] = "背景\\003.jpg";           //指定页面1的路径  
  10. 10      m_strPage[1] = "背景\\004.jpg";           //指定页面2的路径  
  11. 11      m_strPage[2] = "背景\\003.jpg";           //指定页面3的路径  
  12. 12      m_strPage[3] = "背景\\004.jpg";           //指定页面4的路径  
  13. 13      m_strPage[4] = "背景\\000.jpg";           //指定封面的路径  
  14. 14      m_strPage[5] = "背景\\005.jpg";           //指定封底的路径  
  15. 15      m_curNum = 0;                           //当前翻动的相片序号为0  
  16. 16      m_turnType = type_head;                 //翻动类型为封面  
  17. 17      m_bAuto = false;                        //未自动播放  
  18. 18      m_bTOnce = false;                       //未一次性翻页  
  19. 19      SetPage();                              //设置页面  
  20. 20  }  

【代码解析】

还有一些变量是在相册控制模块跳到浏览模块时直接初始化的,详见源码。

(3)在(2)中调用了PageInit()这个函数,它主要实现4个页面相片边框的初始化工作:

  1. 01  void CMyBookDlg::PageInit()  
  2. 02  {  
  3. 03      //页面1相片边框  
  4. 04      m_rectPL.left = 60;   
  5. 05      m_rectPL.top = 60;  
  6. 06      m_rectPLm_rectPL.right = m_rectPL.left + 404;  
  7. 07      m_rectPLm_rectPL.bottom = m_rectPL.top + 450;  
  8. 08      //页面2相片边框  
  9. 09      m_rectPR.left = 74;  
  10. 10      m_rectPR.top = 60;  
  11. 11      m_rectPRm_rectPR.right = m_rectPR.left + 404;  
  12. 12      m_rectPRm_rectPR.bottom = m_rectPR.top + 450;  
  13. 13      //页面3相片边框  
  14. 14      m_rectTL.left = 60;  
  15. 15      m_rectTL.top = 60;  
  16. 16      m_rectTL.right = m_rectPL.left + 404;  
  17. 17      //页面4相片边框  
  18. 18      m_rectTR.left = 74;  
  19. 19      m_rectTR.top = 60;  
  20. 20      m_rectTR.right = m_rectPR.left + 404;  
  21. 21      m_rectTR.bottom = m_rectPR.top + 450;  
  22. 22  }  

(4)在(2)中还调用了SetPage()函数,在该函数中载入了4个参与翻动的页面及封面封底的图像,并定义了4个Graphics型变量进行页面翻动操作。

  1. 01  void CMyBookDlg::SetPage()  
  2. 02  {  
  3. 03      wchar_t *wPage,*wImage;  
  4. 04      int len;  
  5. 05      int i = 0;  
  6. 06      for( i = 0; i < 4; i++)  
  7. 07      {   //载入4个翻动页面  
  8. 08          len = MultiByteToWideChar(CP_ACP, 0, (LPCTSTR)m_strPage[i], -1,             NULL, 0);  
  9. 09          wPage = new wchar_t[len];  
  10. 10          MultiByteToWideChar(CP_ACP, 0, (LPCTSTR)m_strPage[i], -1,               wPage, len);   
  11. 11          m_pPage[i] = Bitmap::FromFile(wPage);  
  12. 12          delete []wPage;  
  13. 13          //载入4个参与翻动的相片  
  14. 14          len = MultiByteToWideChar(CP_ACP, 0, (LPCTSTR)m_strImage[i], -1,            NULL, 0);  
  15. 15          wImage = new wchar_t[len];  
  16. 16          MultiByteToWideChar(CP_ACP, 0, (LPCTSTR)m_strImage[i], -1,              wImage, len);   
  17. 17          m_pImage[i] = Image::FromFile(wImage);  
  18. 18          delete []wImage;  
  19. 19          //定义4个翻动页面的Graphics型变量  
  20. 20          m_pGPage[i] = Graphics::FromImage(m_pPage[i]);  
  21. 21      }  
  22. 22      for( i = 4; i < 6; i++)  
  23. 23      {   //载入相册封面和封底  
  24. 24          len = MultiByteToWideChar(CP_ACP, 0, (LPCTSTR)m_strPage[i], -1,             NULL, 0);  
  25. 25          wPage = new wchar_t[len];  
  26. 26          MultiByteToWideChar(CP_ACP, 0, (LPCTSTR)m_strPage[i], -1,               wPage, len);   
  27. 27          m_pPage[i] = Bitmap::FromFile(wPage);  
  28. 28          delete []wPage;  
  29. 29      }  
  30. 30  }  


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇17.9.3 电子相册浏览模块的设计与.. 下一篇17.9.3 电子相册浏览模块的设计与..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: