c++ win32 progress bar questions!

Started by
2 comments, last by Toonkides 19 years, 4 months ago
Well, I took it upon me to learn the progress bars so that I can implement a cool dialog box. Everything is going great and I initialized the progress bar, but i never called the createwindowEx for it--is that necessary? Seems like an easy problem, but i've been stuck on it, and couldn't find anything on google or gamedev.net that describes how to properly create one. Thanks in advance Code listing:

BOOL CALLBACK AboutDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM 
	INITCOMMONCONTROLSEX InitCtrlEx ;


	InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX) ;
	InitCtrlEx.dwICC  = IDC_PROGRESS ;
	InitCommonControlsEx(&InitCtrlEx) ;

	switch(message)
	{
	case WM_INITDIALOG :
		SendMessage(hDlg, PBM_SETRANGE, 0, MAKELPARAM(0, 100)) ;
		return TRUE ;

	case WM_COMMAND :
		switch(wParam)
		{
		case IDOK :
		case IDCANCEL :
			EndDialog(hDlg, 0) ;
			return TRUE ;

		case IDC_BUTTON1 :
			SendMessage(hDlg, PBM_SETPOS, (WPARAM) (int) 15, 0) ;
			return TRUE ;
		}
		break ;
	}
	return FALSE ;
}

Advertisement
I am 90% confident that my problem is in creating the handle to the progress bar and actually creating the progress bar.

I have the progress bar initialized but no where did I create it.

I believe the code looks like this:
hProgress = CreateWindowEx(0, PROGRESS_CLASS, (LPSTR) NULL, 						WS_CHILD | WS_VISIBLE,						 20, 220, 200, 20,						 hDlg, (HMENU) 0, hInstance, NULL); 


the 4 values 20, 220, 200, 20 indicate where it will show up on the window, but if i'm using a dialog then I'm not quite sure how I use these points.. I noticed that everything can be visually created with vc++ does this mean that I need to still CreateWindowEx ? I'm confused

tia
Maybe This will help.

You can see what is returned from the creation function or call:
char buffer[256];				FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,0,GetLastError(),MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),buffer,256,0);MessageBox(hwnd,buffer,"Error",MB_OK|MB_ICONERROR);
problem solved!

ty:-)

This topic is closed to new replies.

Advertisement