无法更改进度控制的颜色

编程入门 行业动态 更新时间:2024-10-28 08:21:14
本文介绍了无法更改进度控制的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我创建了一个Progress控件,并通过向导创建了[CProgressCtrl m_pro]。 我想改变Progress Control的颜色,所以我在CxxxDlg :: OnInitDialog中添加了代码: COLORREF clrBar = RGB(255,0,0); m_pro.SendMessage(PBM_SETBARCOLOR,0,(LPARAM)clrBar); 但它不起作用......颜色没变。 我错过了什么(也许是Progress Control的属性)? 感谢您的帮助, 谢谢!

Hi all, I have created a Progress control, and created [CProgressCtrl m_pro] by Wizard. I want to change the color of Progress Control so I added the code in CxxxDlg::OnInitDialog : COLORREF clrBar = RGB(255, 0, 0); m_pro.SendMessage(PBM_SETBARCOLOR, 0, (LPARAM) clrBar); But it's not working...The color was not change. Did I miss something(maybe the attribute of Progress Control)? Thanks for your help, thank you!

推荐答案

这是启用C ++ Visual-Styles的代码 $ b stdafx.h中的$ b: Here is the Code to enable Visual-Styles for C++ in stdafx.h: #include <commctrl.h> #pragma comment (lib, "comctl32.lib ") // Ensure that version 6 of ComCtl32.dll is used: #pragma comment(linker, "\"/manifestdependency:type='win32'\ name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \ processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

BOOL CMyApp::InitInstance() { INITCOMMONCONTROLSEX CommonControls; CommonControls.dwSize = sizeof (INITCOMMONCONTROLSEX); CommonControls.dwICC = ICC_STANDARD_CLASSES; InitCommonControlsEx (&CommonControls); ... return TRUE; }

您需要使用SendMessage API向进度条控件发送消息。 这是一个答案 [ ^ ]如何改变颜色。 第二次看它虽然它几乎与你正在做的一样,所以你可能需要添加这样的东西来禁用你的进度条的主题。你必须包括uxtheme.h和uxtheme.lib ... You need to send a message to the progressbar control using the SendMessage API. Here is an answer[^] on StackOverflow that shows pretty well how to change the color. On second look though its almost exactly the same that you are doing, so you may need to add something like this to disable themeing for your progress bar. You will have to include uxtheme.h and uxtheme.lib... SetWindowTheme(hwndProg, _T(""), _T(""));

其中 hwndProg 是进度条的HWND句柄。

Where hwndProg is the HWND handle of your progress bar.

不是100%肯定,但请查看与此相关的Application.EnableVisualStyles Not 100% sure, but check out Application.EnableVisualStyles with regards to this

更多推荐

无法更改进度控制的颜色

本文发布于:2023-11-09 03:02:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571219.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:进度   颜色

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!