图象: 用一个灰的遮罩(RGB(100,100,100)左右)跟它AND或OR一下(以前试过的,具体现在忘了,反正就是这个思路)
如果图象是ICON,那么在DrawIconEx里指定IconStyle = ILD_BLEND25;
文字:设定文字颜色,输出,然后偏移N(n自己体会吧)个象素,再输出一次,当然再换个颜色了。你找个disable的按钮,仔细看一看吧
如果图象是ICON,那么在DrawIconEx里指定IconStyle = ILD_BLEND25;
文字:设定文字颜色,输出,然后偏移N(n自己体会吧)个象素,再输出一次,当然再换个颜色了。你找个disable的按钮,仔细看一看吧
用DrawState函数就行了。
各位高手请指教。
//回调函数,在这里设定大小什么的
BOOL WINAPI DrawStateProc(
HDC hdc, // handle to device context
LPARAM lData, // image information
WPARAM wData, // more image information
int cx, // width of image
int cy // height of image
)
{
BITMAP bm;
HDC hMemDC = ::CreateCompatibleDC (hdc);
SelectObject(hMemDC,(HBITMAP)lData);
GetObject((HBITMAP)lData,sizeof(BITMAP),&bm);
::StretchBlt (hdc,0,0,cx,cy,hMemDC,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
TextOut(hdc,0,50,"Hehe",4);
DeleteDC(hMemDC);
return true;
}////////////////////////////////////
//在OnPaint或什么地方调用
DrawState(dc.GetSafeHdc (),NULL,DrawStateProc ,(LPARAM)m_Bm.GetSafeHandle (),0,10,150,100,100,DST_COMPLEX|DSS_DISABLED);
是不是整个工具条的按钮的图像都要变灰呢?
用CToolBar::SetBitmap 能行吗?(自己画个变灰状态的Bitmap)
for( int i=0; i < nColors; i++)
{
// First save original colors
peOriginal[i].peRed = bmInfo.bmiColors[i].rgbRed ;
peOriginal[i].peGreen = bmInfo.bmiColors[i].rgbGreen;
peOriginal[i].peBlue = bmInfo.bmiColors[i].rgbBlue ;
long lSquareSum = bmInfo.bmiColors[i].rgbRed * bmInfo.bmiColors[i].rgbRed
+ bmInfo.bmiColors[i].rgbGreen * bmInfo.bmiColors[i].rgbGreen
+ bmInfo.bmiColors[i].rgbBlue * bmInfo.bmiColors[i].rgbBlue;
int nGray = (int)sqrt(((double)lSquareSum)/3);
bmInfo.bmiColors[i].rgbRed = nGray;
bmInfo.bmiColors[i].rgbGreen = nGray;
bmInfo.bmiColors[i].rgbBlue = nGray;// Create a reference color table
peGray[i].peRed = nGray;
peGray[i].peGreen = nGray;
peGray[i].peBlue = nGray;
}