📄 source10.cpp
字号:
// source10.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
#include "twain.h"
#include "source10.h"
#include "TitleDlg.h"
//#include "SetValue.h"
#include "SetScanner.h"
#include "Twd_type.h"
//#include "Prot.h"
// Extern Function Prototypes -------------------------------------------
extern void LogMessage(char msg[]);
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////
#define NUM_PIXTYPES 4 // size of number of pixel types array
/*** Global variables *///
HANDLE hDSInst; // Keep track of who we are
HPALETTE hDibPal; // Color palette handle
UINT TimerOut = 9999; // timeout value for message boxes
char SourceControl[MAX_TWPATH] = {'\0'};
// Support for pixel types TW_ARRAY container
//TW_ARRAY PixelTypesTWArray={TWTY_UINT16, NUM_PIXTYPES, {57}};
//TW_UINT16 PixelTypesList[NUM_PIXTYPES]={TWPT_BW, TWPT_GRAY, TWPT_RGB,
// TWPT_PALETTE};
/*** Global variables - Source Environment ***/
TW_IDENTITY dsIdentity; // 数据源标志
TW_IDENTITY appIdentity; // 驱动数据源的应用程序
TW_STATUS twStatus = {TWCC_SUCCESS, FALSE};//状态信息
/*** External stuff ***/
extern MAPPER ControlMap[];
extern MAPPER ImageMap[];
extern HANDLE hImageDlg;
/////////////////////////////////////////////////////////////////////////////
// CSource10App
BEGIN_MESSAGE_MAP(CSource10App, CWinApp)
//{{AFX_MSG_MAP(CSource10App)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSource10App construction
CSource10App::CSource10App()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
CSource10App theApp;
//////////////////////////////////////////////////////////////////////////////
//根据数据源的入口函数入口调用分发函数
TW_UINT16 CALLBACK DS_Entry(pTW_IDENTITY pSrc, TW_UINT32 DG,
TW_UINT16 DAT, TW_UINT16 MSG,
TW_MEMREF pData)
{
TW_UINT16 twRc;
TWMSG twMsg;
char* pTempMem=NULL;
if ((!appIdentity.Id) || (appIdentity.Id == pSrc->Id))//应用程序调用
{
if (MSG == MSG_PROCESSEVENT)
{
LogMessage("Process event message at source\r\n");
//数据源句柄所对应的对话框
if (hImageDlg && IsDialogMessage((struct HWND__ *)hImageDlg, (LPMSG)(((pTW_EVENT)pData)->pEvent)))
{
LogMessage("Process event Message directed to data source dialog\r\n");
twRc = TWRC_DSEVENT;
// you should, for proper form, return
// a MSG_NULL for all windows messages processed by the Data Source
// NOTE: could slip by with a default case in the App and no MSG_NULL
// but that would be cheating!!
//
((pTW_EVENT)pData)->TWMessage = MSG_NULL;
}
else
{
LogMessage("Process event message at source\r\n");
twRc = TWRC_NOTDSEVENT;
}
}
else
{
// Reset the condition code
if (DG != DG_CONTROL && DAT != DAT_STATUS)
{
twStatus.ConditionCode = TWCC_SUCCESS;
}
//为分发函数建立消息结构
twMsg.pSrc = pSrc;
twMsg.DG = DG;
twMsg.DAT = DAT;
twMsg.MSG = MSG;
twMsg.pData = pData;
// Route the Source message.
if (DG == DG_CONTROL)
{
twRc = Dispatch(&twMsg, ControlMap, DAT);
}
else
if (DG == DG_IMAGE)
{
twRc = Dispatch(&twMsg, ImageMap, DAT);
}
else
{
twStatus.ConditionCode = TWCC_BADPROTOCOL;
twRc = TWRC_FAILURE;
}//End of else of the if (DG == DG_IMAGE)
}//End of else of the if (MSG == MSG_PROCESSEVENT)
}//End of if ((!appIdentity.Id) || (appIdentity.Id == pSrc->Id))
else
{
twStatus.ConditionCode = TWCC_BADPROTOCOL;
twRc = TWRC_FAILURE;
}
return twRc;
}
/////////////////////////////////////////////////////////////////
//Do the follow instructs when the data source was invoked
// by the data source manager.
//
BOOL CSource10App::InitInstance()
{
// Initialize any necessary globals
//hDSInst = hModule; hModule is the handle of the DLLMAIN();
hDSInst=m_hInstance;
// state 3
// Clear out calling app's identity
appIdentity.Id = 0L;
// Setup Source's identity and group supported
dsIdentity.Id = 0L;
dsIdentity.ProtocolMajor = TWON_PROTOCOLMAJOR;
dsIdentity.ProtocolMinor = TWON_PROTOCOLMINOR;
dsIdentity.Version.MajorNum = 1;
dsIdentity.Version.MinorNum = 0;
dsIdentity.Version.Language = TWLG_USA;
dsIdentity.Version.Country = TWCY_USA;
dsIdentity.SupportedGroups = DG_CONTROL | DG_IMAGE;
LoadString((struct HINSTANCE__ *)hDSInst, VERSION_INFO, dsIdentity.Version.Info, sizeof(TW_STR32));
LoadString((struct HINSTANCE__ *)hDSInst, MANUFACTURER, dsIdentity.Manufacturer, sizeof(TW_STR32));
LoadString((struct HINSTANCE__ *)hDSInst, PRODFAMILY, dsIdentity.ProductFamily, sizeof(TW_STR32));
LoadString((struct HINSTANCE__ *)hDSInst, PRODNAME, dsIdentity.ProductName, sizeof(TW_STR32));
// pTitleDlg = new CTitleDlg(NULL);
// pTitleDlg->Create(CTitleDlg::IDD,NULL);
return(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -