#include "ltwrappr.h"
virtual L_INT LWia::GetRootItem(pItem, ppWiaRootItem)
Gets the root item for the passed pItem parameter.
Valid pointer to a type IWiaItem or IWiaItem2 object (IWiaItem if using WIA Version 1.0; IWiaItem2 if using WIA Version 2.0), representing an item's root item.
If this parameter is NULL, the ppWiaRootItem parameter will be filled with pointer to the device's root item.
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.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
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, the ppWiaRootItem parameter is updated with a pointer to the device's root item (representing 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
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;
}