CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 1999
    Posts
    1

    a strange problem about CSpinButtonCtrl?

    I wrote a dialog based app with Visual C++ 6.0.In CAboutDlg class, I use Resource Editor to add a CSpinButtonCtrl control.It's ID is ID_SPIN1.In ClassWizard,I attach a Member Variable to it.The variable's type is CSpinButtonCtrl and it's name is m_spin1.I wrote the code:

    CAboutDlg aboutdlg;
    aboutdlg.m_spin1.SetRange(1,31);//cause assertion failure
    aboutdlg.DoModal();



    I can complied it with no error.But when I run these code,any member function of CSpinButtonCtrl will cause assertion failure.Perhaps put these code in aboutdlg.OnInitDialog member function will not cause error,but I can't.Because I must set and get the CSpinButtonCtrl control's data in a generic class.Please help me!


  2. #2
    Join Date
    Apr 1999
    Location
    Germany
    Posts
    418

    Re: a strange problem about CSpinButtonCtrl?

    Hi,

    SetRange requires that the window of CSpinButtonCtrl is actually created, and the member control variable is connected with it. This is done after DoDataExchange is called. So you can't call SetRange before the base implementation of OnInitDialog is called, which will call DoDataExchange.

    The only solution is to set a member variable of your dialog class, and then call SetRange in your implementation of OnInitDialog.

    Martin

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