Skip to main content
GameDev.net gamedev.net
🔒 Locked

progress bar in MFC

Started by jimywang Oct 14, 2004 at 8:30 AM 2 replies 650+ views
Original Post
jimywang
jimywang
here is the deal,i want to make a progress bar in my dll project.in this project I wont have any window,so basically what I wanna do is create a dialog box which is invisible.and create a CProgressCtrl as its child window.here is my code:

	CDialog pCDialog = new CDialog();
	CProgressCtrl pCProgressCtrl = new CProgressCtrl();

	pCDialog->Create(1000,NULL);
	
	RECT rect;
	rect.top = 20;
	rect.left = 20;
	rect.bottom = 60;
	rect.right = 100;

pCProgressCtrl->Create(WS_BORDER|WS_VISIBLE,rect,pCDialog,1001);

however I have a runtime error,everytime it is trying to create the pCDialog.Can someone give me some advice please?thanks in advance.
felisandria
felisandria
Try calling InitCommonControlsEx prior to creating the progress control. Also, is 1000 really a template resource you have set up somewhere, or did you just make it up, for the dialog?

-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
jimywang
jimywang
I did just made the 1000 up.is that gonna be a problem?I dont wanna include a resource just for the dialog,because I wont be using it anyway.I hope someone can tell me the easiest way to create a progress bar in MFC.thanks for the reply.
felisandria
felisandria
Well, the easy way is to make a little dialog with a progress control on it in your resource editor, and use that, really. Then call a create on that dialog, and access the progress control using GetDlgItem(ID_PROGRESS_CTRL or whatever you named it). If you really don't want to use a resource you can CreateDialogIndirect but that's kind of a pain in the rear because it just means you create the template in memory instead of making a couple of clicks on a resource editor.

Also you do realize that unless you do something funky like region clipping you're going to see the dialog anyway, right? Controls aren't really very good at just floating disembodied. Of course, you can remove the title bar off your dialog and make it about the same size as the progress control if you want.

-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.