1

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);
Alexander Rafferty
  • 6,134
  • 4
  • 33
  • 55

2 Answers2

1

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.

Community
  • 1
  • 1
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
0

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
  • 104,103
  • 58
  • 317
  • 552
  • it talks about meters in the msdn user expirience guide, but says nothing about its implementation. – Alexander Rafferty Sep 04 '10 at 02:37
  • @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 Sep 04 '10 at 03:09
  • 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 Sep 04 '10 at 04:56
  • 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 Sep 04 '10 at 13:30