Changing the Display Frequency During Scanning Within an ImageControls 3 Date November 2008 Applies To Kofax ImageControls 2x, 3x Summary This application note contains example code for changing he display frequency during scanning in an ImageControls 3x application Revision 10 Overview ImageControls 3 provides the capability to display all images while they are being scanned This is normally accomplished by connecting the KView to the KScan controls, and automatically displaying the scanned or imported image But, the displaying of images as they are being scanned or imported can negatively impact the ImageControls scan process As an alternative to displaying all images as they are processed, a developer can control the frequency which processed images are displayed For example, instead of displaying each and every image as it is processed, the user may only wish to see every five (5) images processed This is outlined in the ImageControls 3 Programmer's Guide, Chapter 4 Scanning and Importing Images, the section Programmatic Control Over the Frequency of the Display Frequency of Display While Scanning/Importing This project modifies the original demonstration utility, VBDEM32xEXE, source code as provided with the ImageControls 3 Toolkit It provides the ability to alter the frequency at which processed images are displayed The user would select a number between "0" and "9" inclusive A zero (0) would denote the deactivation of any display of processed images A one (1) would denote that all images processed are to be displayed A two (2) would denote that every other image processed be displayed and so on It contains one additional form, frmdisplayfreq, which is a dialog box to select frequency at which images will be displayed This form consists of the following: One (1) label displaying "Display Frequency (0-9):": lbldisplayfreq One (1) text box for the display frequency value: txtdisplayfreq One (1) command button: cmdok The image below displays the placement of these items on the form
A menu selection, mnusourcedisplayfreq, was added after the Batch Processing menu item in the Source pull down menu of the main form, frmmain When it is selected, the form frmdisplayfreq is displayed When the user closes the dialog box, it is unloaded Private Sub mnusourcedisplayfreq_click() '***** Display Frequency dialog box Call KFShowFormWithHourGlass(frmDisplayFreq, True) '***** Hide the form Unload frmdisplayfreq The user is able to select the frequency in which the images will be displayed during processing When the form loads, it centers itself and puts the dialog box on top The initial value is derived from a global variable, g_displayfreq Private Sub Form_Load() '***** Center box KFCenterForm Me '***** Put box on top KFPutFormOnTop Me '***** Initial Value for display frequency txtdisplayfreqtext = g_displayfreq When the OK command button is selected, the value for the display frequency is validated Private Sub cmdok_click() Dim sinputno As String sinputno = txtdisplayfreqtext '***** Check for selection that is out of range If (Val(sInputNo) < 0) Then txtdisplayfreqtext = 0 Exit Sub If (Val(sInputNo) > 9) Then txtdisplayfreqtext = 9 Exit Sub '***** If the input was ok, exit '***** Set display freq global variable Page 2
g_displayfreq = (Val(txtDisplayFreqText)) '***** If display freq is 0, deactivate display If g_displayfreq <> 1 Then frmmain!kscan1display = False frmmain!kscan1display = True '***** Hide Display Freq Form MeHide Three new global variables are added to the General Declarations of the KFUTILBAS file: g_displayfreq, g_pefilename and g_pefront These global variables are used to determine the frequency in which images should be displayed, the filename to which the image was saved, and the page to which the image was saved '***** Global variables for display frequency Global g_displayfreq As Integer 'Display Frequency Global g_pefilename As String 'KScanPEFileName Global g_pefront As Boolean 'Front or Back Image When the main form is loaded, Form_Load event, the global variable g_displayfreq is initialized It is initialized to a value of one (1), or to display all images while processing '***** Initialize Display Frequency g_displayfreq = 1 It is determined if the image is a front or back side image during the KScan_PageEnd event '***** Increment page count (unless back of duplex) If Kscan1PEFront Then g_pepagecount = g_pepagecount + 1 g_totalpages = g_totalpages + 1 '***** Set flag for front or back image g_pefront = True g_pefront = False Page 3
Kscan1IOWriteMode = g_pewritemode The filename and page to view are also updated during the KScan_PageEnd event Select Case g_pewritemode Case KGIOWRITEMODEINSERT: KFPageEndNameBuild Case KGIOWRITEMODEAPPEND: KFPageEndNameBuild '***** The KScanPage property is not used when appending '***** This updates the existing g_pepage variable for '***** use with Display Frequency g_pepage = Kscan1PEPageCount + 1 End Select '***** Set filename to nothing so it is not saved '***** (if it is smaller than the delete threshold) If Kscan1PEDelete Then g_pefilename = "" Kscan1PEPage = g_pepage '***** Update KScanPEFileName for Display Freq g_pefilename = Kscan1PEFileName Page 4
Finally, during the KScan_PageDone event the filename, page and whether it is a front or back page are set and the image is viewed If the user has selected zero (0) or one (1) for the display frequency, then the standard way of handling the viewing of scanned image is performed If not, then the images are manually displayed This is placed at the end of the procedure '***** Determine filename, page, front or back image '***** and determine if it should be viewed If g_displayfreq < 2 Then Exit Sub If (g_pepagecount Mod g_displayfreq) = 0 Then If g_pefront Then KViewLeftFileName = g_pefilename KViewLeftAction = KVACTIONOPENIMAGE KViewLeftPage = g_pepage KViewLeftRefresh KViewRightFileName = g_pefilename KViewRightAction = KVACTIONOPENIMAGE KViewRightPage = g_pepage KViewRightRefresh Page 5