From: <jim...@us...> - 2010-03-10 21:13:41
|
Revision: 81 http://twain-samples.svn.sourceforge.net/twain-samples/?rev=81&view=rev Author: jim0watters Date: 2010-03-10 21:13:24 +0000 (Wed, 10 Mar 2010) Log Message: ----------- Add option of KeepUIEnabled if scanning with UI. Clean up resource.h file of unused items. Modified Paths: -------------- trunk/TWAIN-Samples/Twain_App_sample01/ChangeLog.txt trunk/TWAIN-Samples/Twain_App_sample01/visual_studio_mfc/mfc.rc trunk/TWAIN-Samples/Twain_App_sample01/visual_studio_mfc/mfcDlgConfigure.cpp trunk/TWAIN-Samples/Twain_App_sample01/visual_studio_mfc/mfcDlgConfigure.h trunk/TWAIN-Samples/Twain_App_sample01/visual_studio_mfc/resource.h Modified: trunk/TWAIN-Samples/Twain_App_sample01/ChangeLog.txt =================================================================== --- trunk/TWAIN-Samples/Twain_App_sample01/ChangeLog.txt 2010-02-16 22:50:28 UTC (rev 80) +++ trunk/TWAIN-Samples/Twain_App_sample01/ChangeLog.txt 2010-03-10 21:13:24 UTC (rev 81) @@ -1,3 +1,7 @@ +2010-03-10 JFL Peripheral Solutions ji...@jf... + + * mfcDlgConfigure.cpp Add option of KeepUIEnabled if scanning with UI + 2010-02-16 JFL Peripheral Solutions ji...@jf... * TwainApp.cpp, TwainApp.h, mfcDlgConfigure.cpp, & mfcDlgConfigure.h Modified: trunk/TWAIN-Samples/Twain_App_sample01/visual_studio_mfc/mfc.rc =================================================================== --- trunk/TWAIN-Samples/Twain_App_sample01/visual_studio_mfc/mfc.rc 2010-02-16 22:50:28 UTC (rev 80) +++ trunk/TWAIN-Samples/Twain_App_sample01/visual_studio_mfc/mfc.rc 2010-03-10 21:13:24 UTC (rev 81) @@ -116,8 +116,9 @@ LTEXT "",IDC_STC_DS,7,1,304,38 CONTROL "",IDLC_CAPS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_GROUP | WS_TABSTOP,7,39,304,148 PUSHBUTTON "Path...",IDB_PATH,7,190,33,12 - EDITTEXT IDC_EDIT1,46,190,265,12,ES_AUTOHSCROLL | ES_READONLY - CONTROL "Show UI",IDC_SHOWUI,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,7,215,76,8 + EDITTEXT IDC_SAVEPATH,46,190,265,12,ES_AUTOHSCROLL | ES_READONLY + CONTROL "Show UI",IDC_SHOWUI,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,7,204,76,8 + CONTROL "Keep Open",IDC_KEEPOPEN,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,17,215,76,8 LTEXT "Image Info",IDC_STATIC,319,7,237,8 EDITTEXT IDC_IMAGEINFO,319,16,237,48,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP LTEXT "Extended Image Info",IDC_STATIC,319,71,237,8 Modified: trunk/TWAIN-Samples/Twain_App_sample01/visual_studio_mfc/mfcDlgConfigure.cpp =================================================================== --- trunk/TWAIN-Samples/Twain_App_sample01/visual_studio_mfc/mfcDlgConfigure.cpp 2010-02-16 22:50:28 UTC (rev 80) +++ trunk/TWAIN-Samples/Twain_App_sample01/visual_studio_mfc/mfcDlgConfigure.cpp 2010-03-10 21:13:24 UTC (rev 81) @@ -111,6 +111,7 @@ ,m_sStr_ImageInfo(_T("")) ,m_sStr_ExtImageInfo(_T("")) ,m_bShowUI(FALSE) + ,m_bKeepEnabled(FALSE) ,m_pCapSettings(NULL) { // fill our identity structure @@ -129,8 +130,9 @@ DDX_Text(pDX, IDC_IMAGEINFO, m_sStr_ImageInfo); DDX_Text(pDX, IDC_EXTIMAGEINFO, m_sStr_ExtImageInfo); DDX_Check(pDX, IDC_SHOWUI, m_bShowUI); + DDX_Check(pDX, IDC_KEEPOPEN, m_bKeepEnabled); DDX_Control(pDX, IDLC_CAPS, m_ListCtrl_Caps); - DDX_Control(pDX, IDC_EDIT1, m_EdtSavePath); + DDX_Control(pDX, IDC_SAVEPATH, m_EdtSavePath); } BEGIN_MESSAGE_MAP(CmfcDlgConfigure, CDialog) @@ -814,8 +816,6 @@ if(m_DSMState > 4) return; // Already Enabled - m_DSMessage = (TW_UINT16)-1; - UpdateData(true); // -Enable the data source. This puts us in state 5 which means that we @@ -829,68 +829,74 @@ return; } - // now we have to wait until we hear something back from the DS. - while((TW_UINT16)-1 == m_DSMessage) + do // If showing UI and KeepUIOpen is Enabled then we will loop here until cancle { - // If we are using callbacks, there is nothing to do here except sleep - // and wait for our callback from the DS. If we are not using them, - // then we have to poll the DSM. - MSG Msg; + m_DSMessage = (TW_UINT16)-1; - if(!GetMessage((LPMSG)&Msg, NULL, 0, 0)) + // now we have to wait until we hear something back from the DS. + while((TW_UINT16)-1 == m_DSMessage) { - break;//WM_QUIT - } - TW_EVENT twEvent = {0}; - twEvent.pEvent = (TW_MEMREF)&Msg; - twEvent.TWMessage = MSG_NULL; - TW_UINT16 twRC = TWRC_NOTDSEVENT; - twRC = _DSM_Entry( getAppIdentity(), - m_pDataSource, - DG_CONTROL, - DAT_EVENT, - MSG_PROCESSEVENT, - (TW_MEMREF)&twEvent); - if(!gUSE_CALLBACKS && twRC==TWRC_DSEVENT) - { - // check for message from Source - switch (twEvent.TWMessage) + // If we are using callbacks, there is nothing to do here except sleep + // and wait for our callback from the DS. If we are not using them, + // then we have to poll the DSM. + MSG Msg; + + if(!GetMessage((LPMSG)&Msg, NULL, 0, 0)) { - case MSG_XFERREADY: - case MSG_CLOSEDSREQ: - case MSG_NULL: - m_DSMessage = twEvent.TWMessage; - break; + break;//WM_QUIT + } + TW_EVENT twEvent = {0}; + twEvent.pEvent = (TW_MEMREF)&Msg; + twEvent.TWMessage = MSG_NULL; + TW_UINT16 twRC = TWRC_NOTDSEVENT; + twRC = _DSM_Entry( getAppIdentity(), + m_pDataSource, + DG_CONTROL, + DAT_EVENT, + MSG_PROCESSEVENT, + (TW_MEMREF)&twEvent); - case MSG_CLOSEDSOK: - TRACE("\nError - MSG_CLOSEDSOK in MSG_PROCESSEVENT loop for Scan\n"); - break; + if(!gUSE_CALLBACKS && twRC==TWRC_DSEVENT) + { + // check for message from Source + switch (twEvent.TWMessage) + { + case MSG_XFERREADY: + case MSG_CLOSEDSREQ: + case MSG_NULL: + m_DSMessage = twEvent.TWMessage; + break; - default: - TRACE("\nError - Unknown message in MSG_PROCESSEVENT loop for Scan\n"); - break; + case MSG_CLOSEDSOK: + TRACE("\nError - MSG_CLOSEDSOK in MSG_PROCESSEVENT loop for Scan\n"); + break; + + default: + TRACE("\nError - Unknown message in MSG_PROCESSEVENT loop for Scan\n"); + break; + } } + if(twRC!=TWRC_DSEVENT) + { + TranslateMessage ((LPMSG)&Msg); + DispatchMessage ((LPMSG)&Msg); + } } - if(twRC!=TWRC_DSEVENT) - { - TranslateMessage ((LPMSG)&Msg); - DispatchMessage ((LPMSG)&Msg); - } - } - // At this point the source has sent us a callback saying that it is ready to - // transfer the image. + // At this point the source has sent us a callback saying that it is ready to + // transfer the image. - if(m_DSMessage == MSG_XFERREADY) - { - // move to state 6 as a result of the data source. We can start a scan now. - m_DSMState = 6; - updateIMAGEINFO(); - UpdateImageInfo(); - StartScan(); - } + if(m_DSMessage == MSG_XFERREADY) + { + // move to state 6 as a result of the data source. We can start a scan now. + m_DSMState = 6; + updateIMAGEINFO(); + UpdateImageInfo(); + StartScan(); + } + }while(m_bShowUI && m_bKeepEnabled && m_DSMessage != MSG_CLOSEDSREQ); // Scan is done, disable the ds, thus moving us back to state 4 where we // can negotiate caps again. Modified: trunk/TWAIN-Samples/Twain_App_sample01/visual_studio_mfc/mfcDlgConfigure.h =================================================================== --- trunk/TWAIN-Samples/Twain_App_sample01/visual_studio_mfc/mfcDlgConfigure.h 2010-02-16 22:50:28 UTC (rev 80) +++ trunk/TWAIN-Samples/Twain_App_sample01/visual_studio_mfc/mfcDlgConfigure.h 2010-03-10 21:13:24 UTC (rev 81) @@ -119,4 +119,5 @@ CString m_sStr_ExtImageInfo; CListCtrl m_ListCtrl_Caps; BOOL m_bShowUI; + BOOL m_bKeepEnabled; }; Modified: trunk/TWAIN-Samples/Twain_App_sample01/visual_studio_mfc/resource.h =================================================================== --- trunk/TWAIN-Samples/Twain_App_sample01/visual_studio_mfc/resource.h 2010-02-16 22:50:28 UTC (rev 80) +++ trunk/TWAIN-Samples/Twain_App_sample01/visual_studio_mfc/resource.h 2010-03-10 21:13:24 UTC (rev 81) @@ -5,28 +5,13 @@ #define IDM_ABOUTBOX 0x0010 #define IDD_ABOUTBOX 100 #define IDS_ABOUTBOX 101 -#define IDD_MFC32_DIALOG 102 #define IDD_MFC32_APP 102 #define IDR_MAINFRAME 128 #define IDD_TW_ENUMERATION 129 #define IDD_MFC32_CONFIGURE 130 -#define IDB_CONNECT_DSM 1000 -#define IDC_STATUS 1001 #define IDL_DS 1002 -#define IDC_CAP1 1003 -#define IDC_CAP2 1004 -#define IDC_CAP3 1005 -#define IDC_CAP4 1006 -#define IDC_CAP5 1007 -#define IDC_CAP6 1008 -#define IDC_CAP7 1009 -#define IDL_CAPS 1010 -#define IDC_CAP8 1011 -#define IDC_CAP9 1012 #define IDB_CONNECT_DS 1013 -#define IDB_DISCONNECT_DS 1014 #define IDB_DEFAULT_DS 1014 -#define IDB_DISCONNECT_DSM 1015 #define IDB_SCAN 1016 #define IDC_STC_DS 1017 #define IDC_LIST1 1018 @@ -34,10 +19,10 @@ #define IDC_IMAGEINFO 1019 #define IDC_EXTIMAGEINFO 1020 #define IDC_SHOWUI 1021 -#define IDC_EDIT1 1022 -#define IDC_BUTTON1 1023 +#define IDC_SAVEPATH 1022 #define IDB_PATH 1023 #define IDLC_CAPS 1024 +#define IDC_KEEPOPEN 1025 // Next default values for new objects // This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |