****************************
华软源码:http://www.hur.cn
****************************
颜色拾取器的设计
景周兄曾经写过一个很好的颜色拾取器,若加上颜色显示则更完美。本程序在此基础上实现
了此功能,具体请看代码;
主要代码在OnPaint()中实现:
CWnd * pWnd = GetDlgItem(IDC_COLOR);//get the item
CBrush *brush ;
brush = new CBrush(RGB(red,green,blue));//init the brush;
CDC * pCtrlDC = pWnd->GetDC();//get the dc point
pWnd->Invalidate();//other program can use paint()
pWnd->UpdateWindow();//update the window
pCtrlDC->SelectObject(brush);//select brush;
pCtrlDC->Rectangle(0,0,140,40);//set the paint rect
delete brush;//must delete brush,otherwise can cause memory leak;
修改人:
丛栋
email:
cong119@sohu.com
monkeycd@163.com