The wyDay blog is where you find all the latest news and tips about our existing products and new products to come.
This will be another easy tip because all the work is already done and wrapped up in a nice little control. Its open source and handles all of the details, get it here.
Progress bars in Windows 7 are nearly identical to what they were in Windows Vista. Theyre green, animated and have 3 states: Normal, Error, and Paused:
To get both the 3-state progress bar (regular, error, and paused) along with the taskbar progress bar we need to use some Windows API. The easier of the two to implement is changing the state of the progress bar. This works on Windows Vista and Windows 7:
[DllImport("user32.dll", CharSet = CharSet.Auto)]
internal static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam); SetPaused()
// 0x410 = PBM_SETSTATE
// 0x0003 = PBST_PAUSE
SendMessage(progressBar.Handle, 0x410, 0x0003, 0);
// 0x0002 = PBST_ERROR
SendMessage(progressBar.Handle, 0x410, 0x0002, 0);
// 0x0001 = PBST_NORMAL
SendMessage(progressBar.Handle, 0x410, 0x0001, 0);
Then theres the matter of the taskbar progress bar in Windows 7. You can download the Windows7ProgressBar source code (zip file) to see how I did it, but the gist of it is you need to implement the ITakbarList3 Interface, and then use the SetProgressState to set the state (Normal, Error, Paused, or Marquee) and SetProgressValue to set the value.
Join me Monday when I talk about Drag & Drop icons. See the full list of articles in the series.
Subscribe to our blog's RSS Feed or follow Wyatt (CEO of wyDay) on Mastodon (@firstname.lastname@example.org) to keep up-to-date with our latest posts.