码迷,mamicode.com
首页 > 编程语言 > 详细

MFC 填充系统 方法记录

时间:2015-12-19 23:11:16      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:

1.设置按钮图片

 HBITMAP hbitmap;
 hbitmap = LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(130));  //资源id 130
 ((CButton *)GetDlgItem(1005))->SetBitmap(hbitmap);
 ((CButton *)GetDlgItem(1006))->SetBitmap(hbitmap);

 

2.在onPaint 里响应的dc CPaintDC 其他函数内无效

void CregionTracingDlg::initColorPane(CStatic *cp, COLORREF color)
{
 CPaintDC ColorPaneDc(cp);

 CRect rect;
 cp->GetWindowRect(&rect);
 CBrush brs;
 CRect picrct;
 picrct.top = 0;
 picrct.left = 0;
 picrct.bottom = rect.Height();
 picrct.right = rect.Width();
 brs.CreateSolidBrush(color);
 ColorPaneDc.FillRect(&picrct, &brs);
}

 

3.通用文件对话框

 CFileDialog dlg(TRUE, _T("*.bmp"), NULL, OFN_FILEMUSTEXIST, _T("Bitmap File(*.bmp)|*.bmp|JPG Files (*.jpg)|*.jpg||"),NULL);
 
 
 if (dlg.DoModal() == IDOK)
 {}

 

4.动态设置指针

BOOL CregionTracingDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
 // TODO:  在此添加消息处理程序代码和/或调用默认值
 if (cursorFlag != 0)
 {
  HCURSOR m_cursorCur = LoadCursor(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDC_CURSOR1));
  SetCursor(m_cursorCur);
  return true;
 }
 
 return CDialog::OnSetCursor(pWnd, nHitTest, message);
}

 

5.获取当前鼠标单击点的颜色

void CregionTracingDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
 // TODO:  在此添加消息处理程序代码和/或调用默认值
 if (cursorFlag == 1)
 {

  targetColor= GetPixel(this->GetDC()->GetSafeHdc(),point.x,point.y);

  refreshColorPane();
  cursorFlag = 0;
 }
 else if (cursorFlag == 2)
 {
  backgroundColor = GetPixel(this->GetDC()->GetSafeHdc(), point.x, point.y);

  refreshColorPane();
  cursorFlag = 0;
 }

 CDialogEx::OnLButtonDown(nFlags, point);
}


 

MFC 填充系统 方法记录

标签:

原文地址:http://www.cnblogs.com/tyks/p/5059872.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!