#include "stdafx.h"
#include "DynamicFunc.h"

//////////////////////////////////////////////////////////////////////////
//define 
pPrinterOpen	PrinterOpen;	
pPrinterClose	PrinterClose;

pPrintText		PrintText;
pPrintTextW   PrintTextW;
pLineFeed		LineFeed;		
pPrintBitmap	PrintBitmap;	
pPrintBarcode	PrintBarcode;		

pSetCharacterSet	SetCharacterSet;
pSetInterChrSet		SetInterChrSet;	
pGetCharacterSet	GetCharacterSet;
pGetInterChrSet		GetInterChrSet;	

pSetUpsideDown	SetUpsideDown;
pSetLeftMargin	SetLeftMargin;
pSetPrintWidth	SetPrintWidth;

pDirectIO		DirectIO;	


///////// MSR
pMsrReadReady	 MsrReadReady;	
pMsrReadCancel	 MsrReadCancel;	
pMsrReadTrack	 MsrReadTrack;
pMsrReadFullTrack MsrReadFullTrack;
pMsrRead1Track	 MsrRead1Track;
pMsrRead2Track	 MsrRead2Track;
pMsrRead3Track	 MsrRead3Track;
pGetTrack1		 GetTrack1;
pGetTrack2		 GetTrack2;
pGetTrack3		 GetTrack3;

pSetMsrMsgMode		SetMsrMsgMode;

//////// SCR
pScrPowerDown		ScrPowerDown;
pScrPowerUp			ScrPowerUp;
pScrExchangeAPDU	ScrExchangeAPDU;
pScrOperationMode	ScrOperationMode;
pScrChkCardStatus	ScrChkCardStatus;



pCheckPrinter	CheckPrinter;	
pGetPowerValue	GetPowerValue;	
pGetStat		GetStat;
pGetResultCode	GetResultCode;


pFormFeed			FormFeed;
pNextPrintPos		NextPrintPos;	
pInitializePrinter	InitializePrinter;
pSelectMode			SelectMode;
pAutoCalibration	AutoCalibration;


pSelectPageMode					SelectPageMode;
pSetPrintAreaInPageMode			SetPrintAreaInPageMode;
pSelectPrintDirectionInPageMode	SelectPrintDirectionInPageMode;
pSetAbsolutePrintPosition		SetAbsolutePrintPosition;
pSetAbsoluteVerticalPrintPositionInPageMode SetAbsoluteVerticalPrintPositionInPageMode;
pPrintDataInPageMode			PrintDataInPageMode;

pSetPrintAreaInPM			SetPrintAreaInPM;
pSetPrintDirectionInPM		SetPrintDirectionInPM;
pSetVerticalPositionInPM	SetVerticalPositionInPM;
pSetHorizontalPositionInPM	SetHorizontalPositionInPM;

pDrawLineInPM DrawLineInPM;
pDrawBoxInPM DrawBoxInPM;

HMODULE	m_hDll;

void UnloadDll()
{
	FreeLibrary(m_hDll);
}

