VC++進度條process Bar的用法實例。本站提示廣大學習愛好者:(VC++進度條process Bar的用法實例)文章只能為提供參考,不一定能成為您想要的結果。以下是VC++進度條process Bar的用法實例正文
本文實例講述了VC進度條的用法實例,分享給年夜家供年夜家參考。詳細完成代碼以下:
#include <Windows.h>
#include "resource.h"
#include <Commctrl.h>
//對話框函數
INT_PTR CALLBACK DialogProc(
__in HWND hwndDlg,
__in UINT uMsg,
__in WPARAM wParam,
__in LPARAM lParam
)
{
switch (uMsg)
{
case WM_INITDIALOG:
{
//初始化進度條控件
HWND hWndProcess = ::GetDlgItem(hwndDlg, IDC_PROGRESS1);
//設置規模(0, 100)
::SendMessage(hWndProcess, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
//設置步進年夜小
::SendMessage(hWndProcess, PBM_SETSTEP, 2, 0);
//設置配景色
::SendMessage(hWndProcess, PBM_SETBKCOLOR, 0, RGB(0,0,0xff));
//設置進度條色彩
::SendMessage(hWndProcess, PBM_SETBARCOLOR, 0, RGB(0xff,0,0));
}
break;
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case IDOK:
{
//增長進度值, 增長的數值為後面設置的步長值
::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
)
{
::DialogBoxParam(hInstance, (LPCTSTR)IDD_MAIN, NULL, DialogProc, NULL);
return 0;
}
願望本文所述對年夜家的VC++法式設計有所贊助。