#include "stdafx.h" #include "ylgl.h" #include "ShowPicStatic2.h" #include "PreviewDlg.h" #ifdef _DEBUG //#define new DEBUG_NEW //wangwenbin modify 2014-04-27 #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif Bitmap *g_pImgStaBuf=NULL; ShowPicStatic2::ShowPicStatic2() { m_pImageBk=NULL; m_nFrameMode=-1; m_bStretch=1; if(g_pImgStaBuf==NULL)g_pImgStaBuf=new Bitmap(1500, 1500, PixelFormat24bppRGB); } ShowPicStatic2::~ShowPicStatic2() { ReleaseData(); } BEGIN_MESSAGE_MAP(ShowPicStatic2, CStatic) ON_WM_PAINT() ON_WM_SETCURSOR() ON_WM_ERASEBKGND() END_MESSAGE_MAP() void ShowPicStatic2::OnPaint() { CPaintDC dc(this); try { CRect rc; GetClientRect(&rc); Graphics bufgraph(g_pImgStaBuf); Rect destinationRect(rc.left , rc.top , rc.Width (), rc.Height ()); bufgraph.FillRectangle(((PreviewDlg*)GetParent())->g_pBlackBrush, destinationRect); /* if(m_nFrameMode==1)//À¶¿òÀ¶±ß { Rect destinationRect(rc.left , rc.top , rc.Width (), rc.Height ()); bufgraph.FillRectangle(g_pBlueBrush2, destinationRect); rc.DeflateRect (1,1); Rect destinationRect2(rc.left , rc.top , rc.Width (), rc.Height ()); bufgraph.FillRectangle(g_pBlueBrush, destinationRect2); } else if(m_nFrameMode==2)//À¶¿òºÚ±ß { Rect destinationRect(rc.left , rc.top , rc.Width (), rc.Height ()); bufgraph.FillRectangle(g_pBlackBrush, destinationRect); rc.DeflateRect (1,1); Rect destinationRect2(rc.left , rc.top , rc.Width (), rc.Height ()); bufgraph.FillRectangle(g_pBlueBrush, destinationRect2); } else if(m_nFrameMode==3)//°×¿ò»Ò±ß { Rect destinationRect(rc.left , rc.top , rc.Width (), rc.Height ()); bufgraph.FillRectangle(g_pWhiteBrush2, destinationRect); rc.DeflateRect (2,2); Rect destinationRect2(rc.left , rc.top , rc.Width (), rc.Height ()); bufgraph.FillRectangle(g_pWhiteBrush, destinationRect2); }*/ if(m_nFrameMode==100)//À¶¿òºì±ß,´ú±íÑ¡ÖÐ״̬ { Rect destinationRect(rc.left , rc.top , rc.Width (), rc.Height ()); bufgraph.FillRectangle(((PreviewDlg*)GetParent())->g_pRedBrush, destinationRect); rc.DeflateRect (1,1); Rect destinationRect2(rc.left , rc.top , rc.Width (), rc.Height ()); bufgraph.FillRectangle(((PreviewDlg*)GetParent())->g_pBlackBrush, destinationRect2); } if(m_pImageBk) { int width=m_pImageBk->GetWidth(); int height=m_pImageBk->GetHeight(); if(m_bStretch) RectFitDes(width, height, rc); Rect destinationRect(rc.left , rc.top , rc.Width (), rc.Height ()); bufgraph.DrawImage(m_pImageBk, destinationRect, 0,0,width,height,UnitPixel); } { Graphics dcgraph(dc.GetSafeHdc()); GetClientRect(&rc); Rect destinationRect(rc.left , rc.top , rc.Width (), rc.Height ()); dcgraph.DrawImage(g_pImgStaBuf, destinationRect, 0,0,rc.Width (), rc.Height (),UnitPixel); } } catch(...) { } } void ShowPicStatic2::ReleaseData() { try { if(m_pImageBk) { delete m_pImageBk; m_pImageBk=NULL; } } catch(...) { } } BOOL ShowPicStatic2::OnEraseBkgnd(CDC* pDC) { return TRUE; } void ShowPicStatic2::SetPicPath(CString pathname) { try { ReleaseData(); if(!::PathFileExists (pathname)) { Invalidate(); return; } pathname.MakeLower (); if(pathname.Right (3)=="jpg") { LoadImageFromBuf(&m_pImageBk, pathname); } Invalidate(); } catch(...) { } } extern HCURSOR g_cursorhand; BOOL ShowPicStatic2::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { ::SetCursor(g_cursorhand); return TRUE; }