Twain_DSM  1.0
Functions | Variables
declarations for our memory management functions...

Functions

DSMENTRY DSM_Entry (TW_IDENTITY *_pOrigin, TW_IDENTITY *_pDest, TW_UINT32 _DG, TW_UINT16 _DAT, TW_UINT16 _MSG, TW_MEMREF _pData)
 Data Source Manager Entry Point. More...
 
BOOL WINAPI DllMain (HINSTANCE _hmodule, DWORD _dwReasonCalled, LPVOID)
 DllMain is only needed for Windows, and it's only needed to collect our instance handle, which is also our module handle. More...
 
BOOL CALLBACK SelectDlgProc (HWND _hWnd, UINT _Message, WPARAM _wParam, LPARAM _lParam)
 We support a selection dialog on Windows. More...
 
BOOL CALLBACK EnumChildProc (HWND hwnd, LPARAM lParam)
 We support a selection dialog on Windows. More...
 
TW_HANDLE PASCAL DSM_MemAllocate (TW_UINT32 _bytes)
 
void PASCAL DSM_MemFree (TW_HANDLE _handle)
 
TW_MEMREF PASCAL DSM_MemLock (TW_HANDLE _handle)
 
void PASCAL DSM_MemUnlock (TW_HANDLE _handle)
 
void * DSM_LoadFunction (void *_pHandle, const char *_pszSymbol)
 This function wraps the function loading calls. More...
 

Variables

TW_INT16 TwLocalize::Language
 Language.
 
BYTE TwLocalize::CharSet
 Character Set.
 
LANGID TwLocalize::LangId
 Language Id.
 
char * TwLocalize::Title
 the Title string
 
char * TwLocalize::Sources
 the Sources string
 
char * TwLocalize::Select
 the Select string
 
char * TwLocalize::Cancel
 the Cancel string
 

Detailed Description

Function Documentation

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  _hmodule,
DWORD  _dwReasonCalled,
LPVOID   
)

DllMain is only needed for Windows, and it's only needed to collect our instance handle, which is also our module handle.

Don't ever put anything else in here, not even logging messages. It just isn't safe...

Parameters
[in]_hmodulehandle to the application that loaded the DSM
[in]_dwReasonCalledwhy this function is being called
Returns
TRUE

Definition at line 1425 of file dsm.cpp.

References CTwnDsm::DSMGetState(), dsmState_Open, g_hinstance, g_ptwndsm, kLOG, and kLOGERR.

◆ DSM_Entry()

DSMENTRY DSM_Entry ( TW_IDENTITY _pOrigin,
TW_IDENTITY _pDest,
TW_UINT32  _DG,
TW_UINT16  _DAT,
TW_UINT16  _MSG,
TW_MEMREF  _pData 
)

Data Source Manager Entry Point.

The entry point we want to return to the caller, instead of the one they thought they were getting from TWAIN_32.DLL...

The only entry point into the Data Source Manager. This is the only function not a part of CTwnDsm. It's responsible for managing the class. We keep things organized this way to make sure that we don't allocate any resources until MSG_OPENDSM, and that we release all resources as a part of MSG_CLOSEDSM. If this is done correctly then we won't mind if the library isn't freed (which has been seen to happen sometimes with COM)...

Defined in twain.h

Parameters
[in]_pOriginIdentifies the source module of the message. This could identify an Application, a Source, or the Source Manager.
[in]_pDestIdentifies the destination module for the message. This could identify an application or a data source. If this is NULL, the message goes to the Source Manager.
[in]_DGThe Data Group. Example: DG_IMAGE.
[in]_DATThe Data Attribute Type. Example: DAT_IMAGEMEMXFER.
[in]_MSGThe message. Messages are interpreted by the destination module with respect to the Data Group and the Data Attribute Type.
Example: MSG_GET.
[in,out]_pDataA pointer to the data structure or variable identified by the Data Attribute Type. Example: (TW_MEMREF)&ImageMemXfer where ImageMemXfer is a TW_IMAGEMEMXFER structure.
Returns
a valid TWRC_xxxx return code. Example: TWRC_SUCCESS.

Definition at line 314 of file dsm.cpp.

References CTwnDsm::DSM_Entry(), CTwnDsm::DSMGetState(), dsmState_Open, g_ptwndsm, and kPANIC.

◆ DSM_LoadFunction()

void* DSM_LoadFunction ( void *  _pHandle,
const char *  _pszSymbol 
)

This function wraps the function loading calls.

Linux has a special way to check dlsym failures.

Definition at line 3892 of file dsm.cpp.

References kLOG, kLOGERR, and LOADFUNCTION.

◆ EnumChildProc()

BOOL CALLBACK EnumChildProc ( HWND  hwnd,
LPARAM  lParam 
)

We support a selection dialog on Windows.

This function is part of our CTwnDsm class, so we don't have to have a lot of pointers, and we can keep things private, unlike what we would have to do if we put this code into the function we actually pass to DialogBox...

Parameters
[in]hwndWindow handle of the dialog
[in]lParamlparam
Returns
TRUE

Definition at line 1505 of file dsm.cpp.

Referenced by CTwnDsm::SelectDlgProc().

◆ SelectDlgProc()

BOOL CALLBACK SelectDlgProc ( HWND  _hWnd,
UINT  _Message,
WPARAM  _wParam,
LPARAM  _lParam 
)

We support a selection dialog on Windows.

I wish we didn't, it's more trouble than it's worth, but it's part of that legacy thing. This function is properly constructed for use with DialogBox...

Parameters
[in]_hWndWindow handle of the dialog
[in]_Messagemessage
[in]_wParamwparam
[in]_lParamlparam
Returns
FALSE if we processed the message

Definition at line 1472 of file dsm.cpp.

References g_ptwndsm, and CTwnDsm::SelectDlgProc().