17.9.3 电子相册浏览模块的设计与实现(10)
代码实现如下:
- 01 else if(m_turnType == type_left || m_turnType == type_end)
- 02 {
- 03 for( int i = 0; i < 4; i++)
- 04 { //载入4张相册页面
- 05
- 06 len = MultiByteToWideChar(CP_ACP, 0,
- 07 (LPCTSTR)m_strPage[i], -1, NULL, 0);
- 08 wPage = new wchar_t[len];
- 09 MultiByteToWideChar(CP_ACP, 0,
- 10 (LPCTSTR)m_strPage[i], -1, wPage, len);
- 11 m_pPage[i] = Bitmap::FromFile(wPage);
- 12 delete []wPage;
- 13 } //载入页面1中的相片
- 14 len = MultiByteToWideChar(CP_ACP, 0,
- 15 (LPCTSTR)m_strImage[m_curNum -1 - 2],
- 16 -1, NULL, 0);
- 17 wImage = new wchar_t[len];
- 18 MultiByteToWideChar(CP_ACP, 0,
- 19 (LPCTSTR)m_strImage[m_curNum - 1 - 2], -1, wImage,
- 20 len); //第n-3张
- 21 m_pImage[0] = Image::FromFile(wImage);
- 22 delete []wImage;
- 23 //载入页面2中的相片
- 24 len = MultiByteToWideChar(CP_ACP, 0,
- 25 (LPCTSTR)m_strImage[m_curNum - 2],
- 26 -1, NULL, 0);
- 27 wImage = new wchar_t[len];
- 28 MultiByteToWideChar(CP_ACP, 0,
- 29 (LPCTSTR)m_strImage[m_curNum - 2],
- 30 -1, wImage, len);
- 31 m_pImage[1] = Image::FromFile(wImage); //第n-2张
- 32 delete []wImage;
- 33 //载入页面3中的相片
- 34 len = MultiByteToWideChar(CP_ACP, 0,
- 35 (LPCTSTR)m_strImage[m_curNum -3 - 2],
- 36 -1, NULL, 0);
- 37 wImage = new wchar_t[len];
- 38 MultiByteToWideChar(CP_ACP, 0,
- 39 (LPCTSTR)m_strImage[m_curNum -3 - 2],
- 40 -1, wImage, len); //第n-5张
- 41 m_pImage[2] = Image::FromFile(wImage);
- 42 delete []wImage;
- 43 //载入页面4中的相片
- 44 len = MultiByteToWideChar(CP_ACP, 0,
- 45 (LPCTSTR)m_strImage[m_curNum -2 - 2],
- 46 -1, NULL, 0);
- 47 wImage = new wchar_t[len];
- 48 MultiByteToWideChar(CP_ACP, 0,
- 49 (LPCTSTR)m_strImage[m_curNum -2 - 2],
- 50 -1, wImage, len); //第n-4张
- 51 m_pImage[3] = Image::FromFile(wImage);
- 52 delete []wImage;
- 53 //定义4个页面的Graphics型变量
- 54 for(i = 0; i < 4; i++)
- 55 {
- 56 m_pGPage[i] = Graphics::FromImage(m_pPage[i]);
- 57 }
- 58 //判断是否到达封面
- 59 if(m_curNum <= 3)
- 60 {
- 61 m_turnType = type_leftTohead;
- 62 m_curNum = -2;
- 63 }
- 64 else
- 65 {
- 66 m_curNum -= 2; //前移
- 67 }
- 68 }
【代码解析】
由代码结合图像可以看出,虽然同右翻页的原理相同,但是由于顺序有变,赋值方式也就有了区别。