LWia::GetRootItem

#include "ltwrappr.h"

virtual L_INT LWia::GetRootItem(pItem, ppWiaRootItem)

L_VOID * pItem;

pointer to IWiaItem or IWiaItem2 interface

L_VOID ** ppWiaRootItem;

address of pointer to IWiaItem or IWiaItem2 interface variable to be updated

Gets the root item for the passed pItem parameter.

Parameter

Description

pItem

Valid pointer to a type IWiaItem or IWiaItem2 object (IWiaItem if using WIA Version 1.0; IWiaItem2 if using WIA Version 2.0), which represents the item for which you wish to retrieve its root item.

 

If this parameter is NULL, then the ppWiaRootItem parameter will be filled with pointer to the device's root item.

ppWiaRootItem

Address of the pointer to IWiaItem or IWiaItem2 interface variable to be updated with the root item for the item passed through the pItem parameter.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This feature is available in LEADTOOLS version 16 or higher.

Gets the root item for the item passed through the pItem parameter.

If pItem is NULL then the ppWiaRootItem parameter will be updated with a pointer to the device's root item (which represents the device itself).

This is the first function you need to call to get a pointer to the device's root item. Then pass that pointer to the LWia::EnumChildItems function to enumerate all of the device's child items. Then call this function again for any child item of the enumerated items to retrieve its root item if needed.

Required DLLs and Libraries

LTWIA

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

LWia::EnumChildItems, LWia::InitSession, LWia::EndSession, Class Members

Topics:

Managing WIA Sources

 

WIA Functionality: Property Functions

Example

class CMyWIA : public LWia 
{ 
public: 
   L_INT SetItemPropertiesCallBack(L_INT PropertyID, L_INT nError, L_VOID * pValue); 
   L_INT EnumItemsCallBack(L_INT nItemsCount, L_VOID * pItem); 
}; 
 
L_INT CMyWIA::SetItemPropertiesCallBack(L_INT PropertyID, L_INT nError, L_VOID * pValue) 
{ 
   L_TCHAR szMsg[MAX_PATH] = TEXT(""); 
   if(nError != WIA_SUCCESS) 
   { 
      /* Display error message for the user to inform him about the failed property set */ 
      wsprintf(szMsg,  
               TEXT("Failed to set the property below:\n\n") 
               TEXT("Property ID: %n.\n") 
               TEXT("User Value: %n.\n") 
               TEXT("Error Code: %n."), 
               PropertyID, (*(L_INT*)pValue), nError); 
 
      MessageBox(NULL, szMsg, TEXT("ERROR"), MB_OK|MB_ICONERROR); 
   } 
   return WIA_SUCCESS; 
} 
 
L_INT CMyWIA::EnumItemsCallBack(L_INT nItemsCount, L_VOID * pItem) 
{ 
   UNREFERENCED_PARAMETER(nItemsCount); 
 
   L_INT nRet; 
   LWIAPROPERTIES WiaProps; 
 
   if(pItem != NULL) 
   { 
      /* Get the current properties for the received item */ 
      nRet = GetProperties(pItem, &WiaProps); 
      if(nRet != WIA_SUCCESS) 
         return nRet; 
 
      /* Change some of the item's properties */ 
      WiaProps.nMaxNumOfPages = ALL_PAGES; 
      WiaProps.pDataTransfer->nImageDataType = WIA_DATA_GRAYSCALE; 
      WiaProps.pImageEffects->nBrightness = 250; 
 
      /* Set back the received item properties */ 
      nRet = SetProperties(pItem, &WiaProps); 
      if(nRet != WIA_SUCCESS) 
         return nRet; 
 
      nRet = FreeItem(pItem); 
      if(nRet != WIA_SUCCESS) 
         return nRet; 
   } 
 
   return WIA_SUCCESS; 
} 
 
L_INT LWIA__GetRootItemExample() 
{ 
   IWiaItem * pRootItem = NULL; 
   L_INT nRet; 
   CMyWIA MyClass; 
 
   nRet = MyClass.SelectDeviceDlg(WiaDeviceTypeDefault, 0); 
   if(nRet != WIA_SUCCESS) 
      return nRet; 
 
   /* Get a pointer to the WIA device's root items */ 
   nRet = MyClass.GetRootItem(NULL, (L_VOID**)&pRootItem); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   nRet = MyClass.EnumChildItems(pRootItem); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   return SUCCESS; 
} 
Help Version 20.0.2018.6.20
Products | Support | Contact Us | Copyright Notices
© 1991-2018 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS WIA C++ Class Library Help