Sign in to follow this  
Toonkides

c++ win32 progress bar questions!

Recommended Posts

Toonkides    122
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 ;
}

Share this post


Link to post
Share on other sites
Toonkides    122
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

Share this post


Link to post
Share on other sites
Xiachunyi    556
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);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this