CBasePage显示图片界面的基类

王朝vc·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

// BasePage.h : header file

//

//用于显示图片

#include #include /////////////////////////////////////////////////////////////////////////////// CBasePage windowclass CBasePage : public CDialog{public: void SetpicPath(CString picpath); CBasePage(UINT nIDTemplate, CWnd* pParentWnd = NULL); virtual ~CBasePage();protected: //为了加速显示不放在ONPAINT中 BITMAP m_mapinfo; CDC m_memdc; CComBSTR m_picturePath; //{{AFX_MSG(CBasePage) virtual BOOL OnInitDialog(); afx_msg void OnPaint(); //}}AFX_MSG DECLARE_MESSAGE_MAP()};/////////////////////////////////////////////////////////////////////////////// BasePage.cpp : implementation file//#include "stdafx.h"#include "kyvodclient.h"#include "BasePage.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CBasePageCBasePage::CBasePage(UINT nIDTemplate, CWnd *pParentWnd) :CDialog(nIDTemplate,pParentWnd)//没有对话框资源,要续传给CDialog{ //{{AFX_DATA_INIT(CBasePage) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT}CBasePage::~CBasePage(){}BEGIN_MESSAGE_MAP(CBasePage, CDialog) //{{AFX_MSG_MAP(CBasePage) ON_WM_PAINT() //}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CBasePage message handlersBOOL CBasePage::OnInitDialog() { CDialog::OnInitDialog(); //------------------------------------------------------------------ // Full-Screen Setup //------------------------------------------------------------------ int cx, cy; HDC dc = ::GetDC(NULL); cx = GetDeviceCaps(dc,HORZRES) + GetSystemMetrics(SM_CXBORDER); cy = GetDeviceCaps(dc,VERTRES) + GetSystemMetrics(SM_CYBORDER); ::ReleaseDC(0,dc); ::SetWindowPos(m_hWnd, HWND_TOPMOST, -(GetSystemMetrics(SM_CXBORDER)+1), -(GetSystemMetrics(SM_CYBORDER)+1), cx+1,cy+1, SWP_NOZORDER); //------------------------------------------------------------------ // Load Picture //------------------------------------------------------------------ CPictureHolder picholder; CBitmap bitmap; long WD, HT; if(SUCCEEDED(::OleLoadPicturePath(m_picturePath,0,0,0,IID_IPicture,(void**)&picholder))) { picholder.m_pPict->get_Width (&WD); picholder.m_pPict->get_Height(&HT); } m_memdc.CreateCompatibleDC(GetDC()); bitmap.CreateCompatibleBitmap(GetDC(),cx,cy); m_memdc.SelectObject(bitmap); picholder.Render(&m_memdc,CRect(0,0,cx,cy),CRect(0,0,cx,cy)); bitmap.GetBitmap(&m_mapinfo); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE}void CBasePage::OnPaint() { CPaintDC dc(this); // device context for painting dc.BitBlt(0,0,m_mapinfo.bmWidth,m_mapinfo.bmHeight,&m_memdc,0,0,SRCCOPY); // Do not call CDialog::OnPaint() for painting messages}void CBasePage::SetpicPath(CString path){ m_picturePath = path;} //////////////////////////////////子类调用/////////////////////////////////////////////////////BOOL CSingerList::OnInitDialog() { char CurPath[MAX_PATH]; GetCurrentDirectory(MAX_PATH,CurPath); SetpicPath(CurPath + CString("\\image\\singerlist.jpg")); CBasePage::OnInitDialog();//要在最后调用 return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE}void CSingerList::OnPaint() { CBasePage::OnPaint(); // Do not call CDialog::OnPaint() for painting messages}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航