views:

66

answers:

2

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);
A: 

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.

Billy ONeal
it talks about meters in the msdn user expirience guide, but says nothing about its implementation.
Alexander Rafferty
@Alexander: I don't understand. If all you want is a rectangle, why do you need to make it more complicated. Am I missing something here?
Billy ONeal
it should look like a proper windows progress bar, but blue (and no animated). I'm fine using the green one, but it would be nice if someone knew how to get it like a meter (e.g. available disk space on my computer)
Alexander Rafferty
The progress bar's appearance depends on the particular operating system and theme. If you want it to look different, you will have to use a custom control.
Luke
+1  A: 

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.

Hans Passant
What do I pass to hTheme?
Alexander Rafferty
The return value of OpenThemeData(). The class name is "PROGRESS".
Hans Passant
awesome! it works perfectly.
Alexander Rafferty