////////////////////////////////////////////////////////////////////////// // // Function Name: SetReleaseState // Description: Takes and stores picture // Parameters: // Returns: void // Summary: When this function is called, the picture is first taken // and then stored by calling GetReleaseData. // Author: CannonSDK // /////////////////////////////////////////////////////////////////////////// void CCameraConnect::StartRelease(char* szSavePath) { cdError err; BOOL fRes; CProgress CProg; //char szSavePath[MAX_PATH]; cdUInt32 NumData; /* UI is locked so that information may not be changed. */ err = CDLockUI( m_hSource ); if( GETERRORID(err) != cdOK ) { // goto camerr; } /* It sets up so that a complete message may be disregarded. */ m_fProgramRelease = TRUE; /* A special camera ends a view finder. */ if( m_RelControlCap&cdRELEASE_CONTROL_CAP_ABORT_VIEWFINDER ) { if( m_fVFEnd ) { /* A view finder is ended. */ err = CDTermViewfinder( m_hSource ); if( GETERRORID(err) != cdOK ) { // goto camerr; } /* A thread is ended. */ m_fVFEnd = FALSE; g_CpVFThread->ResumeThread(); WaitForSingleObject( g_CpVFThread->m_hThread, INFINITE ); //m_CViewFinder.SetWindowText( "Start" ); // Invalidate(); // UpdateWindow(); } } /* A photograph is taken. */ NumData = 0; err = CDRelease( m_hSource, FALSE, NULL, NULL, cdPROG_NO_REPORT, &NumData ); if( GETERRORID(err) != cdOK ) { // goto camerr; } /* The directory to save is acquired. */ //GetSavePath( szSavePath, MAX_PATH ); /* The photoed picture is saved. */ fRes = CProg.GetReleaseData( m_hSource, NumData, szSavePath, this ); if( !fRes ) { // goto apierr; } else if( GETERRORID(CProg.m_LastErr) == cdOPERATION_CANCELLED ) { m_fProgramRelease = FALSE; CDUnlockUI( m_hSource ); return; } else if( GETERRORID(CProg.m_LastErr) != cdOK ) { err = CProg.m_LastErr; // goto camerr; } /* The lock of UI is canceled. */ err = CDUnlockUI( m_hSource ); if( GETERRORID(err) != cdOK ) { // goto camerr; } /* It sets up so that a complete message may be received. */ m_fProgramRelease = FALSE; return; }
////////////////////////////////////////////////////////////////////////// // // Function Name: WindowProc // Description: Used for handling windows messages // Parameters: UINT message // WPARAM wParam // LPARAM lparam // char *cpBuffer // Returns: BOOL // Summary: This functions gets called in the CPictureWizardDlg's WindowProc // Within the CPictureWizardDlg's WindowProc functions, we are // also calling this function since there is a possibility that // the release button was pressed. The 'message' tells us what sort of // message was generated prior to calling WindowProc. If a picture is // taken, the ReleaseCallBackFunction will be called setting the message // to g_ReleaseOnMessage // Author: CannonSDK // /////////////////////////////////////////////////////////////////////////// BOOL CCameraConnect::WindowProc(UINT message, WPARAM wParam, LPARAM lParam, char* cpBuffer) { cdError err; BOOL fRes; CProgress CProg; //char szSavePath[MAX_PATH]; cdUInt32 NumData; if( message == g_ReleaseOnMessage ) { /* UI is locked so that information may not be changed. */ err = CDLockUI( m_hSource ); if( GETERRORID(err) != cdOK ) { //goto camerr; } /* It sets up so that a complete message may be disregarded. */ m_fProgramRelease = TRUE; /* A special camera ends a view finder. */ if( m_RelControlCap&cdRELEASE_CONTROL_CAP_ABORT_VIEWFINDER ) { if( m_fVFEnd ) { /* A view finder is ended. */ err = CDTermViewfinder( m_hSource ); if( GETERRORID(err) != cdOK ) { //goto camerr; } /* A thread is ended. */ m_fVFEnd = FALSE; g_CpVFThread->ResumeThread(); WaitForSingleObject( g_CpVFThread->m_hThread, INFINITE ); // this is something that will have to be done on the dlg //m_CViewFinder.SetWindowText( "Start" ); //Invalidate(); //UpdateWindow(); } } /* A photograph is taken. */ NumData = 0; err = CDRelease( m_hSource, FALSE, NULL, NULL, cdPROG_NO_REPORT, &NumData ); if( GETERRORID(err) != cdOK ) { //goto camerr; } /* The directory to save is acquired. */ // this is actually done in the dlg //GetSavePath( szSavePath, MAX_PATH ); //szSavePath = cpBuffer; /* The photoed picture is saved. */ //fRes = CProg.GetReleaseData( m_hSource, NumData, cpBuffer ); // Determine if we should take the left picture or the right if (pCPictureWizardDlg->horizontal) // left picture { //to indicate that horizontal picture is taken pCPictureWizardDlg->horizontal = false; //set the file name for the horizontal(true) picture SetFileName(true); fRes = CProg.GetReleaseData( m_hSource, NumData, FileName, this ); //display horizonal picture in left box if (pCPictureWizardDlg->m_jpgLeft.Load(_T(FileName))) { pCPictureWizardDlg->m_jpgLeft.Scale(PICTURE_WINDOW_WIDTH, PICTURE_WINDOW_HEIGHT); pCPictureWizardDlg->m_jpgLeft.Draw(); } } else // right picture { //set the file name for the vertical (false) picture SetFileName(false); fRes = CProg.GetReleaseData( m_hSource, NumData, FileName, this ); //diplay vertical picture in right box if (pCPictureWizardDlg->m_jpgRight.Load(_T(FileName))) { pCPictureWizardDlg->m_jpgRight.Scale(PICTURE_WINDOW_WIDTH, PICTURE_WINDOW_HEIGHT); pCPictureWizardDlg->m_jpgRight.Draw(); } } if( !fRes ) { //goto apierr; } else if( GETERRORID(CProg.m_LastErr) == cdOPERATION_CANCELLED ) { m_fProgramRelease = FALSE; CDUnlockUI( m_hSource ); return TRUE; } else if( GETERRORID(CProg.m_LastErr) != cdOK ) { err = CProg.m_LastErr; //goto camerr; } /* The lock of UI is canceled. */ err = CDUnlockUI( m_hSource ); if( GETERRORID(err) != cdOK ) { //goto camerr; } /* It sets up so that a complete message may be received. */ m_fProgramRelease = FALSE; //bPictDone = TRUE; //PictureDoneWait(); return TRUE; } return TRUE; }