Help: Update the Progress Bar 
Author Message
 Help: Update the Progress Bar

I'm using MFC to do a small routine with a standard progress bar.  I
saw some old posts in this ng with code for updating a progress bar,
such as:
CProgressCtrl *pMyBar = (CProgressCtrl *)GetDlgItem( IDC_YOURBAR);
pMyBar->SetRange(0 , 100);  // min 0 max 100
pMyBar->SetPos( 50 );  //half way
pMyBar->SetPos( 75 );  / 3/4 of the way ...

The problem is, I've created a separate class.  A button from the
window where the progress bar is located is calling a function of that
new class, which is actually doing all the work.  So, I have to update
the progress bar from that function, but since it's outside of my
CMyDlg, (CProgressCtrl*)GetDlgItem as shown above doesn't work.  Do I
have to use GetDlgItem(hwnd, ID) instead?  If so, how do I get the HWND
for the parent window (which happens to be the only main window in the
project)?  Is there another easier way of updating a progress bar.
This seems like it should be easy, yet I haven't worked with MFC much...

Thanks in advance.

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sat, 24 May 2003 03:00:00 GMT  
 Help: Update the Progress Bar
Add a pointer to your dialog class in your application class and access it
from any where
Is that help?

Ronen

Quote:

> I'm using MFC to do a small routine with a standard progress bar.  I
> saw some old posts in this ng with code for updating a progress bar,
> such as:
> CProgressCtrl *pMyBar = (CProgressCtrl *)GetDlgItem( IDC_YOURBAR);
> pMyBar->SetRange(0 , 100);  // min 0 max 100
> pMyBar->SetPos( 50 );  file://half way
> pMyBar->SetPos( 75 );  / 3/4 of the way ...

> The problem is, I've created a separate class.  A button from the
> window where the progress bar is located is calling a function of that
> new class, which is actually doing all the work.  So, I have to update
> the progress bar from that function, but since it's outside of my
> CMyDlg, (CProgressCtrl*)GetDlgItem as shown above doesn't work.  Do I
> have to use GetDlgItem(hwnd, ID) instead?  If so, how do I get the HWND
> for the parent window (which happens to be the only main window in the
> project)?  Is there another easier way of updating a progress bar.
> This seems like it should be easy, yet I haven't worked with MFC much...

> Thanks in advance.

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sat, 24 May 2003 03:00:00 GMT  
 Help: Update the Progress Bar
Hmm...a little, I guess.  I'm still not sure how to access Progress bar
functions...



Quote:
> Add a pointer to your dialog class in your application class and
access it
> from any where
> Is that help?

> Ronen




Quote:
> > I'm using MFC to do a small routine with a standard progress bar.  I
> > saw some old posts in this ng with code for updating a progress bar,
> > such as:
> > CProgressCtrl *pMyBar = (CProgressCtrl *)GetDlgItem( IDC_YOURBAR);
> > pMyBar->SetRange(0 , 100);  // min 0 max 100
> > pMyBar->SetPos( 50 );  file://half way
> > pMyBar->SetPos( 75 );  / 3/4 of the way ...

> > The problem is, I've created a separate class.  A button from the
> > window where the progress bar is located is calling a function of
that
> > new class, which is actually doing all the work.  So, I have to
update
> > the progress bar from that function, but since it's outside of my
> > CMyDlg, (CProgressCtrl*)GetDlgItem as shown above doesn't work.  Do
I
> > have to use GetDlgItem(hwnd, ID) instead?  If so, how do I get the
HWND
> > for the parent window (which happens to be the only main window in
the
> > project)?  Is there another easier way of updating a progress bar.
> > This seems like it should be easy, yet I haven't worked with MFC
much...

> > Thanks in advance.

> > Sent via Deja.com http://www.deja.com/
> > Before you buy.

Sent via Deja.com http://www.deja.com/
Before you buy.


Sun, 25 May 2003 03:00:00 GMT  
 Help: Update the Progress Bar
...nor do I really understand how to do this.  I'm very new to MFC, so
any code examples would be appreciated.



