Answers
DTT_TEXTCOLOR;
dttopts.crText = cr;<br />
DrawThemeTextEx(dc,TEXT_LABEL,0,str,-1,style,&rc,&dttopts);<br />
}<br />
BOOL OnEraseBkgnd(CDCHandle){ return TRUE; }<br />
void OnPaint(CDCHandle)<br />
{<br />
CPaintDC dc(this->m_hWnd); //此句不能删除<br />
//原来windows底层在调用了Invaildate后会发送一个WM_PAINT的消息给DC,如果没有调用BeginPaint的话,<br />
//这个WM_PAINT消息会一直触发。 <br />
CDCHandle buff_dc;<br />
CRect rc_client;<br />
this->GetClientRect(&rc_client);<br />
Begin(dc,rc_client,BPBF_TOPDOWNDIB,NULL,buff_dc);<br />
int alpha = 255; // 指定控件透明度<br />
if(alpha > 0)<br />
SetAlpha(NULL, alpha);<br />
End(TRUE);<br />
}<br />
};
小吴酱SAMA
answered 10 years, 5 months ago
在Aero窗口中使用GDI绘制会产生穿透的问题。
解决方法:
1,使用gdi+,参考资料
2,仍旧使用gdi,不过,还需要如此做,使用Aero双缓存
WTL代码:
template <class T,class TBase = CWindow>
class Ctrl : public CWindowImpl<T,TBase>,public CBufferedPaint,public CThemeImpl<T>
{
public:
BEGIN_MSG_MAP(Ctrl)
CHAIN_MSG_MAP(CThemeImpl<T>)
MSG_WM_ERASEBKGND(OnEraseBkgnd)
MSG_WM_PAINT(OnPaint)
END_MSG_MAP()
public:
Ctrl()
{
SetThemeClassList(L"globals");
}
void DrawText(HDC dc,CString str,CRect rc,COLORREF cr = RGB(51,51,51),
DWORD style = CENTER)
{
DTTOPTS dttopts = { sizeof(DTTOPTS) };
dttopts.dwFlags = DTT_COMPOSITED
快坏掉DA叔
answered 10 years, 5 months ago