VC中改变EDIT控件的文本颜色
发布时间:2017年12月4日 作者:sieye 查看次数:1130
VC中改变EDIT控件的文本颜色,在对话框窗口过程的回调函数中加入WM_CTLCOLOREDIT消息进行处理。如EDIT控件为IDC_EDIT1: BOOL CALLBACK mWndProc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam) { int wmId, wmEvent; switch(message) { case WM_CLOSE: EndDialog(hDlg,NULL); break; case WM_INITDIALOG: break; case WM_CTLCOLOREDIT: { int t_CtrlID; t_CtrlID=::GetDlgCtrlID((HWND)lParam); if(t_CtrlID==IDC_EDIT1) { ::SetTextColor((HDC)wParam,RGB(255,0,0)); ::SetBkMode((HDC)wParam,TRANSPARENT); } } break; case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); switch (wmId) { case IDC_BUTTON1: break; default: return DefWindowProc(hDlg, message, wParam, lParam); } break; default: return(FALSE); } return(TRUE); }
|
|
|