Hi, everyone:
I am trying to modify some code written under visual C++ for storing data
from another device. The first thing I need to do is that I need to create a
file with own extension, and so the user can user the file to storing data
from the device. After storing data in the file, the user can open the file
for viewing the data.
I attach some Visual C++ code here. I will very appreciated any help for
this.

Visual C++:

//#pragma argsused
int CCommControlView::Retrieve_Scanner()  // scanner is the device I need
store data from it
{
        int job_status, done;
        CString abortmsg;
        

        //char model_str[11][8] = {"VP-1", "DS-3R", "iVS/300", "VS/300",
        //
"iVS/600", "VS/600", "iVS/BGE", "iVS-S","VS-S","STM-01","ViP"};

        char model_str[16][12];
        CString temp;
        for(int i = 0; i < 16; i++)
        {
                temp.LoadString(WSS_G_VP1 + i);
                strcpy(model_str[i],(LPCTSTR) temp);
        }


   CWinScanDoc *pDoc = GetDocument();

   // char szFilters[] = "New Downloading Session (*.isf)|*.isf";
   temp.LoadString(WSS_G_NEW_DNLD_SESSION);
   CFileDialog dlg(FALSE,"isf","*.isf",
      OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY,
      temp,this);

                done = FALSE;
                IsDownloading = TRUE;

                temp.LoadString(WSS_G_DOWNLOADING);
                ((CCommFrame *) GetParentFrame())->SetWindowText(temp);

                job_status = Retrieve_Scanner_Data ();
                if (job_status != JOB_COMPLETED)
                {
                        done =  Error_Handler ((unt8)job_status, PROMPT_ON);
                        // Don't save data if something went wrong
                        pDoc->SetModifiedFlag(FALSE);
                }
                else
                {
                // Check the current A/D reading of the backup battery 
            CBatteryVRec *batteryV = pDoc->scanner()->batteryV();
                        if(batteryV){
                                if (batteryV->LowVoltage()){
                                        Error_Handler (LOW_BATTERY,
PROMPT_OFF);
                                }
                        }           
                }
                IsDownloading = FALSE;


        if (job_status != JOB_COMPLETED)
        {
                if(job_status == ABORT_JOB)
                {
                        //Aborting is like starting over so make sure we do
                                ((CCommFrame *) GetParentFrame())
                                ->SetWindowText(pDoc->GetTitle());
                                Abort = false; //reset Abort to it's
appropriate value

                                // If we are connected to a remote scanner
make sure that
                                // we wait enough time for the scanner to
recover after an abort
                                if(Remote_Online())
                                {
                                        temp.LoadString(WSS_G_ABORT_DNLD);
                                        for(i = 0; i < RECOVER_TIME; i++)
                                        {
                                                // abortmsg.Format("Aborting
Download ... %i seconds",(RECOVER_TIME-i)+2);
                                                abortmsg.Format(temp,
(RECOVER_TIME-i) + 2);

                                                Update_StatusBar
(STATUS_FIELD, abortmsg);
                                                Sleep(1000);
                                        }
                                        temp.LoadString(WSS_G_ABORTCOMP);
                                        Update_StatusBar (STATUS_FIELD,
temp);

                                }

                }
                return 0;
        }
        else
        {
      // Set Document File Name
        //pDoc->SetModifiedFlag(TRUE);
                if(!pDoc->SaveData())
                {
                        // Set the frame title back to 
                        // the original documents title
                        ((CCommFrame *) GetParentFrame())
                                ->SetWindowText(pDoc->GetTitle()); 
                }

//PG&E Report
/*              else
                {
                        DFileName = pDoc->GetTitle();
                        DFileName = DFileName.Left(DFileName.Find('.'));
                        DFileName += "Power.txt";
                        if(pDoc->config()->PowerReport())
                        {
                                DFile.Open(DFileName,CFile::modeCreate |
CFile::modeWrite );
                                CArchive ar( &DFile, CArchive::store, 512);
                                StoreDB(ar,DFileName);
                        }
                }
*/
        //      Send_Msg("Download Completed\n");
                temp.LoadString(WSS_G_DOWNLOAD_COMP);  // Download Completed
                Send_Msg(temp);


                /** Check for auto initialization and prompt user for init
if
                 **  not enabled. **/

                if (pDoc->config()->ScannerReset() == YES)
                                Complete_Scanner_Init ();
                else if (pDoc->config()->ScannerReset() == PROMPT)
                {
        //      if(AfxMessageBox("Reinitialize scanner?",MB_YESNO |
MB_ICONQUESTION) == IDYES)
                        temp.LoadString(WSS_G_REINIT_SCAN);
                        if(AfxMessageBox(temp,MB_YESNO | MB_ICONQUESTION) ==
IDYES)
                                Complete_Scanner_Init ();

                }
        }
        return 1;
}


Allen

Reply via email to