The example of this article tells the VC progress bar Usage example, shares for everybody reference. The specific implementation code is as follows:
Copy Code code as follows:
#include <Windows.h>
#include "resource.h"
#include <Commctrl.h>
dialog box functions
INT_PTR CALLBACK DialogProc (
__in HWND Hwnddlg,
__in UINT umsg,
__in WPARAM WPARAM,
__in LPARAM LPARAM
)
{
Switch (umsg)
{
Case WM_INITDIALOG:
{
Initializing progress bar controls
HWND hwndprocess =:: GetDlgItem (Hwnddlg, IDC_PROGRESS1);
Set Range (0, 100)
:: SendMessage (hwndprocess, Pbm_setrange, 0, Makelparam (0, 100));
Set Step size
:: SendMessage (Hwndprocess, Pbm_setstep, 2, 0);
Set Background color
:: SendMessage (hwndprocess, Pbm_setbkcolor, 0, RGB (0,0,0xff));
Set progress bar Color
:: SendMessage (hwndprocess, Pbm_setbarcolor, 0, RGB (0xff,0,0));
}
Break
Case WM_COMMAND:
{
Switch (LOWORD (wParam))
{
Case IDOK:
{
Increase the progress value and increase the value of the step that was set earlier
:: SendDlgItemMessage (Hwnddlg, Idc_progress1, pbm_stepit, 0, 0);
}
Break
Case IDCANCEL:
:: EndDialog (Hwnddlg, IDCANCEL);
return 0;
}
}
Break
}
return 0;
}
int WINAPI WinMain (
__in hinstance HInstance,
__in hinstance hPrevInstance,
__in LPSTR lpCmdLine,
__in int nCmdShow
)
{
::D Ialogboxparam (HINSTANCE, (LPCTSTR) idd_main, NULL, DIALOGPROC, NULL);
return 0;
}
I hope this article will help you with VC + + program design.