
C:\Projects\110\ci110\DEV\CI110\V3200GrabBeeXplusDeluxe>fc dib.cpp ..\v3107\dib.cpp 
Comparing files Dib.cpp and ..\V3107\DIB.CPP
FC: no differences encountered


C:\Projects\110\ci110\DEV\CI110\V3200GrabBeeXplusDeluxe>fc dibdoc.cpp ..\v3107\dibdoc.cpp 
Comparing files Dibdoc.cpp and ..\V3107\DIBDOC.CPP
FC: no differences encountered


C:\Projects\110\ci110\DEV\CI110\V3200GrabBeeXplusDeluxe>fc dibview.cpp ..\v3107\dibview.cpp 
Comparing files Dibview.cpp and ..\V3107\DIBVIEW.CPP
FC: no differences encountered


C:\Projects\110\ci110\DEV\CI110\V3200GrabBeeXplusDeluxe>fc iresultdialog.cpp ..\v3107\iresultdialog.cpp 
Comparing files Iresultdialog.cpp and ..\V3107\IRESULTDIALOG.CPP
FC: no differences encountered


C:\Projects\110\ci110\DEV\CI110\V3200GrabBeeXplusDeluxe>fc mainfrm.cpp ..\v3107\mainfrm.cpp 
Comparing files Mainfrm.cpp and ..\V3107\MAINFRM.CPP
***** Mainfrm.cpp
#include <mmreg.h>
#include <msacm.h>    // Audio Compression Manager
#include "Eztwain.h"
***** ..\V3107\MAINFRM.CPP
#include <mmreg.h>
#include "Eztwain.h"
*****

***** Mainfrm.cpp
   unsigned short int ucnt,uval;
   unsigned int numwritten=0;
   bool bNoValue;
***** ..\V3107\MAINFRM.CPP
   unsigned short int ucnt,uval;
   bool bNoValue;
*****

***** Mainfrm.cpp
   UINT cbwh=sizeof(WAVEHDR);
   bool bFilesave=PARFlecksValue.bTESTOUT;
   while(1)
***** ..\V3107\MAINFRM.CPP
   UINT cbwh=sizeof(WAVEHDR);
   while(1)
*****

