最近,分配我这个苦力去做界面,现将此中的一个东东总结一哈子,以便让更多的苦力分享并共勉一盘子。
要使用CImage类,就在对话框类的头文件中定义一个:CImage类
CImage m_DlgBKImage;
再在此对话框的OnInitDialog中进行载入,方法为:
char LoatFilePath[256] = "C://Documents and Settings//Administrator//桌面//20090728//20090728//23.jpg";
HRESULT ImageLoad;
CRect rect;
CWnd::GetClientRect(&rect);
ImageLoad = m_DlgBKImage.Load(LoatFilePath);
if(0 == ImageLoad)
{
Messagebox("load file error!");
}
InvalidateRect(&rect,TRUE);
再在对话框的OnPaint方法中:
CPaintDC dc(this); // 用于绘制的设备上下文
CRect rect;
GetClientRect(&rect);
if (!m_DlgBKImage.IsNull())
{
m_DlgBKImage.StretchBlt(dc,rect);
}
就能够显示出指定的图片在对话框的背景上了