// SupportedCaps.cpp : implementation file // #include "stdafx.h" #include "TwainDemo.h" #include "SupportedCaps.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CSupportedCaps dialog CSupportedCaps::CSupportedCaps(CWnd* pParent /*=NULL*/) : CDialog(CSupportedCaps::IDD, pParent) { //{{AFX_DATA_INIT(CSupportedCaps) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_nCapsCount = 0; m_nAvailableCapsCount = 0; } void CSupportedCaps::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSupportedCaps) DDX_Control(pDX, IDC_STATIC_CAPS_COUNT, m_lblCapsCount); DDX_Control(pDX, IDC_LIST_SUPPORTED_CAPS, m_lstCaps); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CSupportedCaps, CDialog) //{{AFX_MSG_MAP(CSupportedCaps) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSupportedCaps message handlers BOOL CSupportedCaps::OnInitDialog() { CDialog::OnInitDialog(); CTwainDemoApp * pApp = (CTwainDemoApp *)AfxGetApp(); L_INT nRet = TWAIN_SUCCESS; TW_CAPABILITY twCap; memset(&twCap, 0, sizeof(TW_CAPABILITY)); twCap.Cap = CAP_SUPPORTEDCAPS; twCap.ConType = TWON_ARRAY; nRet = pApp->m_MyTwain.GetCapability(&twCap, LTWAIN_CAPABILITY_GETVALUES); if (nRet != TWAIN_SUCCESS) { CString csError; csError.Format(TEXT("Error occurred when calling L_TwainGetCapability, nRet = %d"), nRet); pApp->AddErrorToErrorsList(csError); return FALSE; } pTW_ARRAY pArray = NULL; pTW_ENUMERATION pEnum = NULL; pTW_UINT16 puCap = NULL; switch (twCap.ConType) { case TWON_ARRAY: pArray = (pTW_ARRAY)GlobalLock(twCap.hContainer); m_nCapsCount = pArray->NumItems; puCap = (pTW_UINT16)&pArray->ItemList; break; case TWON_ENUMERATION: pEnum = (pTW_ENUMERATION)GlobalLock(twCap.hContainer); m_nCapsCount = pEnum->NumItems; puCap = (pTW_UINT16)&pEnum->ItemList; break; } m_nAvailableCapsCount = m_nCapsCount; for (int i=0; i