开发者

Cannot implement meter in windows API

开发者 https://www.devze.com 2023-01-14 15:46 出处:网络
I am using the windows API (in C++) to create a windows application. Now, I have a progress bar which I want to show like a meter. A meter is blue and has no animation. I cannot figure out how to imp

I am using the windows API (in C++) to create a windows application.

Now, I have a progress bar which I want to show like a meter. A meter is blue and has no animation. I cannot figure out how to implement this, and if I have to, I will just settle for the usual green progress bar.

Please help.

EDIT: At least, is it possible to disable the animation (highlight the slides across the filled section of the bar)?

EDIT2:

Here is the C++ solution if anyone else is having this problem:

PAINTSTRUCT ps;
HDC hDC = BeginPaint(hwnd,&ps);
RECT r;
HTHEME theme = OpenThemeData(hwnd,L"PROGRESS");
SetRect(&r,10,10,100,25);
DrawThemeBackground(theme,hDC,11,2,&r开发者_StackOverflow社区,NULL);
SetRect(&r,10,10,50,25);
DrawThemeBackground(theme,hDC,5,4,&r,NULL);
CloseThemeData(theme);
EndPaint(hwnd,&ps);


You can draw this style of progress bar with DrawThemeBackground(). You'll find the theme name, part and state numbers in my answer in this thread.


The built in control cannot do this... however, it's not like ProgressBar is a complicated control. If you want nothing but a blue rectangle, use DrawRect and draw a blue rectangle.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号