CTL_COLORSTATIC对所有控件都相同 [英] CTL_COLORSTATIC same for all controls

查看:76
本文介绍了CTL_COLORSTATIC对所有控件都相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就是我处理消息的方式:



This is how I'm handling the message :

case WM_CTLCOLORSTATIC:
	{
		if (GetDlgItem(hwnd, 155) == (HWND)lParam);
		{
			HDC hDC = (HDC)wParam;
			SetTextColor(hDC, RGB(255, 0, 0));
			return (LRESULT)GetStockObject(HOLLOW_BRUSH);
		}

		if (GetDlgItem(hwnd, 151) == (HWND)lParam || GetDlgItem(hwnd, 153) == (HWND)lParam);
		{
			HDC hDC = (HDC)wParam;
			SetTextColor(hDC, RGB(0, 0, 0));
			return (LRESULT)GetStockObject(HOLLOW_BRUSH);
		}
	}





以及如何创建静态文本标签:





And how static text labels are created :

EncoderLabel = CreateWindowEx(NULL, L"STATIC", L" Encoder ", WS_CHILD | WS_VISIBLE, 27, 50, 57, 16, hwnd,(HMENU)153, GetModuleHandle(NULL), NULL);

ChooseEncoding = CreateWindowEx(NULL, L"STATIC", L"Choose Encoding firstly !", WS_CHILD | WS_VISIBLE, 200 - (165/2), 37, 165, 16, hwnd,(HMENU)155, GetModuleHandle(NULL), NULL);

outputLabel = CreateWindowEx(NULL, L"STATIC", L" output ", WS_CHILD | WS_VISIBLE, 27, 240, 37, 16, hwnd,(HMENU)151, GetModuleHandle(NULL), NULL);







每个控件都以红色打印。无论哪个控件正在绘制,(HWND)lparam总是匹配第一个if并用红色绘制控件



因为我在另一个项目上工作了对我而言,面对这个问题实际上是非常不寻常的,常见的控制可能是导致这个问题的原因吗?我在TabControl上画它们,但它们不是Tabcontrol的孩子。此控件是主框架窗口的子窗口




Every control gets printed in red. Doesn't matter which control is being drawn, (HWND)lparam will always match the first if and paint the control in red

Since I got this working on another project, to me it's actually very unusual to face this problem, are common controls possibly the cause of this ? I'm painting them over a TabControl, but they're not Tabcontrol's child. This controls are child of the main frame window

推荐答案

Giggle。



从末尾删除分号if语句。



8 ^ P
Giggle.

Remove the semicolons from the end of the if statements.

8^P


这篇关于CTL_COLORSTATIC对所有控件都相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