Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Adding Progress Control gives assertion failure

Posted on 2006-03-28
6
Medium Priority
?
286 Views
Last Modified: 2008-02-01
Hi Experts,

I am trying to add a progress control to a simple dialog.  This is what I have done!
1. I added a Progress Control to a dialog.  
2. Using Class Wizard, I created a member variable for that control.( m_progress)
3. In the OnInitDialog( ) member function of that dialog class,
  m_progress.SetRange(0,100)
When I launch the app, it is giving assertion failure.

This is where it is failing.

_AFXCMN_INLINE void CProgressCtrl::SetRange(short nLower, short nUpper)
      { ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, PBM_SETRANGE, 0, MAKELPARAM(nLower, nUpper)); }

Why would I get this error.  Actually, calling m_progress.SetStep() also gives assertion failure.  My application is a Control Panel Applet, if that has anything to do with it.

Thanks,
0
Comment
Question by:thanesh
  • 5
6 Comments
 
LVL 1

Author Comment

by:thanesh
ID: 16315315
Hmmm... the problem is m_progress is null.  Why?
0
 
LVL 1

Author Comment

by:thanesh
ID: 16315767
If I do:

m_progress.Create(WS_CHILD | WS_VISIBLE, CRect(30, 70, 310, 90), this,0x16);
instead of adding the control through the resource editor it works.
0
 
LVL 86

Accepted Solution

by:
jkr earned 750 total points
ID: 16317401
If you never create the control, the 'm_hWnd' value will not be initialized, so adding the above line will fix that. BTW, why aren't you using a predefined control ID?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:thanesh
ID: 16322114
OK.  But, when I insert an EditBox control, for example, from the Resource editor I do not have to do call Create.  Then why for this ProgressCtrl I have to do it.  

0
 
LVL 1

Author Comment

by:thanesh
ID: 16322180
When I add the progress control through resource editor, and then use Create to create a Progress Control, I have two of them.
0
 
LVL 1

Author Comment

by:thanesh
ID: 16322395
I am doing 'Create' to  create the dialog instead of DoModal().  Do you know if this has something to do with it.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question