home *** CD-ROM | disk | FTP | other *** search
- // OCRDEMO.cpp : Defines the class behaviors for the application.
- //
-
- #include "stdafx.h"
- #include "OCRDEMO.h"
-
- #include "MainFrm.h"
- #include "OCRDoc.h"
- #include "OCRView.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // COCRApp
-
- BEGIN_MESSAGE_MAP(COCRApp, CWinApp)
- //{{AFX_MSG_MAP(COCRApp)
- ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
- ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_AS, OnUpdateFileSaveas)
- ON_UPDATE_COMMAND_UI(ID_OCR_RECOGNIZE, OnUpdateOcrRecognize)
- ON_UPDATE_COMMAND_UI(ID_OCR_CLEARDOCUMENT, OnUpdateOcrCleardocument)
- ON_UPDATE_COMMAND_UI(ID_OCR_EDITDOCUMENT, OnUpdateOcrEditdocument)
- ON_COMMAND(ID_PREFERENCES_LANGUAGE_ENGLISH, OnPreferencesLanguageEnglish)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_LANGUAGE_ENGLISH, OnUpdatePreferencesLanguageEnglish)
- ON_COMMAND(ID_PREFERENCES_LANGUAGE_GERMAN, OnPreferencesLanguageGerman)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_LANGUAGE_GERMAN, OnUpdatePreferencesLanguageGerman)
- ON_COMMAND(ID_PREFERENCES_LANGUAGE_FRENCH, OnPreferencesLanguageFrench)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_LANGUAGE_FRENCH, OnUpdatePreferencesLanguageFrench)
- ON_COMMAND(ID_PREFERENCES_LANGUAGE_SPANISH, OnPreferencesLanguageSpanish)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_LANGUAGE_SPANISH, OnUpdatePreferencesLanguageSpanish)
- ON_COMMAND(ID_PREFERENCES_LANGUAGE_ITALIAN, OnPreferencesLanguageItalian)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_LANGUAGE_ITALIAN, OnUpdatePreferencesLanguageItalian)
- ON_COMMAND(ID_PREFERENCES_LANGUAGE_DUTCH, OnPreferencesLanguageDutch)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_LANGUAGE_DUTCH, OnUpdatePreferencesLanguageDutch)
- ON_COMMAND(ID_PREFERENCES_LANGUAGE_SWEDISH, OnPreferencesLanguageSwedish)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_LANGUAGE_SWEDISH, OnUpdatePreferencesLanguageSwedish)
- ON_COMMAND(ID_PREFERENCES_LANGUAGE_NORWEGIAN, OnPreferencesLanguageNorwegian)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_LANGUAGE_NORWEGIAN, OnUpdatePreferencesLanguageNorwegian)
- ON_COMMAND(ID_PREFERENCES_LANGUAGE_FINNISH, OnPreferencesLanguageFinnish)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_LANGUAGE_FINNISH, OnUpdatePreferencesLanguageFinnish)
- ON_COMMAND(ID_PREFERENCES_LANGUAGE_DANISH, OnPreferencesLanguageDanish)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_LANGUAGE_DANISH, OnUpdatePreferencesLanguageDanish)
- ON_COMMAND(ID_PREFERENCES_LANGUAGE_PORTUGUESE, OnPreferencesLanguagePortuguese)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_LANGUAGE_PORTUGUESE, OnUpdatePreferencesLanguagePortuguese)
- ON_COMMAND(ID_PREFERENCES_LANGUAGE_RUSSIAN, OnPreferencesLanguageRussian)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_LANGUAGE_RUSSIAN, OnUpdatePreferencesLanguageRussian)
- ON_COMMAND(ID_PREFERENCES_TRAINING, OnPreferencesTraining)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_TRAINING, OnUpdatePreferencesTraining)
- ON_COMMAND(ID_PREFERENCES_PREPROCESSINGMODE_NONE, OnPreferencesPreprocessingmodeNone)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_PREPROCESSINGMODE_NONE, OnUpdatePreferencesPreprocessingmodeNone)
- ON_COMMAND(ID_PREFERENCES_PREPROCESSINGMODE_DOTMATRIX, OnPreferencesPreprocessingmodeDotmatrix)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_PREPROCESSINGMODE_DOTMATRIX, OnUpdatePreferencesPreprocessingmodeDotmatrix)
- ON_COMMAND(ID_PREFERENCES_PREPROCESSINGMODE_REMOVEHALFTONES, OnPreferencesPreprocessingmodeRemovehalftones)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_PREPROCESSINGMODE_REMOVEHALFTONES, OnUpdatePreferencesPreprocessingmodeRemovehalftones)
- ON_COMMAND(ID_PREFERENCES_PREPROCESSINGMODE_AUTOSEGMENTATION, OnPreferencesPreprocessingmodeAutosegmentation)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_PREPROCESSINGMODE_AUTOSEGMENTATION, OnUpdatePreferencesPreprocessingmodeAutosegmentation)
- ON_COMMAND(ID_PREFERENCES_PREPROCESSINGMODE_FAX, OnPreferencesPreprocessingmodeFax)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_PREPROCESSINGMODE_FAX, OnUpdatePreferencesPreprocessingmodeFax)
- ON_COMMAND(ID_PREFERENCES_PREPROCESSINGMODE_NEWSPAPER, OnPreferencesPreprocessingmodeNewspaper)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_PREPROCESSINGMODE_NEWSPAPER, OnUpdatePreferencesPreprocessingmodeNewspaper)
- ON_COMMAND(ID_PREFERENCES_PREPROCESSINGMODE_ORIENTATION, OnPreferencesPreprocessingmodeOrientation)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_PREPROCESSINGMODE_ORIENTATION, OnUpdatePreferencesPreprocessingmodeOrientation)
- ON_COMMAND(ID_PREFERENCES_PREPROCESSINGMODE_SKEW, OnPreferencesPreprocessingmodeSkew)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_PREPROCESSINGMODE_SKEW, OnUpdatePreferencesPreprocessingmodeSkew)
- ON_COMMAND(ID_PREFERENCES_PREPROCESSINGMODE_DOTMATRIXDETECT, OnPreferencesPreprocessingmodeDotmatrixdetect)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_PREPROCESSINGMODE_DOTMATRIXDETECT, OnUpdatePreferencesPreprocessingmodeDotmatrixdetect)
- ON_COMMAND(ID_PREFERENCES_PREPROCESSINGMODE_AUTOSETDEGRADE, OnPreferencesPreprocessingmodeAutosetdegrade)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_PREPROCESSINGMODE_AUTOSETDEGRADE, OnUpdatePreferencesPreprocessingmodeAutosetdegrade)
- ON_COMMAND(ID_PREFERENCES_PREPROCESSINGMODE_AUTOFAX, OnPreferencesPreprocessingmodeAutofax)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_PREPROCESSINGMODE_AUTOFAX, OnUpdatePreferencesPreprocessingmodeAutofax)
- ON_COMMAND(ID_PREFERENCES_PREPROCESSINGMODE_TEXTORIENTATION, OnPreferencesPreprocessingmodeTextorientation)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_PREPROCESSINGMODE_TEXTORIENTATION, OnUpdatePreferencesPreprocessingmodeTextorientation)
- ON_COMMAND(ID_PREFERENCES_PREPROCESSINGMODE_FULLORIENTATION, OnPreferencesPreprocessingmodeFullorientation)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_PREPROCESSINGMODE_FULLORIENTATION, OnUpdatePreferencesPreprocessingmodeFullorientation)
- ON_COMMAND(ID_PREFERENCES_PREPROCESSINGMODE_DORIGHT, OnPreferencesPreprocessingmodeDoright)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_PREPROCESSINGMODE_DORIGHT, OnUpdatePreferencesPreprocessingmodeDoright)
- ON_COMMAND(ID_PREFERENCES_RECOGNITIONMODE_STANDARD, OnPreferencesRecognitionmodeStandard)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_RECOGNITIONMODE_STANDARD, OnUpdatePreferencesRecognitionmodeStandard)
- ON_COMMAND(ID_PREFERENCES_RECOGNITIONMODE_DEGRADED, OnPreferencesRecognitionmodeDegraded)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_RECOGNITIONMODE_DEGRADED, OnUpdatePreferencesRecognitionmodeDegraded)
- ON_COMMAND(ID_PREFERENCES_RECOGNITIONMODE_UNKNOWN, OnPreferencesRecognitionmodeUnknown)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_RECOGNITIONMODE_UNKNOWN, OnUpdatePreferencesRecognitionmodeUnknown)
- ON_COMMAND(ID_PREFERENCES_VERIFIERMODE_NONE, OnPreferencesVerifiermodeNone)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_VERIFIERMODE_NONE, OnUpdatePreferencesVerifiermodeNone)
- ON_COMMAND(ID_PREFERENCES_VERIFIERMODE_CHAR, OnPreferencesVerifiermodeChar)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_VERIFIERMODE_CHAR, OnUpdatePreferencesVerifiermodeChar)
- ON_COMMAND(ID_PREFERENCES_VERIFIERMODE_WORD, OnPreferencesVerifiermodeWord)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_VERIFIERMODE_WORD, OnUpdatePreferencesVerifiermodeWord)
- ON_COMMAND(ID_PREFERENCES_VERIFIERTHRESHOLD, OnPreferencesVerifierthreshold)
- ON_COMMAND(ID_PREFERENCES_MINPOINTSIZE, OnPreferencesMinpointsize)
- ON_COMMAND(ID_PREFERENCES_MAXPOINTSIZE, OnPreferencesMaxpointsize)
- ON_COMMAND(ID_PREFERENCES_TEXTORIENTLIMIT, OnPreferencesTextorientlimit)
- ON_COMMAND(ID_PREFERENCES_HEADERFOOTERPROCESS, OnPreferencesHeaderfooterprocess)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_HEADERFOOTERPROCESS, OnUpdatePreferencesHeaderfooterprocess)
- ON_COMMAND(ID_PREFERENCES_SLOPPYMANUAL, OnPreferencesSloppymanual)
- ON_UPDATE_COMMAND_UI(ID_PREFERENCES_SLOPPYMANUAL, OnUpdatePreferencesSloppymanual)
- ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
- //}}AFX_MSG_MAP
- // Standard file based document commands
- ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
- ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // COCRApp construction
-
- COCRApp::COCRApp()
- {
- // TODO: add construction code here,
- // Place all significant initialization in InitInstance
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // The one and only COCRApp object
-
- COCRApp theApp;
-
- /////////////////////////////////////////////////////////////////////////////
- // COCRApp initialization
-
- BOOL COCRApp::InitInstance()
- {
- m_fImage = FALSE;
- m_fRecognize = FALSE;
- m_nPage = 1;
- m_nPaintSize = PAINTSIZEMODE_FIT;
-
- m_nPreprocessingMode = OCRPP_DO_RIGHT;
- m_nRecognitionMode = OCRREC_UNKNOWN;
- m_nVerifierMode = OCRVER_WORD;
- m_nVerifierThreshold = 750;
- m_nMinPointSize = 5;
- m_nMaxPointSize = 72;
- m_nLanguage = OCRLNG_ENGLISH;
- m_bHeaderFooterProcess = TRUE;
- m_bSloppyManual = TRUE;
- m_nTextOrientLimit = -1;
-
- strcpy(m_szDocumentName, "");
- strcpy(m_szUnrecognized, "~");
- strcpy(m_szQuestionable, "");
- strcpy(m_szLeftSingleQuote, "'");
- strcpy(m_szRightSingleQuote, "'");
- sprintf(m_szLeftDoubleQuote, "%c", '"');
- sprintf(m_szRightDoubleQuote, "%c", '"');
- strcpy(m_szDecimal, ".");
- strcpy(m_szThousands, ",");
- strcpy(m_szLexicon, "xxx");
- // strcpy(m_szTraining, "");
- strcpy(m_szTraining, m_pszHelpFilePath);
-
- // Initialize OLE libraries
- if (!AfxOleInit())
- {
- AfxMessageBox(IDP_OLE_INIT_FAILED);
- return FALSE;
- }
-
- AfxEnableControlContainer();
-
- // Standard initialization
- // If you are not using these features and wish to reduce the size
- // of your final executable, you should remove from the following
- // the specific initialization routines you do not need.
-
- #ifdef _AFXDLL
- Enable3dControls(); // Call this when using MFC in a shared DLL
- #else
- Enable3dControlsStatic(); // Call this when linking to MFC statically
- #endif
-
- LoadStdProfileSettings(); // Load standard INI file options (including MRU)
-
- // Register the application's document templates. Document templates
- // serve as the connection between documents, frame windows and views.
- CSingleDocTemplate* pDocTemplate;
- pDocTemplate = new CSingleDocTemplate(
- IDR_MAINFRAME,
- RUNTIME_CLASS(COCRDEMODoc),
- RUNTIME_CLASS(CMainFrame), // main SDI frame window
- RUNTIME_CLASS(COCRDEMOView));
- pDocTemplate->SetContainerInfo(IDR_CNTR_INPLACE);
- AddDocTemplate(pDocTemplate);
-
- // Parse command line for standard shell commands, DDE, file open
- CCommandLineInfo cmdInfo;
- ParseCommandLine(cmdInfo);
-
- // Dispatch commands specified on the command line
- if (!ProcessShellCommand(cmdInfo))
- return FALSE;
-
- POSITION FirstDocPos = pDocTemplate->GetFirstDocPosition();
-
- COCRDEMODoc* pDoc = (COCRDEMODoc*)pDocTemplate->GetNextDoc(FirstDocPos);
- pDoc->InitLEADDoc();
-
- return TRUE;
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CAboutDlg dialog used for App About
-
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
-
- // Dialog Data
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- //}}AFX_DATA
-
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CAboutDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
-
- // Implementation
- protected:
- //{{AFX_MSG(CAboutDlg)
- // No message handlers
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
-
- CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
- {
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
- }
-
- void CAboutDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- //}}AFX_DATA_MAP
- }
-
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- // No message handlers
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- // App command to run the dialog
- void COCRApp::OnAppAbout()
- {
- CAboutDlg aboutDlg;
- aboutDlg.DoModal();
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // COCRApp commands
- int COCRApp::DisplayLEADError(int nCode)
- {
- CString str;
-
- if(nCode)
- {
- str.Format("A LEADTOOLS error has occured.\nCODE = %d", nCode);
- m_pMainWnd->MessageBox(str);
- }
- return(nCode);
- }
-
- void COCRApp::OnUpdateFileSaveas(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(m_fImage && m_fRecognize);
- }
-
- void COCRApp::OnUpdateOcrRecognize(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(m_fImage);
- }
-
- void COCRApp::OnUpdateOcrCleardocument(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(m_fRecognize);
- }
-
- void COCRApp::OnUpdateOcrEditdocument(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(m_fRecognize);
- }
-
- void COCRApp::OnPreferencesLanguageEnglish()
- {
- m_nLanguage = OCRLNG_ENGLISH;
- }
-
- void COCRApp::OnUpdatePreferencesLanguageEnglish(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nLanguage == OCRLNG_ENGLISH);
- }
-
- void COCRApp::OnPreferencesLanguageGerman()
- {
- m_nLanguage = OCRLNG_GERMAN;
- }
-
- void COCRApp::OnUpdatePreferencesLanguageGerman(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nLanguage == OCRLNG_GERMAN);
- }
-
- void COCRApp::OnPreferencesLanguageFrench()
- {
- m_nLanguage = OCRLNG_FRENCH;
- }
-
- void COCRApp::OnUpdatePreferencesLanguageFrench(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nLanguage == OCRLNG_FRENCH);
- }
-
- void COCRApp::OnPreferencesLanguageSpanish()
- {
- m_nLanguage = OCRLNG_SPANISH;
- }
-
- void COCRApp::OnUpdatePreferencesLanguageSpanish(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nLanguage == OCRLNG_SPANISH);
- }
-
- void COCRApp::OnPreferencesLanguageItalian()
- {
- m_nLanguage = OCRLNG_ITALIAN;
- }
-
- void COCRApp::OnUpdatePreferencesLanguageItalian(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nLanguage == OCRLNG_ITALIAN);
- }
-
- void COCRApp::OnPreferencesLanguageDutch()
- {
- m_nLanguage = OCRLNG_DUTCH;
- }
-
- void COCRApp::OnUpdatePreferencesLanguageDutch(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nLanguage == OCRLNG_DUTCH);
- }
-
- void COCRApp::OnPreferencesLanguageSwedish()
- {
- m_nLanguage = OCRLNG_SWEDISH;
- }
-
- void COCRApp::OnUpdatePreferencesLanguageSwedish(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nLanguage == OCRLNG_SWEDISH);
- }
-
- void COCRApp::OnPreferencesLanguageNorwegian()
- {
- m_nLanguage = OCRLNG_NORWEGIAN;
- }
-
- void COCRApp::OnUpdatePreferencesLanguageNorwegian(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nLanguage == OCRLNG_NORWEGIAN);
- }
-
- void COCRApp::OnPreferencesLanguageFinnish()
- {
- m_nLanguage = OCRLNG_FINNISH;
- }
-
- void COCRApp::OnUpdatePreferencesLanguageFinnish(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nLanguage == OCRLNG_FINNISH);
- }
-
- void COCRApp::OnPreferencesLanguageDanish()
- {
- m_nLanguage = OCRLNG_DANISH;
- }
-
- void COCRApp::OnUpdatePreferencesLanguageDanish(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nLanguage == OCRLNG_DANISH);
- }
-
- void COCRApp::OnPreferencesLanguagePortuguese()
- {
- m_nLanguage = OCRLNG_PORTUGUESE;
- }
-
- void COCRApp::OnUpdatePreferencesLanguagePortuguese(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nLanguage == OCRLNG_PORTUGUESE);
- }
-
- void COCRApp::OnPreferencesLanguageRussian()
- {
- m_nLanguage = OCRLNG_RUSSIAN;
- }
-
- void COCRApp::OnUpdatePreferencesLanguageRussian(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nLanguage == OCRLNG_RUSSIAN);
- }
-
- void COCRApp::OnPreferencesTraining()
- {
- if (m_szTraining[0] == 0)
- {
- strcpy(m_szTraining, m_pszHelpFilePath);
- m_szTraining[strlen(m_szTraining)-3] = 'T';
- m_szTraining[strlen(m_szTraining)-2] = 'R';
- m_szTraining[strlen(m_szTraining)-1] = 'A';
- }
- else
- {
- m_szTraining[0] = 0;
- }
- }
-
- void COCRApp::OnUpdatePreferencesTraining(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_szTraining[0] != 0);
- }
-
- void COCRApp::OnPreferencesPreprocessingmodeNone()
- {
- m_nPreprocessingMode = OCRPP_NONE;
- }
-
- void COCRApp::OnUpdatePreferencesPreprocessingmodeNone(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nPreprocessingMode == OCRPP_NONE);
- }
-
- void COCRApp::OnPreferencesPreprocessingmodeDotmatrix()
- {
- long nMode=OCRPP_DOT_MATRIX;
-
- if (m_nPreprocessingMode & nMode)
- {
- m_nPreprocessingMode &= ~nMode;
- }
- else
- {
- m_nPreprocessingMode |= nMode;
- }
- }
-
- void COCRApp::OnUpdatePreferencesPreprocessingmodeDotmatrix(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nPreprocessingMode & OCRPP_DOT_MATRIX);
- }
-
- void COCRApp::OnPreferencesPreprocessingmodeRemovehalftones()
- {
- long nMode=OCRPP_REMOVE_HALFTONES;
-
- if (m_nPreprocessingMode & nMode)
- {
- m_nPreprocessingMode &= ~nMode;
- }
- else
- {
- m_nPreprocessingMode |= nMode;
- }
- }
-
- void COCRApp::OnUpdatePreferencesPreprocessingmodeRemovehalftones(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nPreprocessingMode & OCRPP_REMOVE_HALFTONES);
- }
-
- void COCRApp::OnPreferencesPreprocessingmodeAutosegmentation()
- {
- long nMode=OCRPP_AUTO_SEGMENTATION;
-
- if (m_nPreprocessingMode & nMode)
- {
- m_nPreprocessingMode &= ~nMode;
- }
- else
- {
- m_nPreprocessingMode |= nMode;
- }
- }
-
- void COCRApp::OnUpdatePreferencesPreprocessingmodeAutosegmentation(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nPreprocessingMode & OCRPP_AUTO_SEGMENTATION);
- }
-
- void COCRApp::OnPreferencesPreprocessingmodeFax()
- {
- long nMode=OCRPP_FAX;
-
- if (m_nPreprocessingMode & nMode)
- {
- m_nPreprocessingMode &= ~nMode;
- }
- else
- {
- m_nPreprocessingMode |= nMode;
- }
- }
-
- void COCRApp::OnUpdatePreferencesPreprocessingmodeFax(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nPreprocessingMode & OCRPP_FAX);
- }
-
- void COCRApp::OnPreferencesPreprocessingmodeNewspaper()
- {
- long nMode=OCRPP_NEWS_PAPER;
-
- if (m_nPreprocessingMode & nMode)
- {
- m_nPreprocessingMode &= ~nMode;
- }
- else
- {
- m_nPreprocessingMode |= nMode;
- }
- }
-
- void COCRApp::OnUpdatePreferencesPreprocessingmodeNewspaper(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nPreprocessingMode & OCRPP_NEWS_PAPER);
- }
-
- void COCRApp::OnPreferencesPreprocessingmodeOrientation()
- {
- long nMode=OCRPP_ORIENTATION;
-
- if (m_nPreprocessingMode & nMode)
- {
- m_nPreprocessingMode &= ~nMode;
- }
- else
- {
- m_nPreprocessingMode |= nMode;
- }
- }
-
- void COCRApp::OnUpdatePreferencesPreprocessingmodeOrientation(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nPreprocessingMode & OCRPP_ORIENTATION);
- }
-
- void COCRApp::OnPreferencesPreprocessingmodeSkew()
- {
- long nMode=OCRPP_SKEW;
-
- if (m_nPreprocessingMode & nMode)
- {
- m_nPreprocessingMode &= ~nMode;
- }
- else
- {
- m_nPreprocessingMode |= nMode;
- }
- }
-
- void COCRApp::OnUpdatePreferencesPreprocessingmodeSkew(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nPreprocessingMode & OCRPP_SKEW);
- }
-
- void COCRApp::OnPreferencesPreprocessingmodeDotmatrixdetect()
- {
- long nMode=OCRPP_DOT_MATRIX_DETECT;
-
- if (m_nPreprocessingMode & nMode)
- {
- m_nPreprocessingMode &= ~nMode;
- }
- else
- {
- m_nPreprocessingMode |= nMode;
- }
- }
-
- void COCRApp::OnUpdatePreferencesPreprocessingmodeDotmatrixdetect(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nPreprocessingMode & OCRPP_DOT_MATRIX_DETECT);
- }
-
- void COCRApp::OnPreferencesPreprocessingmodeAutosetdegrade()
- {
- long nMode=OCRPP_AUTO_SET_DEGRADE;
-
- if (m_nPreprocessingMode & nMode)
- {
- m_nPreprocessingMode &= ~nMode;
- }
- else
- {
- m_nPreprocessingMode |= nMode;
- }
- }
-
- void COCRApp::OnUpdatePreferencesPreprocessingmodeAutosetdegrade(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nPreprocessingMode & OCRPP_AUTO_SET_DEGRADE);
- }
-
- void COCRApp::OnPreferencesPreprocessingmodeAutofax()
- {
- long nMode=OCRPP_AUTO_FAX;
-
- if (m_nPreprocessingMode & nMode)
- {
- m_nPreprocessingMode &= ~nMode;
- }
- else
- {
- m_nPreprocessingMode |= nMode;
- }
- }
-
- void COCRApp::OnUpdatePreferencesPreprocessingmodeAutofax(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nPreprocessingMode & OCRPP_AUTO_FAX);
- }
-
- void COCRApp::OnPreferencesPreprocessingmodeTextorientation()
- {
- long nMode=OCRPP_TEXT_ORIENTATION;
-
- if (m_nPreprocessingMode & nMode)
- {
- m_nPreprocessingMode &= ~nMode;
- }
- else
- {
- m_nPreprocessingMode |= nMode;
- }
- }
-
- void COCRApp::OnUpdatePreferencesPreprocessingmodeTextorientation(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nPreprocessingMode & OCRPP_TEXT_ORIENTATION);
- }
-
- void COCRApp::OnPreferencesPreprocessingmodeFullorientation()
- {
- long nMode=OCRPP_FULL_ORIENTATION;
-
- if ((m_nPreprocessingMode & nMode) == nMode)
- {
- m_nPreprocessingMode &= ~nMode;
- }
- else
- {
- m_nPreprocessingMode |= nMode;
- }
- }
-
- void COCRApp::OnUpdatePreferencesPreprocessingmodeFullorientation(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck((m_nPreprocessingMode & OCRPP_FULL_ORIENTATION) == OCRPP_FULL_ORIENTATION);
- }
-
- void COCRApp::OnPreferencesPreprocessingmodeDoright()
- {
- long nMode=OCRPP_DO_RIGHT;
-
- if ((m_nPreprocessingMode & nMode) == nMode)
- {
- m_nPreprocessingMode &= ~nMode;
- }
- else
- {
- m_nPreprocessingMode |= nMode;
- }
- }
-
- void COCRApp::OnUpdatePreferencesPreprocessingmodeDoright(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck((m_nPreprocessingMode & OCRPP_DO_RIGHT) == OCRPP_DO_RIGHT);
- }
-
- void COCRApp::OnPreferencesRecognitionmodeStandard()
- {
- m_nRecognitionMode = OCRREC_STANDARD;
- }
-
- void COCRApp::OnUpdatePreferencesRecognitionmodeStandard(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nRecognitionMode == OCRREC_STANDARD);
- }
-
- void COCRApp::OnPreferencesRecognitionmodeDegraded()
- {
- m_nRecognitionMode = OCRREC_DEGRADED;
- }
-
- void COCRApp::OnUpdatePreferencesRecognitionmodeDegraded(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nRecognitionMode == OCRREC_DEGRADED);
- }
-
- void COCRApp::OnPreferencesRecognitionmodeUnknown()
- {
- m_nRecognitionMode = OCRREC_UNKNOWN;
- }
-
- void COCRApp::OnUpdatePreferencesRecognitionmodeUnknown(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nRecognitionMode == OCRREC_UNKNOWN);
- }
-
- void COCRApp::OnPreferencesVerifiermodeNone()
- {
- m_nVerifierMode = OCRVER_NONE;
- }
-
- void COCRApp::OnUpdatePreferencesVerifiermodeNone(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nVerifierMode == OCRVER_NONE);
- }
-
- void COCRApp::OnPreferencesVerifiermodeChar()
- {
- m_nVerifierMode = OCRVER_CHAR;
- }
-
- void COCRApp::OnUpdatePreferencesVerifiermodeChar(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nVerifierMode == OCRVER_CHAR);
- }
-
- void COCRApp::OnPreferencesVerifiermodeWord()
- {
- m_nVerifierMode = OCRVER_WORD;
- }
-
- void COCRApp::OnUpdatePreferencesVerifiermodeWord(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_nVerifierMode == OCRVER_WORD);
- }
-
- void COCRApp::OnPreferencesVerifierthreshold()
- {
- COcrDemoNumberDlg dlg;
-
- dlg.m_strTitle = _T("Verifier Threshold");
- dlg.m_strLabel = _T("&Amount");
- dlg.m_nValue = m_nVerifierThreshold;
- dlg.m_nMin = 0;
- dlg.m_nMax = 999;
- dlg.m_nPage = 100;
-
- if (dlg.DoModal() == IDOK)
- {
- m_nVerifierThreshold = dlg.m_nValue;
- }
- }
-
- void COCRApp::OnPreferencesMinpointsize()
- {
- COcrDemoNumberDlg dlg;
-
- dlg.m_strTitle = _T("Min Point Size");
- dlg.m_strLabel = _T("&Amount");
- dlg.m_nValue = m_nMinPointSize;
- dlg.m_nMin = 1;
- dlg.m_nMax = 100;
- dlg.m_nPage = 10;
-
- if (dlg.DoModal() == IDOK)
- {
- m_nMinPointSize = dlg.m_nValue;
- }
- }
-
- void COCRApp::OnPreferencesMaxpointsize()
- {
- COcrDemoNumberDlg dlg;
-
- dlg.m_strTitle = _T("Max Point Size");
- dlg.m_strLabel = _T("&Amount");
- dlg.m_nValue = m_nMaxPointSize;
- dlg.m_nMin = 1;
- dlg.m_nMax = 100;
- dlg.m_nPage = 10;
-
- if (dlg.DoModal() == IDOK)
- {
- m_nMaxPointSize = dlg.m_nValue;
- }
- }
-
- void COCRApp::OnPreferencesTextorientlimit()
- {
- COcrDemoNumberDlg dlg;
-
- dlg.m_strTitle = _T("Text Orient Limit");
- dlg.m_strLabel = _T("&Amount");
- dlg.m_nValue = m_nTextOrientLimit;
- dlg.m_nMin = -1;
- dlg.m_nMax = 999;
- dlg.m_nPage = 100;
-
- if (dlg.DoModal() == IDOK)
- {
- m_nTextOrientLimit = dlg.m_nValue;
- }
- }
-
- void COCRApp::OnPreferencesHeaderfooterprocess()
- {
- if (m_bHeaderFooterProcess == TRUE)
- {
- m_bHeaderFooterProcess = FALSE;
- }
- else
- {
- m_bHeaderFooterProcess = TRUE;
- }
- }
-
- void COCRApp::OnUpdatePreferencesHeaderfooterprocess(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_bHeaderFooterProcess);
- }
-
- void COCRApp::OnPreferencesSloppymanual()
- {
- if (m_bSloppyManual == TRUE)
- {
- m_bSloppyManual = FALSE;
- }
- else
- {
- m_bSloppyManual = TRUE;
- }
- }
-
- void COCRApp::OnUpdatePreferencesSloppymanual(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_bSloppyManual);
- }
-
- void COCRApp::OnFileOpen()
- {
- CLeadDlg LTCommDlg;
- RECT rcWin;
- BOOL bContinue=FALSE;
- int nRet;
-
- ::SetRect(&rcWin, 0, 0, 1, 1);
-
- if(LTCommDlg.Create(NULL,0,rcWin,m_pMainWnd,100))
- {
- LTCommDlg.SetEnableMethodErrors(FALSE);
- LTCommDlg.SetFilter("Graphics|*.cmp;*.jpg;*.jff;*.jtf;*.bmp;*.tif;*.tga;*.pcx;*.cal;*.mac;*.mac;*.img;*.msp;*.wpg;*.wpg;*.ras;*.pct;*.pcd;*.eps;*.wmf");
- LTCommDlg.SetFileDlgFlags(0);
- LTCommDlg.SetDialogTitle("Open File");
- LTCommDlg.SetUIFlags( DLG_FO_FILEINFO |
- DLG_FO_MULTIPAGE |
- DLG_FO_SHOWPREVIEW |
- DLG_FO_SHOWSTAMP |
- DLG_FO_95STYLE );
- nRet = LTCommDlg.FileOpen((long)m_pMainWnd->m_hWnd);
- if(!nRet)
- bContinue = TRUE;
- else
- bContinue = FALSE;
- }
- if(bContinue)
- {
- m_nPage = (short)LTCommDlg.GetPageNumber();
- OpenDocumentFile((LPCTSTR)LTCommDlg.GetFileName());
- }
- return;
- }
-