Search code examples
c++windowsapiprogressmeter

Cannot implement meter in windows API


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,NULL);
SetRect(&r,10,10,50,25);
DrawThemeBackground(theme,hDC,5,4,&r,NULL);
CloseThemeData(theme);
EndPaint(hwnd,&ps);

Solution

  • 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.