MFC控件CMonthCalCtrl设置颜色颜色无效

   今天用起了MFC的日历控件,发现SetColor函数并没有起到作用,百度一番也没有找到解决办法,于是翻过墙google下,找到下面的内容,算是解决办法,原文如下:

from: [email protected]

subject: Re: CMonthCalCtrl::SetColor doesn't change visual color

On Friday, May 22, 2009 7:11:00 PM UTC+8, Kai wrote:

> VS2008 in Vista,

> m_Cal.SetColor(MCSC_MONTHBK, 0x0000FF00);

> then check color

> COLORREF color = m_Cal.GetColor(MCSC_MONTHBK);

> color = 0x0000FF00;

> I also tried other regions. Nothing happens. What is wrong?


quote from MSDN


If visual styles are active, this macro has no effect except when iColor is MCSC_BACKGROUND.


if you want to change color, you MUST to disable visual style.


HOW?

you can open stdafx.h then comment the line something like below


#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")



Then your "SetColor" will works!


Regards,


方法是注释掉stdafx.h内的

#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")


你可能感兴趣的:(setColor,CMonthCalCtrl)