Hi everyone!
I wrote code for the progress bar but the thing is that it is just an empty bar and nothing goes on.
So how can make it update?
#include <windows.h>
#include <commctrl.h>
#include "Resource.h"
//---------------------------------------------------------------------------
RECT rcClient;
HWND hWnd;
HWND hProgress;
HWND hDlg;
HINSTANCE hInst;
int pb_pos;
LRESULT CALLBACK DlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
//---------------------------------------------------------------------------
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
hInst = hInstance;
DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1),
hWnd, reinterpret_cast<DLGPROC>(DlgProc));
pb_pos= SendMessage(hProgress, PBM_GETPOS, 0, 0);
pb_pos += 1; // increase
SendMessage(hProgress, PBM_SETPOS, pb_pos, 0);
SendMessage(hProgress, PBM_SETRANGE, 0, MAKELPARAM(0, 220));
return FALSE;
}
#define _AFXDLL
//---------------------------------------------------------------------------
LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg,
WPARAM wParam, LPARAM lParam)
{
INITCOMMONCONTROLSEX InitCtrlEx;
InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
InitCtrlEx.dwICC = ICC_PROGRESS_CLASS;
InitCommonControlsEx(&InitCtrlEx);
SendMessage(hProgress, PBM_SETRANGE, 0, MAKELPARAM(0, 220));
switch(Msg)
{
case WM_INITDIALOG:
SendMessage(hProgress, PBM_SETRANGE, 0, MAKELPARAM(0, 220));
hProgress=CreateWindowEx(0, PROGRESS_CLASS, NULL,
WS_CHILD | WS_VISIBLE | PBS_MARQUEE,
20, 20, 17, 260,
hWndDlg, NULL, hInst, NULL);
// SetTimer(hProgress, 1001, 1000, 0);
MessageBox(hWndDlg,L"Start the bar",L"Start the Bar",MB_OK);
pb_pos= SendMessage(hWndDlg, PBM_SETMARQUEE, 0, 0);
pb_pos += 1;
SendMessage(hWndDlg, PBM_SETPOS, pb_pos, 0);
SendMessage(hProgress, PBM_SETRANGE, TRUE, MAKELPARAM(0, 220));
SendMessage(hWnd, PBM_SETRANGE, TRUE, MAKELPARAM(0, 220));
//SendMessage(hWnd, PBM_SETSTEP, (WPARAM) 1, 0);
return TRUE;
case WM_COMMAND:
switch(wParam)
{
case IDOK:
EndDialog(hWndDlg, 0);
return TRUE;
case IDCANCEL:
EndDialog(hWndDlg, 0);
return TRUE;
}
break;
}
extern HINSTANCE g_hinst;
return FALSE;
}
I've linked the cmmctrl lib and dll.
I've attempted to use SendMessage function but it didn't work.