导读:
1、由CodeProject 上下载CXImage,并编连之;
2、在欲使用CxImage的dll工程中设置:
project->settings->Object library->cximagecrtd.lib
且将cximagecrtd.dll拷贝至目标dll工程目录中。
3、在需要加入的相应头文件中加入
#include "ximage.h"
以贴png图至对话框为例
4、在对话框中添加成员变量
HBITMAP hBitmapBk;
5、重载函数
BOOL CDialingBoxDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CxImage image("E://PhoenixChen//new//calling_center.png", CXIMAGE_FORMAT_PNG);
hBitmapBk = image.MakeBitmap(GetDC()->m_hDC);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
6、重载函数
void CDialingBoxDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
/
BITMAP bitmap;
CRect rt;
CDC Cpmem;
GetWindowRect(rt);
GetObject(hBitmapBk,sizeof(BITMAP),&bitmap);
Cpmem.CreateCompatibleDC (&dc);
SelectObject(Cpmem.m_hDC ,hBitmapBk);
//pcdc->StretchBlt(0,0,rt.Width (),rt.Height (),&Cpmem,0,0,bitmap.bmWidth ,bitmap.bmHeight ,SRCCOPY);
dc.StretchBlt(0,0,rt.Width (),rt.Height (),&Cpmem,0,0,bitmap.bmWidth ,bitmap.bmHeight ,SRCCOPY);
Cpmem.DeleteDC ();
//EndPaint(&ps);
///
// Do not call CDialog::OnPaint() for painting messages
}
本文转自
http://www.xrss.cn/Dev/C/200731211151.Html
1、由CodeProject 上下载CXImage,并编连之;
2、在欲使用CxImage的dll工程中设置:
project->settings->Object library->cximagecrtd.lib
且将cximagecrtd.dll拷贝至目标dll工程目录中。
3、在需要加入的相应头文件中加入
#include "ximage.h"
以贴png图至对话框为例
4、在对话框中添加成员变量
HBITMAP hBitmapBk;
5、重载函数
BOOL CDialingBoxDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CxImage image("E://PhoenixChen//new//calling_center.png", CXIMAGE_FORMAT_PNG);
hBitmapBk = image.MakeBitmap(GetDC()->m_hDC);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
6、重载函数
void CDialingBoxDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
/
BITMAP bitmap;
CRect rt;
CDC Cpmem;
GetWindowRect(rt);
GetObject(hBitmapBk,sizeof(BITMAP),&bitmap);
Cpmem.CreateCompatibleDC (&dc);
SelectObject(Cpmem.m_hDC ,hBitmapBk);
//pcdc->StretchBlt(0,0,rt.Width (),rt.Height (),&Cpmem,0,0,bitmap.bmWidth ,bitmap.bmHeight ,SRCCOPY);
dc.StretchBlt(0,0,rt.Width (),rt.Height (),&Cpmem,0,0,bitmap.bmWidth ,bitmap.bmHeight ,SRCCOPY);
Cpmem.DeleteDC ();
//EndPaint(&ps);
///
// Do not call CDialog::OnPaint() for painting messages
}
本文转自
http://www.xrss.cn/Dev/C/200731211151.Html