Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Windows
 Charting and Real-Time Graphics Tools for Windows
 MFC Chapter 5 Tutorial in
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Kyle.IBT

5 Posts

Posted - 13 Feb 2008 :  14:29:07  Show Profile  Reply with Quote
Hello-

I'm building the tutorial in chapter 5 of the MFC Graphics Libraries manual. I get an Access violation exception calling WGLinePlot in the BuildGraph method. I've tracked this to a call that the parent class QCGraphWnd makes to WGLinePlot which includes as a parameter a handle to a device context (q_hdc). I have closely looked over my code and it does not deviate from the chapter 5 tutorial. Can you please help me track down this error? You can download my project from https://jshare.johnshopkins.edu/kfritz1/kf_web/TEST1KF.zip

Error:
"Unhandled exception at 0x1003a4b5 in TEST1.exe: 0xC0000005: Access violation reading location 0x0014fffc."

Thank-you
Kyle

Kyle Fritz
Infinite Biomedical Technologies

Kyle.IBT

5 Posts

Posted - 13 Feb 2008 :  14:31:21  Show Profile  Reply with Quote
FYI:

Using Visual Studio 2008, Microsoft Visual C++ 2008

Kyle Fritz
Infinite Biomedical Technologies
Go to Top of Page

quinncurtis

1164 Posts

Posted - 13 Feb 2008 :  15:59:00  Show Profile  Reply with Quote
Congratulations, you did all the hard stuff correctly. The only error is in the for loop that initializes the data. You are starting the for loop at 1. This leaves the value of lpX1[0] and lpY1[0] uninitialized, which does not mean, as many think, the value will be 0.0. Instead it is a random collection of bytes that may or may not be a valid real number. We usually refer to those types of values as garbage values, and they cannot be processed by our software.

CTEST1Doc::CTEST1Doc()
{
  // TODO: add one-time construction code here
  //------------QWC CODE TILL END
  //allocate global data arrays
  lpX1 = new realtype[NUMP];
  lpY1 = new realtype[NUMP];

  //simulate x,y
  for(int i=1; i<NUMP;i++)
  {
    lpX1[i]=(realtype) i;
    lpY1[i]=15*cos(M_PI * i / 4.0);
  }
  //Create new static data set
  pDataSet = new QCStaticData( "60 Cyc Noise", lpX1, lpY1, NUMP);
}


Change to:

CTEST1Doc::CTEST1Doc()
{
  // TODO: add one-time construction code here
  //------------QWC CODE TILL END
  //allocate global data arrays
  lpX1 = new realtype[NUMP];
  lpY1 = new realtype[NUMP];

  //simulate x,y
  for(int i=0; i<NUMP;i++)
  {
    lpX1[i]=(realtype) i;
    lpY1[i]=15*cos(M_PI * i / 4.0);
  }
  //Create new static data set
  pDataSet = new QCStaticData( "60 Cyc Noise", lpX1, lpY1, NUMP);
}
Go to Top of Page

Kyle.IBT

5 Posts

Posted - 13 Feb 2008 :  16:46:16  Show Profile  Reply with Quote
Thanks a lot. How careless of me.....

Kyle Fritz
Infinite Biomedical Technologies
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07