I’ve done a lot of programming over the years, but not very much on client applications. My history is primarily with server applications and test code which in many cases only has an input file as UI or better still a SQL connection string. So I wrote a progress bar today. They’re not too hard and MSDN actually has an ok resource on how to build one *gasp* with example code!
I ended up not using that exact variation but came close. This part is what gave me the most trouble, although it wasn’t that much.
SendMessage(hwndPB, PBM_SETRANGE, 0, MAKELPARAM(0, cb / 2048));
SendMessage(hwndPB, PBM_SETSTEP, (WPARAM) 1, 0);
The above code assumes you call the following which increments the bar by the 3rd parameter of the PBM_SETSTEP call.
SendMessage(hwndPB, PBM_STEPIT, 0, 0);
However this didn’t appear to work for me. My bar didn’t move at all when I called SendMessage with a PBM_STEPIT, so I used PBM_ without calling the SendMessage with PBM_SETRANGE. This is easy because without that cal the progress bar defaults to min/max of 0 to 100. This way I had just a handful of places in my code where I wanted to advance the bar to specific intervals because the code inbetween was not equal in it’s progressness. So using the following I was able to explicitly set my progress bar where the 3rd argument is a value from 0 to 100.
SendMessage(hwndPB, PBM_SETPOS, 10, 0);
This is a pretty simple implementation and I would probably use a variable in place of the 10 if it were more complex, but I only made 5 calls, so this works for now. The MSDN article covers the rest pretty well including styles and dialog options.