ModifyStyle( WS_CAPTION, WS_MINIMIZEBOX, SWP_DRAWFRAME ); //去掉标题栏
SetWindowText("窗口标题");//设置对话框的标题
m_bmpBackground.LoadBitmap(IDB_BITMAP1); // 窗体背景图片//
void CTestDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
//CDialog::OnPaint();
//这段装载背景图
CPaintDC dc(this); //对话框的dc//CPaintDC是从CDC派生出来的。在构造时自动调用CWnd::BeginPaint,析构时调用CWnd::EndPaint。通常CPaintDC用来响应WM_PAINT消息。一般应用在OnPaint函数
CDC dcMem;
dcMem.CreateCompatibleDC(&dc); //创建与对话框dc兼容的内存dc
CRect rect;
GetClientRect(&rect);//该函数获取窗口客户区的坐标。
BITMAP bitMap;
m_bmpBackground.GetBitmap(&bitMap);//好像是设置背景图
CBitmap *pbmpOld=dcMem.SelectObject(&m_bmpBackground); //将背景位图选入内存dc中
dc.StretchBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0,bitMap.bmWidth,bitMap.bmHeight,SRCCOPY); //将内存dc中的位图拉伸显示在对话框的dc中
//dc.BitBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0,SRCCOPY);
}
}
第一步,定义一个CBitmap对象CBitmap m_bmpBackground;
第二步,用m_bmpBackground.LoadBitmap(IDB_BITMAP1);将资源文件中的图片载入;
第三步,