Text Control 控制元件通過定時器設定,每隔一秒重繪控制元件里面的內容。但是我設定了背景透明效果后,控制元件就沒法重繪,設定固定顏色背景就可以重繪內容
實際效果:


Text Control 顯示代碼
bool CIDCardCountDown::ShowMessage()
{
unsigned int delaySeconds = m_countDownSeconds - m_consumeSeconds;
CRect rc;
::GetWindowRect(m_hWnd, rc);
m_pParent->InvalidateRect(rc);
CString strFormat;
if (delaySeconds>=10)
{
strFormat.LoadString(IDS_IDCARD_COUNT_DOWN_MSG);//顯示的訊息
}
else
{
strFormat.LoadString(IDS_IDCARD_COUNT_DOWN_MSG_LESSTHAN10);
}
CString strMsg;
strMsg.Format(strFormat, delaySeconds);
::SetWindowText(m_hWnd, strMsg);
//::InvalidateRect(m_hWnd, &rc, TRUE);
if (delaySeconds == 0)
{
EndCountDown();
FireCountDownComplete();
return false;
}
m_consumeSeconds++;
return true;
}
Text Control 控制代碼
HBRUSH CLoginDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = __super::OnCtlColor(pDC, pWnd, nCtlColor);
int nControlID = pWnd->GetDlgCtrlID();
switch (nControlID)
{
case IDC_COUNT_DOWN_MSG:
pDC->SetTextColor(RGB(100,100,100));
//pDC->SetBkColor(RGB(255,255,255));
pDC->SetBkMode(TRANSPARENT);
pDC->SelectObject(&m_countDownFont);
hbr = (HBRUSH)GetStockObject(NULL_BRUSH);
break;
}
return hbr;
}


uj5u.com熱心網友回復:
OnEraseBkgnd ?uj5u.com熱心網友回復:
能麻煩詳細說明一下嗎老師,Text控制元件需要重繪嗎?
ps:我的Text控制元件沒有重繪,透明背景是這句控制的
pDC->SetBkMode(TRANSPARENT);
uj5u.com熱心網友回復:
hbr = (HBRUSH)GetStockObject(NULL_BRUSH);表示 不擦除 背景, 當然 重疊(30 與 2x) 了
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/124007.html
標籤:界面
上一篇:GDI+多執行緒
