Code   Information
Information Progress Bars.

A lot of people ask me "How the hell do I use progress bars in my C code?". No they don't, but I'll tell you anyway. It's easy, and here's how. This code snipet shows you (almost) all the calls you need. Have a look.

   
  ...
#include "commctrl.h"
...
int WINAPI WinMain(...){
     ...
     InitCommonControls();
     ...
}
...
   SendDlgItemMessage(
     hWnd,
     IDC_BAR,
     PBM_SETRANGE,
     0,
     MAKELPARAM(90,270)
   );
...
   SendDlgItemMessage(
     hWnd,
     IDC_BAR,
     PBM_SETPOS,
     180,
     0L
   );
...
 
     


So. You might get away with just using these two calls in your code. "PBM_SETRANGE" to set the extents of the bar, and "PBM_SETPOS" to set it's current position. But there are others, have a look in the Win32 Messages bit of your help file. Make sure to include the common controls library (comctl32.lib) in your project. Also, as with all cases of using MFC type common controls in C programs, you've got to call "InitCommonControls()" or your dialog box won't work. Obviously you've got to have a progress bar control in your window with an ID of IDC_BAR.
 




G.E.M