中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档 | 网通镜像
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > Web开发 > JavaScripts > 综合文章
CBasePage显示图片界面的基类
作者:佚名 时间:2005-02-24 11:03 出处:互连网 责编:chinaitpower
              摘要:CBasePage显示图片界面的基类

// BasePage.h : header file
//
//用于显示图片
#include  
#include
/////////////////////////////////////////////////////////////////////////////
// CBasePage window



class 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_FILE
static char THIS_FILE[] = __FILE__;
#endif


/////////////////////////////////////////////////////////////////////////////
// CBasePage


CBasePage::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_MAP
END_MESSAGE_MAP()



/////////////////////////////////////////////////////////////////////////////
// CBasePage message handlers
BOOL 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
}

关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有