Quote:
> Add a pointer to your dialog class in your application class and
access it
> from any where
> Is that help?

> Ronen




Quote:
> > I'm using MFC to do a small routine with a standard progress bar.  I
> > saw some old posts in this ng with code for updating a progress bar,
> > such as:
> > CProgressCtrl *pMyBar = (CProgressCtrl *)GetDlgItem( IDC_YOURBAR);
> > pMyBar->SetRange(0 , 100);  // min 0 max 100
> > pMyBar->SetPos( 50 );  file://half way
> > pMyBar->SetPos( 75 );  / 3/4 of the way ...

> > The problem is, I've created a separate class.  A button from the
> > window where the progress bar is located is calling a function of
that
> > new class, which is actually doing all the work.  So, I have to
update
> > the progress bar from that function, but since it's outside of my
> > CMyDlg, (CProgressCtrl*)GetDlgItem as shown above doesn't work.  Do
I
> > have to use GetDlgItem(hwnd, ID) instead?  If so, how do I get the
HWND
> > for the parent window (which happens to be the only main window in
the
> > project)?  Is there another easier way of updating a progress bar.
> > This seems like it should be easy, yet I haven't worked with MFC
much...

> > Thanks in advance.

> > Sent via Deja.com http://www.deja.com/
> > Before you buy.

Sent via Deja.com http://www.deja.com/
Before you buy.


Sun, 25 May 2003 03:00:00 GMT  
 Help: Update the Progress Bar
1) Add the dialog class as a member of your App class.

CMyApp
{
    public:

    CMyDlg*    m_pDlg;

Quote:
}

Create an instance of the dialog - maybe in the CMyApp constructor

2) When you need to show the dialog - do the following:
    CMyApp* pApp = (CMyApp*)AfxGetApp();
    ASSERT(pApp);

    pApp->m_pDlg.DoModal();

3) Assuming you have the progress bar class as a member in your dialog
class, you can access this member and change
    the progress bar as you wish.

    pApp->m_pDlg.m_MyProgressBar.Set....

Hope this will help.

Ronen

Quote:

> ...nor do I really understand how to do this.  I'm very new to MFC, so
> any code examples would be appreciated.



> > Add a pointer to your dialog class in your application class and
> access it
> > from any where
> > Is that help?

> > Ronen



> > > I'm using MFC to do a small routine with a standard progress bar.  I
> > > saw some old posts in this ng with code for updating a progress bar,
> > > such as:
> > > CProgressCtrl *pMyBar = (CProgressCtrl *)GetDlgItem( IDC_YOURBAR);
> > > pMyBar->SetRange(0 , 100);  // min 0 max 100
> > > pMyBar->SetPos( 50 );  file://half way
> > > pMyBar->SetPos( 75 );  / 3/4 of the way ...

> > > The problem is, I've created a separate class.  A button from the
> > > window where the progress bar is located is calling a function of
> that
> > > new class, which is actually doing all the work.  So, I have to
> update
> > > the progress bar from that function, but since it's outside of my
> > > CMyDlg, (CProgressCtrl*)GetDlgItem as shown above doesn't work.  Do
> I
> > > have to use GetDlgItem(hwnd, ID) instead?  If so, how do I get the
> HWND
> > > for the parent window (which happens to be the only main window in
> the
> > > project)?  Is there another easier way of updating a progress bar.
> > > This seems like it should be easy, yet I haven't worked with MFC
> much...

> > > Thanks in advance.

> > > Sent via Deja.com http://www.deja.com/
> > > Before you buy.

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sun, 25 May 2003 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Help: Updating a Progress Bar

2. How to update a Progress bar from different class

3. update progress bar in a popup dialog

4. update progress bar

5. Updating modal progress bar

6. Progress bar not showing visual progress

7. Showing file loading/saving progress in progress bar?

8. progress bar on a status bar

9. progress bar on a status bar

10. Progress bar is not showing on status bar

11. Progress Bar in Status Bar Pane

12. Progress bar in status bar

 

 
Powered by phpBB® Forum Software