标签:
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);
}
标签:
原文地址:http://www.cnblogs.com/tyks/p/5059872.html