win32 edit control字体颜色

win32 edit control字体颜色
INT_PTR CALLBACK MainUI::MainUIProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{   
	MainUI* pMainUI = (MainUI*)GetWindowLongPtr(hDlg, GWLP_USERDATA);
	switch (message)
	{
		case WM_CTLCOLOREDIT:
		{
			if ((HWND)lParam == GetDlgItem(pMainUI->GetHWND(),IDC_EDIT_TRADE_MSG)&&pMainUI->bTradeError)
			{
				SetTextColor((HDC)wParam,RGB(255,0,0));
				SetBkMode((HDC)wParam, OPAQUE); 
				return (INT_PTR)GetStockObject(NULL_BRUSH);
			}
			else if ((HWND)lParam == GetDlgItem(pMainUI->GetHWND(),IDC_EDIT_QUOTE_MSG)&& pMainUI->bQuotesError)
			{
				SetTextColor((HDC)wParam,RGB(255,0,0));
				SetBkMode((HDC)wParam, OPAQUE); //
				//SetBkMode((HDC)wParam, TRANSPARENT); //文字的背景透明
				//return (INT_PTR)CreateSolidBrush(RGB(0xee,0xee,0xc4));
				return (INT_PTR)GetStockObject(NULL_BRUSH);
			}
			return NULL;
			
		}
	}


注意:
1)改颜色时要在消息处理中,在别的地方无效
2)OPAQUE和TRANSPARENT的区别,(TRANSPARENT时感觉毛毛的,是否我的代码有问题)
3)必须返回一个画刷

你可能感兴趣的:(Win32)