Jump to content
  • Advertisement
Sign in to follow this  
jimywang

progress bar in MFC

This topic is 5389 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!