Creating a progress window
Been a while since I had a problem bad enough to need to post it here. I guess that's a good sign :). Anyway, I'm creating a window class and supporting functions for a window that will pop up and show a progress bar and a cancel button. I'm writing it so it will be able to be draw inside of another window as well as in it's own window. I've gotten to the point where by calling the create function I should at least be seeing something, but no matter what I try I can't get what I have so far to display anything at all. I've tried messing with it numerous ways, but it just won't show any signs of working. I posted below the full code I have written for this. Can anyone here figure out what I'm doing wrong?
Code:
//Include files////////////////////////////////////////////////////////////////////////////
#include "global_definitions.h"
#include <windows.h>
#include <commctrl.h>
#include "debug.h"
#include "memory.h"
#include "window_classes.h"
///////////////////////////////////////////////////////////////////////////////////////////
//Function prototypes//////////////////////////////////////////////////////////////////////
//Progress Window
//Usage Notes:
//
//First, Initialize the progress window class be calling InitProgressWindowClass
//Before calling a funtion that uses a progress routine, call CreateProgressWindow and
//save the return to a HWND variable.
//When calling a funtion that uses a progress routine, pass CopyProgressRoutine as the
//routine and the address of the HWND from the previous step as the data pointer
void InitProgressWindowClass(void);
HWND CreateProgressWindow(HWND hWndParent, char * title, BOOL popup, RECT * progressCords);
void DestroyProgressWindow(HWND hWndProgress, BOOL cancel);
INT_PTR CALLBACK ProgressWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
DWORD CALLBACK CopyProgressRoutine(LARGE_INTEGER TotalFileSize, LARGE_INTEGER TotalBytesTransferred, LARGE_INTEGER StreamSize, LARGE_INTEGER StreamBytesTransferred, DWORD dwStreamNumber, DWORD dwCallbackReason, HANDLE hSourceFile, HANDLE hDestinationFile, LPVOID lpData);
///////////////////////////////////////////////////////////////////////////////////////////
//Function definitions/////////////////////////////////////////////////////////////////////
void InitProgressWindowClass(void)
{
WNDCLASSEX wc = {0};
//Register the progress window class
wc.cbSize = sizeof(wc);
wc.lpszClassName = "Progress Window";
wc.hInstance = GetModuleHandle(NULL);
wc.lpfnWndProc = ProgressWindowProc;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE);
wc.cbWndExtra = sizeof(PROGRESSINFO *);
RegisterClassEx(&wc);
}
HWND CreateProgressWindow(HWND hWndParent, char * title, BOOL popup, RECT * progressCords)
{
HWND hWndProgress;
DWORD dwStyle = WS_CHILD | WS_VISIBLE;
char * windowTitle = 0;
if(!windowTitle)
windowTitle = "";
if(popup)
dwStyle |= WS_OVERLAPPED;
else
dwStyle |= WS_DLGFRAME;
hWndProgress = CreateWindow(
"Progress Window",
windowTitle,
dwStyle,
progressCords->left,
progressCords->top,
progressCords->right - progressCords->left,
progressCords->bottom - progressCords->top,
hWndParent,
NULL,
GetModuleHandle(NULL),
&hWndParent);
return hWndProgress;
}
void DestroyProgressWindow(HWND hWndProgress, BOOL cancel)
{
}
INT_PTR CALLBACK ProgressWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
PROGRESSINFO * pip = (PROGRESSINFO *) GetWindowLongPtr(hWnd, GWL_USERDATA);
switch(uMsg)
{
case WM_NCCREATE:
SetWindowLongPtr(hWnd, GWL_USERDATA, (LONG) ClearMemAlloc(sizeof(PROGRESSINFO)));
return FALSE;
break;
case WM_CREATE:
pip->progressBar = CreateWindowEx(
0,
PROGRESS_CLASS,
NULL,
WS_CHILD | WS_VISIBLE,
0,
0,
50,
50,
hWnd,
0,
GetModuleHandle(NULL),
NULL);
return FALSE;
break;
case WM_DESTROY:
free((void *) GetWindowLongPtr(hWnd, GWL_USERDATA));
return FALSE;
break;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
DWORD CALLBACK CopyProgressRoutine(LARGE_INTEGER TotalFileSize, LARGE_INTEGER TotalBytesTransferred, LARGE_INTEGER StreamSize, LARGE_INTEGER StreamBytesTransferred, DWORD dwStreamNumber, DWORD dwCallbackReason, HANDLE hSourceFile, HANDLE hDestinationFile, LPVOID lpData)
{
return PROGRESS_CONTINUE;
}
///////////////////////////////////////////////////////////////////////////////////////////