BOOL LoadDll()
{ 	
// This file supports all Platforms, but this sample code only supports PC Platforms
// so if you want to use this sample code in PDA platform, you should create a new project for 
// PC Platform and add file in your project.	
            
	m_hDll = LoadLibrary(TEXT("bxl.dll"));	

	if (m_hDll == 0)
		return FALSE;

	PrinterOpen			= (pPrinterOpen)GetProcAddress(m_hDll, TEXT("PrinterOpen"));	
	PrinterClose		= (pPrinterClose)GetProcAddress(m_hDll, TEXT("PrinterClose"));

	PrintText			= (pPrintText)GetProcAddress(m_hDll, TEXT("PrintText"));	
  PrintTextW    = (pPrintTextW)GetProcAddress(m_hDll, TEXT("PrintTextW"));
	LineFeed			= (pLineFeed)GetProcAddress(m_hDll, TEXT("LineFeed"));	
	PrintBitmap			= (pPrintBitmap)GetProcAddress(m_hDll, TEXT("PrintBitmap"));	
	PrintBarcode		= (pPrintBarcode)GetProcAddress(m_hDll, TEXT("PrintBarcode"));	
	
	SetCharacterSet		= (pSetCharacterSet)GetProcAddress(m_hDll, TEXT("SetCharacterSet"));	
	SetInterChrSet		= (pSetInterChrSet)GetProcAddress(m_hDll, TEXT("SetInterChrSet"));	
	GetCharacterSet		= (pGetCharacterSet)GetProcAddress(m_hDll, TEXT("GetCharacterSet"));	
	GetInterChrSet		= (pGetInterChrSet)GetProcAddress(m_hDll, TEXT("GetInterChrSet"));	

	SetUpsideDown		= (pSetUpsideDown)GetProcAddress(m_hDll, TEXT("SetUpsideDown"));
	SetLeftMargin		= (pSetLeftMargin)GetProcAddress(m_hDll, TEXT("SetLeftMargin"));
	SetPrintWidth		= (pSetPrintWidth)GetProcAddress(m_hDll, TEXT("SetPrintWidth"));

	DirectIO			= (pDirectIO)GetProcAddress(m_hDll, TEXT("DirectIO"));	

    ///////////  MSR
	MsrReadReady		= (pMsrReadReady)GetProcAddress(m_hDll, TEXT("MsrReadReady"));	
	MsrReadCancel		= (pMsrReadCancel)GetProcAddress(m_hDll, TEXT("MsrReadCancel"));	
	MsrReadTrack		= (pMsrReadTrack)GetProcAddress(m_hDll, TEXT("MsrReadTrack"));	
	MsrReadFullTrack    = (pMsrReadFullTrack)GetProcAddress(m_hDll, TEXT("MsrReadFullTrack"));
	MsrRead1Track		= (pMsrRead1Track)GetProcAddress(m_hDll, TEXT("MsrRead1Track"));
	MsrRead2Track		= (pMsrRead2Track)GetProcAddress(m_hDll, TEXT("MsrRead2Track"));
	MsrRead3Track		= (pMsrRead3Track)GetProcAddress(m_hDll, TEXT("MsrRead3Track"));
	GetTrack1			= (pGetTrack1)GetProcAddress(m_hDll, TEXT("GetTrack1"));	
	GetTrack2			= (pGetTrack2)GetProcAddress(m_hDll, TEXT("GetTrack2"));	
	GetTrack3			= (pGetTrack3)GetProcAddress(m_hDll, TEXT("GetTrack3"));	

	SetMsrMsgMode		= (pSetMsrMsgMode)GetProcAddress(m_hDll, TEXT("SetMsrMsgMode"));
  
    //////////  SCR
    ScrPowerDown		= (pScrPowerDown)GetProcAddress(m_hDll, TEXT("ScrPowerDown"));
    ScrPowerUp			= (pScrPowerUp)GetProcAddress(m_hDll, TEXT("ScrPowerUp"));
    ScrExchangeAPDU		= (pScrExchangeAPDU)GetProcAddress(m_hDll, TEXT("ScrExchangeAPDU"));
    ScrOperationMode	= (pScrOperationMode)GetProcAddress(m_hDll, TEXT("ScrOperationMode"));
    ScrChkCardStatus	= (pScrChkCardStatus)GetProcAddress(m_hDll, TEXT("ScrChkCardStatus"));

	CheckPrinter		= (pCheckPrinter)GetProcAddress(m_hDll, TEXT("CheckPrinter"));	
	GetPowerValue		= (pGetPowerValue)GetProcAddress(m_hDll, TEXT("GetPowerValue"));	
	GetStat				= (pGetStat)GetProcAddress(m_hDll, TEXT("GetStat"));	
	GetResultCode		= (pGetResultCode)GetProcAddress(m_hDll, TEXT("GetResultCode"));	


	FormFeed			= (pFormFeed) GetProcAddress(m_hDll, TEXT("FormFeed"));
	NextPrintPos		= (pNextPrintPos)GetProcAddress(m_hDll, TEXT("NextPrintPos"));	
	InitializePrinter	= (pInitializePrinter) GetProcAddress(m_hDll, TEXT("InitializePrinter"));
	SelectMode			= (pSelectMode) GetProcAddress(m_hDll, TEXT("SelectMode"));
	AutoCalibration		= (pAutoCalibration) GetProcAddress(m_hDll, TEXT("AutoCalibration"));
	

	SelectPageMode					= (pSelectPageMode) GetProcAddress(m_hDll, TEXT("SelectPageMode"));
	SetPrintAreaInPageMode			= (pSetPrintAreaInPageMode) GetProcAddress(m_hDll, TEXT("SetPrintAreaInPageMode"));
	SelectPrintDirectionInPageMode	= (pSelectPrintDirectionInPageMode) GetProcAddress(m_hDll, TEXT("SelectPrintDirectionInPageMode"));
	SetAbsolutePrintPosition		= (pSetAbsolutePrintPosition) GetProcAddress(m_hDll, TEXT("SetAbsolutePrintPosition"));
	SetAbsoluteVerticalPrintPositionInPageMode = (pSetAbsoluteVerticalPrintPositionInPageMode) GetProcAddress(m_hDll, TEXT("SetAbsoluteVerticalPrintPositionInPageMode"));
	PrintDataInPageMode				= (pPrintDataInPageMode) GetProcAddress(m_hDll, TEXT("PrintDataInPageMode"));

	SetPrintAreaInPM			= (pSetPrintAreaInPM) GetProcAddress(m_hDll, TEXT("SetPrintAreaInPM"));
	SetPrintDirectionInPM		= (pSetPrintDirectionInPM) GetProcAddress(m_hDll, TEXT("SetPrintDirectionInPM"));
	SetVerticalPositionInPM		= (pSetVerticalPositionInPM) GetProcAddress(m_hDll, TEXT("SetVerticalPositionInPM"));
	SetHorizontalPositionInPM	= (pSetHorizontalPositionInPM) GetProcAddress(m_hDll, TEXT("SetHorizontalPositionInPM"));
  
	DrawLineInPM	= (pDrawLineInPM) GetProcAddress(m_hDll, TEXT("DrawLineInPM"));
    DrawBoxInPM	= (pDrawBoxInPM) GetProcAddress(m_hDll, TEXT("DrawBoxInPM"));
  
	
	return TRUE;
}