CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2008
    Posts
    85

    Progress bar wont show >_<!

    i am making an app which when you start it, it displays an intro screen (Splash Screen within the dialog it self)

    using the on ShowWindow message,but after that splash is displayed it will display another screen loading all the resources for the app and showing the % in a Progress bar.

    If i set up my progress bar and then show it,it displays correctly but when i try to increment it with StepIt,it doesn't want to show the new value (%).

    Code:
    Code:
    void CEveControlDlg::OnShowWindow(BOOL bShow, UINT nStatus)
    {
    	CDialog::OnShowWindow(bShow, nStatus);
    
    	//show window and show intro image
    	this->SetRedraw(TRUE);
    	m_Intro.ShowWindow(TRUE);
    	m_Intro.UpdateWindow();
    	Sleep(3000);
    	m_Intro.ShowWindow(FALSE);
    	HBITMAP Loading = (HBITMAP)LoadImage(0,"Loading.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
    	m_Loading.SetBitmap(Loading);
    	m_Loading.ShowWindow(TRUE);
    	m_Loading_Prcnt.ShowWindow(TRUE);
    	m_Loading_Prcnt.SetRange(0,100);
    	m_Loading_Prcnt.SetStep(20);
    	m_Loading_Prcnt.StepIt();
    	//show Loading screen and start loading resources
    }
    if i set this way
    Code:
    	m_Loading_Prcnt.SetRange(0,100);
    	m_Loading_Prcnt.SetStep(20);
    	m_Loading_Prcnt.StepIt();
            m_Loading_Prcnt.ShowWindow(TRUE);
    it displays the first 20% right but doesn't want to update to 40% when i later call StepIt again after ShowWindow has been called.

    and if i do it this way
    Code:
    m_Loading.ShowWindow(TRUE);
    	m_Loading_Prcnt.ShowWindow(TRUE);
    	m_Loading_Prcnt.SetRange(0,100);
    	m_Loading_Prcnt.SetStep(20);
    	m_Loading_Prcnt.StepIt();
    	m_Loading_Prcnt;
    it doesn't wan to even show on the screen.

    Can any one tell me what am i doing wrong?

    Help will be greatly appreciated.

  2. #2
    Join Date
    Nov 2003
    Posts
    2,185

    Re: Progress bar wont show >_<!

    Please use ShowWindow as designed using SW_SHOW instead of TRUE.

    Your second example does exactly what you want. Set a range of 0 - 100 (%). Then, you set the stepsize to 20. Then, you step once (from 0 -> 20%). Then, the function ends, so what is not working? If you call StepIt() twice, the progress bar will be 40 % (however, don't re-initialize the progress bar by setting its range).
    Last edited by Tischnoetentoet; March 25th, 2008 at 03:41 AM.

  3. #3
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: Progress bar wont show >_<!

    Your code is not pumping messages while performing the lengthy operation of loading resources etc. Unless your code pumps messages, including the all-important WM_PAINT message, you will not be able to see the result of your calls to StepIt().

    Lengthy operations are best performed as follows:

    - in a separate thread, or
    - for MFC apps, in small chunks in the OnIdle() function, or
    - in small chunks with calls to PeekMessage/DispatchMessage between each chunk

    Mike
    Last edited by MikeAThon; March 25th, 2008 at 11:43 AM.

  4. #4
    Join Date
    Jan 2008
    Posts
    85

    Re: Progress bar wont show >_<!

    Quote Originally Posted by Tischnoetentoet
    Please use ShowWindow as designed using SW_SHOW instead of TRUE.

    Your second example does exactly what you want. Set a range of 0 - 100 (%). Then, you set the stepsize to 20. Then, you step once (from 0 -> 20%). Then, the function ends, so what is not working? If you call StepIt() twice, the progress bar will be 40 % (however, don't re-initialize the progress bar by setting its range).
    Whats happening is that when the i start my app and the intro finishes to display and the loading screen appears,it wont show up the progress control.

    It shows the BG imageControl but doesn't show the progress control,but if i hide the middle of my apps screen,and get it back up it only draws the part that was hided and the part that wan sent still hided.

    I need to redraw the screen so the progress bar shows.

    here is a screen so u can see what i mean:


    This is the loading screen with the progress hided(how it normally loads)



    this is what i do to hide the app screen so it redraws part of the bar.


    and this is the app with half the bar redrawn after i move it up.



    Hope those images helped in explaining my prob.


    Help will be appreciated.
    Last edited by I_want_to_learn; March 25th, 2008 at 07:52 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured