使用WinXp通用控件时编辑控件背景色的奇怪行为 [英] Strange behaviour of edit control background color when using WinXp common controls

查看:88
本文介绍了使用WinXp通用控件时编辑控件背景色的奇怪行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个奇怪的问题(嗯,至少我发现它很奇怪=)).我正在编写自己的GUI库,该库是Windows api的包装(是的,我知道WTL和类似MFC =的框架).在当前阶段,我已经以这种方式封装了通用控件:例如,Edit类由一个简单窗口和一个位于其上方的标准编辑窗口(MainWindow-> GhostWindow-> EditBox)组成.例如,这就是我可以如何在编辑类本身内部更改编辑的背景颜色的方法:

myedit->SetBkColor ( RGB ( 0, 0, 0 ) );

它运行良好,直到我调用InitCommonControlsEx并将清单文件附加到我的程序中为止.完成此操作后,我的编辑仅在具有焦点时才能够更改颜色.老实说,我对为什么这样的行为以及我做错了事没有全面的想法,所以我将不胜感激.

谢谢,#535.

解决方案

好吧,一切都比我想的容易得多.我太不专心=(当一个人不使用样式时,一根手杖使用:: SetBkColor(...)更改背景色,然后从WM_CTLCOLOR *返回画笔以更改边框颜色.现在,:: SetBkColor(...)对应于 focus 颜色,返回的画笔会更改背景颜色.

I am having a strange problem ( well, at least i find it strange =) ). I am writing my own GUI library, which is a wrapper around windows api (and yes, i am aware of WTL and frameworks like MFC =) ). At the current stage i have incapsulated common controls in such manner: for example, Edit class consists of a simple window and an standard edit window above it ( MainWindow -> GhostWindow -> EditBox ). That is how i can for example change a background colour of an edit inside an edit class itself:

myedit->SetBkColor ( RGB ( 0, 0, 0 ) );

And it worked fine, until i called InitCommonControlsEx and attached manifest file to my program. After doing this, my edits become capable of changing colours only when they have focus. To be honest, i don't have a comprehensive thoughts about why do the behave like this and what am i doing wrong, so i will appreciate any help.

Thank you, #535.

解决方案

Well, everything is much easier, than i thought. I was just too inattentive =( When one don't use styling, one cane use ::SetBkColor(...) to change background colour, and return a brush from WM_CTLCOLOR* to change a border colour. Things become different after enabling styling. Now ::SetBkColor(...) correspond to focus colour and returning brush changes background colour. Shame on me =(

这篇关于使用WinXp通用控件时编辑控件背景色的奇怪行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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