|
Programming Guru
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 
|
Well I can't test it here, but try something like: (don't forget to inlude the lib)
#include <windows.h>
#include <commctrl.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
/* Global var */
char * className = "ProgressbarApp";
char * captionName = "Progressbar Application";
HINSTANCE hInstanceGlobal;
/* Function prototypes */
int APIENTRY WinMain( HINSTANCE, HINSTANCE, LPSTR, int );
BOOL InitApplication( HINSTANCE );
BOOL InitInstance( HINSTANCE, int );
LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
MSG msg;
hInstanceGlobal= hInstance;
if (!InitApplication(hinstance))
return FALSE;
if (!InitInstance(hinstance, nCmdShow))
return FALSE;
while((GetMessage(&msg, NULL, 0, 0)) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
/* Initialise Application */
BOOL InitApplication( HINSTANCE hinstance )
{
WNDCLASS WndClass;
WndClass.style = 0;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.lpfnWndProc = WndProc;
WndClass.hInstance = hInstance;
WndClass.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndClass.lpszMenuName = NULL;
WndClass.lpszClassName = className;
return RegisterClass(&WndClass);
}
BOOL InitInstance( HINSTANCE hInstance, int nCmdShow )
{
HWND hWnd = CreateWindow(className, captionName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
if(!hWnd)
return FALSE;
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch(msg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_CREATE:
void OnWmCreate(hInstanceGlobal, hwnd);
break;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED)
{
if(LOWORD(wParam) == 1)
{
OnButtonClicked();
}
}
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
}
void OnWmCreate( HINSTANCE hInstance, HWND hwnd )
{
HWND hButton;
RECT rcClient;
HWND hwndPB;
hButton = CreateWindow("BUTTON", "Increment", WS_CHILD | WS_VISIBLE | BS_PUSBUTTON, 100, 100, 100, 100, hwnd, (HMENU) 1, hInstanceGlobal, NULL);
InitCommonControls();
GetClientRect(hwndParent, &rcClient);
hwndPB = CreateWindowEx(0, PROGRESS_CLASS, (LPCTSTR) NULL, WS_CHILD | WS_VISIBLE,
rcClient.left, rcClient.bottom, rcClient.right - rcClient, rcClient.top - rcClient.bottom,
hwnd, (HMENU) 0, hInstance, NULL);
SendMessage(hwndPB, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
SendMessage(hwndPB, PBM_SETSTEP, (WPARAM) 20, 0);
DestroyWindow(hwndPB);
}
void OnButtonClicked()
{
SendMessage(hwndPB, PBM_STEPIT, 0, 0);
} Got to run now, I'll help you later if it doesnt work 
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
|