We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Adding Progress Control gives assertion failure

thanesh
thanesh asked
on
Medium Priority
312 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,
Comment
Watch Question

Author

Commented:
Hmmm... the problem is m_progress is null.  Why?

Author

Commented:
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.
CERTIFIED EXPERT
Top Expert 2012
Commented:
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?

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
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.  

Author

Commented:
When I add the progress control through resource editor, and then use Create to create a Progress Control, I have two of them.

Author

Commented:
I am doing 'Create' to  create the dialog instead of DoModal().  Do you know if this has something to do with it.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.