***** Mainfrm.cpp
            lParam = MAKELPARAM((WORD)n, (WORD)uDevType);
             //AfxMessageBox(wic.szPname, MB_ICONINFORMATION | MB_OK);
            if(strstr(wic.szPname,"USB EMP Audio Device")) //USB VideoBus II, Audio
            {
                                //AfxMessageBox("USB Audio Device", MB_ICONINFORMATION | MB_OK);
               /* if(wic.dwFormats&WAVE_FORMAT_1M08)AfxMessageBox("1M08", MB_ICONINFORMATION | MB_OK);
                if(wic.dwFormats&WAVE_FORMAT_1M16)AfxMessageBox("1M16", MB_ICONINFORMATION | MB_OK);
***** ..\V3107\MAINFRM.CPP
            lParam = MAKELPARAM((WORD)n, (WORD)uDevType);
            if(strstr(wic.szPname,"USB VideoBus II, Audio"))
            {
                /*if(wic.dwFormats&WAVE_FORMAT_1M08)AfxMessageBox("1M08", MB_ICONINFORMATION | MB_OK);
                if(wic.dwFormats&WAVE_FORMAT_1M16)AfxMessageBox("1M16", MB_ICONINFORMATION | MB_OK);
*****

***** Mainfrm.cpp
               wfx.nChannels=2;
               wfx.nSamplesPerSec=22050; //16000; 
               wfx.wBitsPerSample=16;
***** ..\V3107\MAINFRM.CPP
               wfx.nChannels=2;
               wfx.nSamplesPerSec=16000; 
               wfx.wBitsPerSample=16;
*****

***** Mainfrm.cpp
               mmr=waveInOpen( &hwi,n,&wfx,NULL,NULL,CALLBACK_NULL | WAVE_FORMAT_DIRECT );
               /*
               char MsgBuf[255];
               sprintf(MsgBuf,"waveInOpen mmr=%d",(int)mmr);
               AfxMessageBox( (LPCTSTR)MsgBuf,  MB_OK | MB_ICONINFORMATION );*/

               if(mmr==MMSYSERR_ALLOCATED)AfxMessageBox("waveInOpen Specified resource is already allocated.",MB_ICONINFORMATIO
 | MB_OK);
               if(mmr==MMSYSERR_BADDEVICEID)AfxMessageBox("waveInOpen Specified device identifier is out of range.",MB_ICONINFO
MATION | MB_OK);
               if(mmr==MMSYSERR_NODRIVER)AfxMessageBox("waveInOpen No device driver is present.",MB_ICONINFORMATION | MB_OK);
               if(mmr==MMSYSERR_NOMEM)AfxMessageBox("waveInOpen Unable to allocate or lock memory.",MB_ICONINFORMATION | MB_OK)

               if(mmr==WAVERR_BADFORMAT)AfxMessageBox("waveInOpen Attempted to open with an unsupported waveform-audio format."
MB_ICONINFORMATION | MB_OK);
               if(mmr==MMSYSERR_INVALPARAM)AfxMessageBox("waveInOpen Invalid parameter passed",MB_ICONINFORMATION | MB_OK);
  
***** ..\V3107\MAINFRM.CPP
               mmr=waveInOpen( &hwi,n,&wfx,NULL,NULL,CALLBACK_NULL | WAVE_FORMAT_DIRECT );

/*char MsgBuf[255];
sprintf(MsgBuf,"waveInOpen mmr=%d",(int)mmr);
AfxMessageBox( (LPCTSTR)MsgBuf,  MB_OK | MB_ICONINFORMATION );
 if(mmr==MMSYSERR_ALLOCATED)AfxMessageBox("Specified resource is already allocated.",MB_ICONINFORMATION | MB_OK);
if(mmr==MMSYSERR_BADDEVICEID)AfxMessageBox("Specified device identifier is out of range.",MB_ICONINFORMATION | MB_OK);
if(mmr==MMSYSERR_NODRIVER)AfxMessageBox("No device driver is present.",MB_ICONINFORMATION | MB_OK);
if(mmr==MMSYSERR_NOMEM)AfxMessageBox("Unable to allocate or lock memory.",MB_ICONINFORMATION | MB_OK);
if(mmr==WAVERR_BADFORMAT)AfxMessageBox("Attempted to open with an unsupported waveform-audio format.",MB_ICONINFORMATION | MB_O
);
if(mmr==MMSYSERR_INVALPARAM)AfxMessageBox("Invalid parameter passed",MB_ICONINFORMATION | MB_OK);

 */
  
*****

***** Mainfrm.cpp
               {
                  //AfxMessageBox("waveInOpen OK",MB_ICONINFORMATION | MB_OK);
                  for(whbuffer=0;whbuffer<MAXWAVCNT && mmr==MMSYSERR_NOERROR;whbuffer++)
***** ..\V3107\MAINFRM.CPP
               {
           
                  for(whbuffer=0;whbuffer<MAXWAVCNT && mmr==MMSYSERR_NOERROR;whbuffer++)
*****

***** Mainfrm.cpp
                  {
                     //AfxMessageBox("waveInPrepareHeader OK", MB_ICONINFORMATION | MB_OK);
                     for(whbuffer=0;whbuffer<MAXWAVCNT && mmr==MMSYSERR_NOERROR;whbuffer++)
***** ..\V3107\MAINFRM.CPP
                  {
                     //   AfxMessageBox("waveInPrepareHeader OK", MB_ICONINFORMATION | MB_OK);
                     for(whbuffer=0;whbuffer<MAXWAVCNT && mmr==MMSYSERR_NOERROR;whbuffer++)
*****

***** Mainfrm.cpp
                        {
                                                   //AfxMessageBox("waveInStart OK", MB_ICONINFORMATION | MB_OK);
                           if(testout){if(fclose(testout))AfxMessageBox("fclose error", MB_ICONINFORMATION | MB_OK);Sleep(10);}
***** ..\V3107\MAINFRM.CPP
                        {
                           if(testout){if(fclose(testout))AfxMessageBox("fclose error", MB_ICONINFORMATION | MB_OK);Sleep(10);}
*****

***** Mainfrm.cpp

                           if(PARFlecksValue.bTESTOUT&&bFilesave)
                              if((testout=fopen( "testout.wav", "wb" ))==NULL)AfxMessageBox("FileOpen error for testout.wav", M
_ICONINFORMATION | MB_OK);
                           strcpy(MsgBuf,"RIFF");
***** ..\V3107\MAINFRM.CPP

                           if(PARFlecksValue.bTESTOUT)
                           if((testout=fopen( "testout.wav", "wb" ))==NULL)AfxMessageBox("FileOpen error for testout.wav", MB_I
ONINFORMATION | MB_OK);
                           strcpy(MsgBuf,"RIFF");
*****

***** Mainfrm.cpp
                           {
                              if(mmr==MMSYSERR_NOERROR && PARFlecksValue.measure) //PARFlecksValue.measure tells us if we want 
o continue measuring PAR and sunflecks
                                                          {
                                                             // AfxMessageBox("filling buffer", MB_ICONINFORMATION | MB_OK);
                                 ucnt=0;
                                 bNoValue=FALSE;
                                 while(!(wh[whbuffer].dwFlags & WHDR_DONE) && (ucnt<100)){ucnt++;Sleep(100);}
                                                              //AfxMessageBox("Done filling buffer", MB_ICONINFORMATION | MB_OK
;
                                  //  sprintf(MsgBuf," 390 MAX timer ucnt %u",ucnt);
***** ..\V3107\MAINFRM.CPP
                           {
                           if(mmr==MMSYSERR_NOERROR && PARFlecksValue.measure) //PARFlecksValue.measure tells us if we want to 
ontinue measuring PAR and sunflecks
                           {
                              ucnt=0;
                              bNoValue=FALSE;
                              while(!(wh[whbuffer].dwFlags & WHDR_DONE) && (ucnt<390)){ucnt++;Sleep(100);}
                                  //  sprintf(MsgBuf," 390 MAX timer ucnt %u",ucnt);
*****

***** Mainfrm.cpp
                                  //  AfxMessageBox(MsgBuf, MB_ICONINFORMATION | MB_OK);
                                  //if(testout)ucnt=fwrite( (const void *)wavebuffer[whbuffer], sizeof( char ),  MAXWAV, testou
 );
                                  //  sprintf(MsgBuf,"Bytes written %u",ucnt);
***** ..\V3107\MAINFRM.CPP
                                  //  AfxMessageBox(MsgBuf, MB_ICONINFORMATION | MB_OK);
                              //if(testout)ucnt=fwrite( (const void *)wavebuffer[whbuffer], sizeof( char ),  MAXWAV, testout );

                                  //  sprintf(MsgBuf,"Bytes written %u",ucnt);
*****

***** Mainfrm.cpp
   
                                 //PARFlecksValue.bTESTOUT=FALSE;  //if(whbuffer==3)
                                 if(!(wh[whbuffer].dwFlags & WHDR_DONE))
                                 {
                                    AfxMessageBox("Wave did not fill buffers.", MB_ICONINFORMATION | MB_OK);
                                                                    //Sleep(4000);
                                    if(testout)ucnt=fwrite( (const void *)wavebuffer[whbuffer], sizeof( char ),  MAXWAV, testou
 );
                                    if(testout)if(fclose(testout))AfxMessageBox("fclose error", MB_ICONINFORMATION | MB_OK);
                                    testout=NULL;
                                                                    waveInStop(hwi);
                                    bNoValue=TRUE;
                                 }
                                 if(!bNoValue)
                                 {
                                    //AfxMessageBox("!bNoValue", MB_ICONINFORMATION | MB_OK);
                                    uval=0;
                                    ubcnt=0;
   
                                    for(uval=142;(uval<MAXWAV-MAXAVG*100+202+113)&&((*(wavebuffer[whbuffer]+uval))<5);uval+=4)/
used to start at 140, changed to 142 to measure PAR instead of sunflecks
                                    {
                               //     if(uval>20000)
***** ..\V3107\MAINFRM.CPP
   
                              //PARFlecksValue.bTESTOUT=FALSE;  //if(whbuffer==3)
                              if(!(wh[whbuffer].dwFlags & WHDR_DONE))
                              {
                                 waveInStop(hwi);
                                 AfxMessageBox("Wave did not fill buffers", MB_ICONINFORMATION | MB_OK);
                                 bNoValue=TRUE;
                              }
                       
                              if(!bNoValue)
                              {
                                 uval=0;
                                 ubcnt=0;
   
                                 for(uval=140;(uval<MAXWAV-MAXAVG*100+202+113)&&((*(wavebuffer[whbuffer]+uval))<20);uval+=4)
                                 {
                               //     if(uval>20000)
*****

***** Mainfrm.cpp
                               //     }
                                    }
                                                                
                                    if(uval>=MAXWAV-MAXAVG*100+202+113)
                                                                    {
                                       if(testout)ucnt=fwrite( (const void *)wavebuffer[whbuffer], sizeof( char ),  MAXWAV, tes
out );
                                                                           numwritten=numwritten+ucnt;
                                       if(whbuffer==MAXWAVCNT-1)
                                                                           {
                                                                              if(testout)if(fclose(testout))AfxMessageBox("fclo
e error", MB_ICONINFORMATION | MB_OK);
                                          if(testout)sprintf(MsgBuf,"Written %u, whbuffer %u",numwritten,whbuffer);
                                          if(testout)AfxMessageBox(MsgBuf, MB_ICONINFORMATION | MB_OK);
                                                                                  numwritten=0;
                                                                                  whbuffer=MAXWAVCNT;
                                          testout=NULL;
                                                                                  bFilesave=FALSE;
                                                                              PARFlecksValue.count++; //terminate measurement w
th no results
                                                                           }
                                       //if(testout)sprintf(MsgBuf,"Written %u, whbuffer %u",numwritten,whbuffer);
                                       //if(testout)AfxMessageBox(MsgBuf, MB_ICONINFORMATION | MB_OK);
                                                                    }
                                                                    else
                                    {
                                       if(testout)ucnt=fwrite( (const void *)wavebuffer[whbuffer], sizeof( char ),  MAXWAV, tes
out );
                                       //if(testout)sprintf(MsgBuf,"Bytes written %u, Buffer %u",ucnt,whbuffer);
                                       //if(testout)AfxMessageBox(MsgBuf, MB_ICONINFORMATION | MB_OK);
                                       uparcnt=0;
                                       PARFlecksValue.Flecks=0.0;
                                       PARFlecksValue.PAR=0.0;
                                       for(un=0;un<MAXAVG;un++) /* we will average some readings */
                                       {
                                          uinterval=0; // 210 offset from uval to starting to measure and about 1616 long
                                          upar[un]=0;
                                          ipar[un]=0;
                                          uFlecks[un]=0;
                                          iFlecks[un]=0;
                                          if(ubcnt==0)
                                          {
                                             ucnt=uval+2+202+100*un; // 0 is msb of left, 1 is lsb of left, 2 is msb of right, 
 is lsb of right...added 2 to keep par sunflecks in right order after changing uval
                                             //if(testout)sprintf(MsgBuf,"ucnt %u",ucnt);
                                             //if(testout)AfxMessageBox(MsgBuf, MB_ICONINFORMATION | MB_OK);
                                             if(ucnt<MAXWAV-113)
                                             {
                                                for(uinterval=1;uinterval<113;uinterval+=4) //28 readings with about 10 per cyc
e
                                                {
                                                  c1=(*(wavebuffer[whbuffer]+ucnt+uinterval));
                                                  c2=(*(wavebuffer[whbuffer]+ucnt-1+uinterval));
                                                  itmp=(unsigned int)c1*256+(unsigned int)c2;
                                                  if(itmp>32767)itmp=itmp-65536;
                                                  if(itmp>0&&itmp>upar[un])upar[un]=itmp;
                                                  if(itmp<0&&itmp<ipar[un])ipar[un]=itmp;
                                                }
                                                for(uinterval=3;uinterval<113;uinterval+=4)
                                                {
                                                  c1=(*(wavebuffer[whbuffer]+ucnt+uinterval));
                                                  c2=(*(wavebuffer[whbuffer]+ucnt-1+uinterval));
                                                  itmp=(unsigned int)c1*256+(unsigned int)c2;
                                                  if(itmp>32767)itmp=itmp-65536;
                                                  if(itmp<0&&itmp<iFlecks[un])iFlecks[un]=itmp;
                                                  if(itmp>0&&itmp>uFlecks[un])uFlecks[un]=itmp;
                                                }
                                             }
                                             else
                                             {
                                                upar[un]=0;
                                                uFlecks[un]=0;
                                             }
                              //             sprintf(MsgBuf,"upar %u,  uFlecks %u",upar[un], uFlecks[un]);
                              //             AfxMessageBox(MsgBuf, MB_ICONINFORMATION | MB_OK);
      
                                          }
                                          PARFlecksValue.Flecks+=::Flecksgain*ci_config_geometry->Flecksspancal*(((double)uFlec
s[un]-(double)iFlecks[un])+(double)ci_config_geometry->Fleckszerocal);
                                          PARFlecksValue.PAR=PARFlecksValue.PAR+::PARgain*ci_config_geometry->PARspancal*(((dou
le)upar[un]-(double)ipar[un])+ci_config_geometry->PARzerocal);
                         //               sprintf(MsgBuf,"Flecksgain %g, spancal %g, uFlecks %u", ::Flecksgain, ci_config_geome
ry->Flecksspancal, uFlecks[un]);
                        //                AfxMessageBox(MsgBuf, MB_ICONINFORMATION | MB_OK);
         
                                       } // for(un=0;un<24;un++)
                                       if (PARFlecksValue.PAR<0.0)PARFlecksValue.PAR=0.0;
                                       if(whbuffer==0)mmr=100; // lets stop this recording stuff.
                                       if((PARFlecksValue.measure>0) && (bNoValue==FALSE))
                                       {
                                          ::PAR=PARFlecksValue.PAR;
                                          ::Flecks=PARFlecksValue.Flecks;
                                          if(::Flecks>100.0)::Flecks=100.0;
                                          if(::PAR<0.0)::PAR=0.0;
                                          if(::Flecks<0.0)::Flecks=0.0;
                                          PARFlecksValue.count++;
                              //         PARFlecksValue.measure=0;
                                          CDocument* pDoc = mainFrame->GetActiveDocument();
                                          if (pDoc->IsKindOf(RUNTIME_CLASS(CDibDoc)))
                                          {
***** ..\V3107\MAINFRM.CPP
                               //     }
                                 }
                                 if(uval<MAXWAV-MAXAVG*100+202+113)
                                 {
                                    if(testout)ucnt=fwrite( (const void *)wavebuffer[whbuffer], sizeof( char ),  MAXWAV, testou
 );
                                  //  sprintf(MsgBuf,"Bytes written %u, Buffer %u",ucnt,whbuffer);
                                  //  AfxMessageBox(MsgBuf, MB_ICONINFORMATION | MB_OK);
                                 uparcnt=0;
                                 PARFlecksValue.Flecks=0.0;
                                 PARFlecksValue.PAR=0.0;
                                 for(un=0;un<MAXAVG;un++) /* we will average some readings */
                                 {
                                    uinterval=0; // 210 offset from uval to starting to measure and about 1616 long
                                    upar[un]=0;
                                    ipar[un]=0;
                                    uFlecks[un]=0;
                                    iFlecks[un]=0;
                                    if(ubcnt==0)
                                    {
                                       ucnt=uval+202+100*un; // 0 is msb of left, 1 is lsb of left, 2 is msb of right, 3 is lsb
of right
                           //               sprintf(MsgBuf,"ucnt %u",ucnt);
                           //               AfxMessageBox(MsgBuf, MB_ICONINFORMATION | MB_OK);
                                       if(ucnt<MAXWAV-113)
                                       {
                                          for(uinterval=1;uinterval<113;uinterval+=4) //28 readings with about 10 per cycle
                                          {
*****

***** Mainfrm.cpp
                                          {
                                             ((CDibDoc*) pDoc)->UpdateAllViews(NULL);
                                          }       
                                       }
                                       whbuffer=MAXWAVCNT;
                                    } //if(uval<MAXWAV-MAXAVG*100+202+113)
                                 } //if(!bNoValue)
                              }//if(mmr==MMSYSERR_NOERROR && PARFlecksValue.measure>0)
                           }// for whbuffer
***** ..\V3107\MAINFRM.CPP
                                          {
                                            c1=(*(wavebuffer[whbuffer]+ucnt+uinterval));
                                            c2=(*(wavebuffer[whbuffer]+ucnt-1+uinterval));
                                            itmp=(unsigned int)c1*256+(unsigned int)c2;
                                            if(itmp>32767)itmp=itmp-65536;
                                            if(itmp>0&&itmp>upar[un])upar[un]=itmp;
                                            if(itmp<0&&itmp<ipar[un])ipar[un]=itmp;
                                          }
                                          for(uinterval=3;uinterval<113;uinterval+=4)
                                          {
                                            c1=(*(wavebuffer[whbuffer]+ucnt+uinterval));
                                            c2=(*(wavebuffer[whbuffer]+ucnt-1+uinterval));
                                            itmp=(unsigned int)c1*256+(unsigned int)c2;
                                            if(itmp>32767)itmp=itmp-65536;
                                            if(itmp<0&&itmp<iFlecks[un])iFlecks[un]=itmp;
                                            if(itmp>0&&itmp>uFlecks[un])uFlecks[un]=itmp;
                                          }
                                       }
                                       else
                                       {
                                          upar[un]=0;
                                          uFlecks[un]=0;
                                       }
                              //            sprintf(MsgBuf,"upar %u,  uFlecks %u",upar[un], uFlecks[un]);
                              //            AfxMessageBox(MsgBuf, MB_ICONINFORMATION | MB_OK);
      
                                    }
                                    PARFlecksValue.Flecks+=::Flecksgain*ci_config_geometry->Flecksspancal*(((double)uFlecks[un]
(double)iFlecks[un])+(double)ci_config_geometry->Fleckszerocal);
                                    PARFlecksValue.PAR=PARFlecksValue.PAR+::PARgain*ci_config_geometry->PARspancal*(((double)up
r[un]-(double)ipar[un])+ci_config_geometry->PARzerocal);
                         //           sprintf(MsgBuf,"Flecksgain %g, spancal %g, uFlecks %u", ::Flecksgain, ci_config_geometry-
Flecksspancal, uFlecks[un]);
                        //               AfxMessageBox(MsgBuf, MB_ICONINFORMATION | MB_OK);
         
                                 } // for(un=0;un<24;un++)
                                 if (PARFlecksValue.PAR<0.0)PARFlecksValue.PAR=0.0;
                                 if(whbuffer==0)mmr=100; // lets stop this recording stuff.
                                 if((PARFlecksValue.measure>0) && (bNoValue==FALSE))
                                 {
                                    ::PAR=PARFlecksValue.PAR;
                                    ::Flecks=PARFlecksValue.Flecks;
                                    if(::Flecks>100.0)::Flecks=100.0;
                                    if(::PAR<0.0)::PAR=0.0;
                                    if(::Flecks<0.0)::Flecks=0.0;
                                    PARFlecksValue.count++;
                              //         PARFlecksValue.measure=0;
                                    CDocument* pDoc = mainFrame->GetActiveDocument();
                                    if (pDoc->IsKindOf(RUNTIME_CLASS(CDibDoc)))
                                    {
                                       ((CDibDoc*) pDoc)->UpdateAllViews(NULL);
                                    }       
                                 }
                                 whbuffer=MAXWAVCNT;
                                 } //if(uval<MAXWAV-MAXAVG*100+202+113)
                              } //if(!bNoValue)
                           }//if(mmr==MMSYSERR_NOERROR && PARFlecksValue.measure>0)
                           }// for whbuffer
*****

***** Mainfrm.cpp
                     if(testout)if(fclose(testout))AfxMessageBox("fclose error", MB_ICONINFORMATION | MB_OK);
                                         numwritten=0;
                     testout=NULL;
***** ..\V3107\MAINFRM.CPP
                     if(testout)if(fclose(testout))AfxMessageBox("fclose error", MB_ICONINFORMATION | MB_OK);
                     testout=NULL;
*****

***** Mainfrm.cpp
                DibReceived(hdib);
        } //if hdib
***** ..\V3107\MAINFRM.CPP
                DibReceived(hdib);

//      PARFlecks();

        } //if hdib
*****

***** Mainfrm.cpp
        PARFlecksValue.measure=1;
        

        
         if (!TWAIN_LoadSourceManager()) {
                AfxMessageBox("TWAIN LoadSourceManager error", MB_ICONINFORMATION | MB_OK);
        } else if (!TWAIN_OpenSourceManager(m_hWnd)) {
                AfxMessageBox("TWAIN OpenSourceManager error", MB_ICONINFORMATION | MB_OK);
    } else if (!TWAIN_OpenDefaultSource()) {
                AfxMessageBox("TWAIN default Data Source error", MB_ICONINFORMATION | MB_OK);
        } else if (!TWAIN_NegotiatePixelTypes(TWAIN_ANYTYPE)) {
                AfxMessageBox("TWAIN PixelType error", MB_ICONINFORMATION | MB_OK);
        } else if (!TWAIN_EnableSource(m_hWnd)) {
                AfxMessageBox("TWAIN Failed to enable Data Soruce", MB_ICONINFORMATION | MB_OK);
        }
        Sleep(10);

        // shut everything down in the right sequence
        // these routines do nothing if the corresponding 'open' failed
        TWAIN_DisableSource();
        TWAIN_CloseSource();    
    TWAIN_CloseSourceManager(m_hWnd);
    TWAIN_UnloadSourceManager();

***** ..\V3107\MAINFRM.CPP
        PARFlecksValue.measure=1;
    while(PARFlecksValue.count<count+1)Sleep(150);
        PARFlecksValue.measure=0;
        
        CDocument* pDoc = GetActiveDocument();
        if (pDoc->IsKindOf(RUNTIME_CLASS(CDibDoc))) {
                CDibView* pView = (CDibView*) GetActiveView();
                pView->SetImageAdjustment(FALSE);
        ((CDibDoc*) pDoc)->ShowResultSF();
        }

}

*****

***** Mainfrm.cpp

    while(PARFlecksValue.count==count)Sleep(100);
        PARFlecksValue.measure=0;
        
        CDocument* pDoc = GetActiveDocument();
        if (pDoc->IsKindOf(RUNTIME_CLASS(CDibDoc))) {
                CDibView* pView = (CDibView*) GetActiveView();
                pView->SetImageAdjustment(FALSE);
        ((CDibDoc*) pDoc)->ShowResultSF();
        }

***** ..\V3107\MAINFRM.CPP

void CMainFrame::OnUpdateSelectSource(CCmdUI* pCmdUI) 
{
        /*** old code, used CTwain's functions
        pCmdUI->Enable(State() == SOURCE_MANAGER_OPEN);
        */
        //pCmdUI->Enable(TWAIN_State() == TWAIN_SM_OPEN);
        pCmdUI->Enable(TWAIN_IsAvailable());

*****

***** Mainfrm.cpp



void CMainFrame::OnUpdateSelectSource(CCmdUI* pCmdUI) 
{
***** ..\V3107\MAINFRM.CPP

void CMainFrame::OnSelectSource() 
{
*****

***** Mainfrm.cpp
        /*** old code, used CTwain's functions
        pCmdUI->Enable(State() == SOURCE_MANAGER_OPEN);
        */
        //pCmdUI->Enable(TWAIN_State() == TWAIN_SM_OPEN);
        pCmdUI->Enable(TWAIN_IsAvailable());

}

void CMainFrame::OnSelectSource() 
{
        /*** old code, used CTwain's functions
        SelectSource();
***** ..\V3107\MAINFRM.CPP
        /*** old code, used CTwain's functions
        SelectSource();
*****

