简体   繁体   English

使用WinXp通用控件时编辑控件背景色的奇怪行为

[英]Strange behaviour of edit control background color when using WinXp common controls

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 =) ). 我正在编写自己的GUI库,它是Windows api的包装(是的,我知道WTL和类似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 ). 在当前阶段,我已经以这种方式封装了通用控件:例如,Edit类由一个简单的窗口和一个位于其上方的标准编辑窗口(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. 它运行良好,直到我调用InitCommonControlsEx并将清单文件附加到程序中。 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. 谢谢#535

  1. When you attach the version 6 manifest, the call to InitcommonControlsEx becomes unnecessary. 当您附加版本6清单时,不需要调用InitcommonControlsEx。

  2. Anyway. 无论如何。 with the version 6 common controls loaded, XP theming is used even for the standard windows controls. 加载了版本6的通用控件后,XP主题设置甚至用于标准的Windows控件。 The background colors for the controls are painted using the xp-theme color, so the WM_CTLCOLOR* messages are used less. 控件的背景色是使用xp主题色绘制的,因此,使用WM_CTLCOLOR *消息较少。

  3. You are currently overriding the coolor of various control elements using the WM_CTLCOLOR* messages? 您当前正在使用WM_CTLCOLOR *消息覆盖各种控制元素的散热器吗?

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 =( 我太不专心=(当不使用样式时,一根手杖使用:: SetBkColor(...)更改背景颜色,然后从WM_CTLCOLOR *返回画笔以更改边框颜色。启用样式后,情况将有所不同现在:: SetBkColor(...)对应于焦点颜色,返回的画笔更改背景颜色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM