触摸屏租赁
Touch screen rental
广告机租赁
Advertising rental
机器人租赁
Robot leasing
 当前位置:首页 > > 对话框背景贴图(文件)

void CMyDlg::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
 {
 RECT rect;
 CPaintDC dc(this);      //建立响应WM_PAINT消息的DC
   CDC *md = new CDC;       //建立一暂存DC md
  CBitmap *bitmap = new CBitmap;  //建立CBitmap位图对象
  GetClientRect(&rect);   //取得操作窗口大小
  md->CreateCompatibleDC(&dc); //将md转换成与dc兼容的DC
 bitmap->m_hObject = (HBITMAP)::LoadImage(NULL,"zhulin.bmp",
  IMAGE_BITMAP,rect.right,rect.bottom,LR_LOADFROMFILE);
//加载位图
 md->SelectObject(bitmap);  //选择位图对象到md中
 dc.BitBlt(0,0,rect.right,rect.bottom,md,0,0,SRCCOPY);
//将暂存DC中的位图贴到显示DC中
   delete md; //释放资源
  delete bitmap; //释放资源

  CDialog::OnPaint();
 }
}


工作室地址:重庆石桥铺电脑城B座 | 微信:z35544216 | 网址:www.35544216.com