// ZTestView.cpp : implementation of the CZTestView class // #include "stdafx.h" #include "ZTest.h" #include "ZTestDoc.h" #include "ZTestView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif HINSTANCE hPPLZ; typedef int (_stdcall *pfnZ_Bar2d_Maxi)(int x,int y,int nMode,int nSymbol,int nTotal, int nClass,int nCountry,char cZipCode1[6],char cZipCode2[4], LPCTSTR data, int increase); typedef int (_stdcall *pfnZ_Bar2d_PDF417)(int x,int y,int o,int h,int s,int c,int r, int t,int narrow,LPCTSTR data,int increase); typedef int (_stdcall *pfnZ_Bar2d_QRCode)(int x,int y,int nModel,int nMagni,int nErr_Cor, int nInput, LPCTSTR data,int increase); typedef void (_stdcall *pfnZ_Clear_Memory)(void); typedef void (_stdcall *pfnZ_ClosePrn)(void); typedef int (_stdcall *pfnZ_CreatePrn)(int selection,LPCTSTR filename); typedef int (_stdcall *pfnZ_Del_Format)(int memory, char formatname[11]); typedef int (_stdcall *pfnZ_Del_Graphic)(int memory,char graphicname[11]); typedef int (_stdcall *pfnZ_Draw_Box)(int x,int y,int width,int height,int thickness); typedef int (_stdcall *pfnZ_Draw_Line)(int x,int y,int width,int height); typedef char* (_stdcall *pfnZ_Get_DLL_Version)(int nShowMessage); typedef int (_stdcall *pfnZ_Get_DLL_VersionA)(int nShowMessage); typedef int (_stdcall *pfnZ_Get_Graphic_ColorBMP)(int x,int y,int mem_mode,LPCTSTR filename); typedef int (_stdcall *pfnZ_Initial_Setting)(int Type,LPCTSTR Source); typedef int (_stdcall *pfnZ_Load_Graphic)(int x,int y,int memory,char graphic_name[10], int horizontal, int vertical); typedef int (_stdcall *pfnZ_Open_ChineseFont)(char* path); typedef int (_stdcall *pfnZ_Print_Form)(int labset,int copies,int mem_mode,char form_out[11]); typedef int (_stdcall *pfnZ_Print_Out)(int copies,int sets); typedef int (_stdcall *pfnZ_Prn_Barcode)(int x,int y,int ori,int narrow, int width, int height,char type,int increase,LPCTSTR data,char human1, char human2,char human3,char human4,char human5); typedef int (_stdcall *pfnZ_Prn_Text)(int x,int y,int ori,char font,int height,int width, int numeric,LPCTSTR data); typedef int (_stdcall *pfnZ_Prn_Text_Chinese)(int x,int y,int fonttype,LPCTSTR id_name,LPCTSTR data,int mem_mode); typedef int (_stdcall *pfnZ_Prn_Text_TrueType)(int x,int y,int FSize,LPCTSTR FType,int Fspin, int FWeight,int FItalic,int FUnline,int FStrikeOut, LPCTSTR id_name,LPCTSTR data,int mem_mode); typedef int (_stdcall *pfnZ_Prn_Text_TrueType_W)(int x, int y, int FHeight, int FWidth, LPCTSTR FType, int Fspin, int FWeight,int FItalic, int FUnline, int FStrikeOut,LPCTSTR id_name, LPCTSTR data,int mem_mode); typedef int (_stdcall *pfnZ_Set_Backfeed)(int nDistance); typedef int (_stdcall *pfnZ_Set_Darkness)(int darkness); typedef int (_stdcall *pfnZ_Set_DebugDialog)(int nEnable); typedef int (_stdcall *pfnZ_Set_FlashMemory)(int Status); typedef void (_stdcall *pfnZ_Set_Format_New)(LPCTSTR FormatName); typedef int (_stdcall *pfnZ_Set_Label)(int Length); typedef int (_stdcall *pfnZ_Set_Mode)(char mode); typedef int (_stdcall *pfnZ_Set_Origin)(int y); typedef int (_stdcall *pfnZ_Set_Paper)(char mode); typedef int (_stdcall *pfnZ_Set_Prncomport)(int baud, int parity, int data, int stop); typedef int (_stdcall *pfnZ_Set_Prncomport_PC)(int nBaudRate, int nByteSize, int nParity, int nStopBits, int nDsr, int nCts, int nXonXoff); typedef void (_stdcall *pfnZ_Set_Reset)(); typedef int (_stdcall *pfnZ_Set_Speed)(int print); typedef int (_stdcall *pfnZ_Set_TPH)(char mode); typedef int (_stdcall *pfnZ_Set_Unit)(char Unit); typedef int (_stdcall *pfnZ_Set_Gap)(int nPatern,int nGap); typedef int (_stdcall *pfnZ_Set_ProcessDlg)(int nShow); typedef int (_stdcall *pfnZ_Set_PrintWidth)(int nDotwidth); typedef int (_stdcall *pfnZ_Print_OutQuality)(int nTotal, int copies, int sets, int nPause); typedef int (_stdcall *pfnZ_GetUSBBufferLen)(void); typedef int (_stdcall *pfnZ_EnumUSB)(char *buf); typedef int (_stdcall *pfnZ_CreateUSBPort)(int nPort); pfnZ_Bar2d_Maxi Z_Bar2d_Maxi = NULL; pfnZ_Bar2d_PDF417 Z_Bar2d_PDF417 = NULL; pfnZ_Bar2d_QRCode Z_Bar2d_QRCode = NULL; pfnZ_Clear_Memory Z_Clear_Memory = NULL; pfnZ_ClosePrn Z_ClosePrn = NULL; pfnZ_CreatePrn Z_CreatePrn = NULL; pfnZ_Del_Format Z_Del_Format = NULL; pfnZ_Del_Graphic Z_Del_Graphic = NULL; pfnZ_Draw_Box Z_Draw_Box = NULL; pfnZ_Draw_Line Z_Draw_Line = NULL; pfnZ_Get_DLL_Version Z_Get_DLL_Version = NULL; pfnZ_Get_DLL_VersionA Z_Get_DLL_VersionA = NULL; pfnZ_Get_Graphic_ColorBMP Z_Get_Graphic_ColorBMP = NULL; pfnZ_Initial_Setting Z_Initial_Setting = NULL; pfnZ_Load_Graphic Z_Load_Graphic = NULL; pfnZ_Open_ChineseFont Z_Open_ChineseFont = NULL; pfnZ_Print_Form Z_Print_Form = NULL; pfnZ_Print_Out Z_Print_Out = NULL; pfnZ_Prn_Barcode Z_Prn_Barcode = NULL; pfnZ_Prn_Text Z_Prn_Text = NULL; pfnZ_Prn_Text_Chinese Z_Prn_Text_Chinese = NULL; pfnZ_Prn_Text_TrueType Z_Prn_Text_TrueType = NULL; pfnZ_Prn_Text_TrueType_W Z_Prn_Text_TrueType_W = NULL; pfnZ_Set_Backfeed Z_Set_Backfeed = NULL; pfnZ_Set_Darkness Z_Set_Darkness = NULL; pfnZ_Set_DebugDialog Z_Set_DebugDialog = NULL; pfnZ_Set_FlashMemory Z_Set_FlashMemory = NULL; pfnZ_Set_Format_New Z_Set_Format_New = NULL; pfnZ_Set_Label Z_Set_Label = NULL; pfnZ_Set_Mode Z_Set_Mode = NULL; pfnZ_Set_Origin Z_Set_Origin = NULL; pfnZ_Set_Paper Z_Set_Paper = NULL; pfnZ_Set_Prncomport Z_Set_Prncomport = NULL; pfnZ_Set_Prncomport_PC Z_Set_Prncomport_PC = NULL; pfnZ_Set_Reset Z_Set_Reset = NULL; pfnZ_Set_Speed Z_Set_Speed = NULL; pfnZ_Set_TPH Z_Set_TPH = NULL; pfnZ_Set_Unit Z_Set_Unit = NULL; pfnZ_Set_Gap Z_Set_Gap = NULL; pfnZ_Set_ProcessDlg Z_Set_ProcessDlg = NULL; pfnZ_Set_PrintWidth Z_Set_PrintWidth = NULL; pfnZ_Print_OutQuality Z_Print_OutQuality = NULL; pfnZ_GetUSBBufferLen Z_GetUSBBufferLen = NULL; pfnZ_EnumUSB Z_EnumUSB = NULL; pfnZ_CreateUSBPort Z_CreateUSBPort = NULL; ///////////////////////////////////////////////////////////////////////////// // CZTestView IMPLEMENT_DYNCREATE(CZTestView, CView) BEGIN_MESSAGE_MAP(CZTestView, CView) //{{AFX_MSG_MAP(CZTestView) ON_WM_LBUTTONDOWN() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CZTestView construction/destruction CZTestView::CZTestView() { VERIFY(hPPLZ = ::LoadLibrary("WINPPLZ.DLL")); VERIFY(Z_Bar2d_Maxi = (pfnZ_Bar2d_Maxi) ::GetProcAddress(hPPLZ,"Z_Bar2d_Maxi")); VERIFY(Z_Bar2d_PDF417 = (pfnZ_Bar2d_PDF417) ::GetProcAddress(hPPLZ,"Z_Bar2d_PDF417")); VERIFY(Z_Bar2d_QRCode = (pfnZ_Bar2d_QRCode) ::GetProcAddress(hPPLZ,"Z_Bar2d_QRCode")); VERIFY(Z_Clear_Memory = (pfnZ_Clear_Memory) ::GetProcAddress(hPPLZ,"Z_Clear_Memory")); VERIFY(Z_ClosePrn = (pfnZ_ClosePrn) ::GetProcAddress(hPPLZ,"Z_ClosePrn")); VERIFY(Z_CreatePrn = (pfnZ_CreatePrn) ::GetProcAddress(hPPLZ,"Z_CreatePrn")); VERIFY(Z_Del_Format = (pfnZ_Del_Format) ::GetProcAddress(hPPLZ,"Z_Del_Format")); VERIFY(Z_Del_Graphic = (pfnZ_Del_Graphic) ::GetProcAddress(hPPLZ,"Z_Del_Graphic")); VERIFY(Z_Draw_Box = (pfnZ_Draw_Box) ::GetProcAddress(hPPLZ,"Z_Draw_Box")); VERIFY(Z_Draw_Line = (pfnZ_Draw_Line) ::GetProcAddress(hPPLZ,"Z_Draw_Line")); VERIFY(Z_Get_DLL_Version = (pfnZ_Get_DLL_Version) ::GetProcAddress(hPPLZ,"Z_Get_DLL_Version")); VERIFY(Z_Get_DLL_VersionA = (pfnZ_Get_DLL_VersionA) ::GetProcAddress(hPPLZ,"Z_Get_DLL_VersionA")); VERIFY(Z_Get_Graphic_ColorBMP = (pfnZ_Get_Graphic_ColorBMP) ::GetProcAddress(hPPLZ,"Z_Get_Graphic_ColorBMP")); VERIFY(Z_Initial_Setting = (pfnZ_Initial_Setting) ::GetProcAddress(hPPLZ,"Z_Initial_Setting")); VERIFY(Z_Load_Graphic = (pfnZ_Load_Graphic) ::GetProcAddress(hPPLZ,"Z_Load_Graphic")); VERIFY(Z_Open_ChineseFont = (pfnZ_Open_ChineseFont) ::GetProcAddress(hPPLZ,"Z_Open_ChineseFont")); VERIFY(Z_Print_Form = (pfnZ_Print_Form) ::GetProcAddress(hPPLZ,"Z_Print_Form")); VERIFY(Z_Print_Out = (pfnZ_Print_Out) ::GetProcAddress(hPPLZ,"Z_Print_Out")); VERIFY(Z_Prn_Barcode = (pfnZ_Prn_Barcode) ::GetProcAddress(hPPLZ,"Z_Prn_Barcode")); VERIFY(Z_Prn_Text = (pfnZ_Prn_Text) ::GetProcAddress(hPPLZ,"Z_Prn_Text")); VERIFY(Z_Prn_Text_Chinese = (pfnZ_Prn_Text_Chinese) ::GetProcAddress(hPPLZ,"Z_Prn_Text_Chinese")); VERIFY(Z_Prn_Text_TrueType = (pfnZ_Prn_Text_TrueType) ::GetProcAddress(hPPLZ,"Z_Prn_Text_TrueType")); VERIFY(Z_Prn_Text_TrueType_W = (pfnZ_Prn_Text_TrueType_W) ::GetProcAddress(hPPLZ,"Z_Prn_Text_TrueType_W")); VERIFY(Z_Set_Backfeed = (pfnZ_Set_Backfeed) ::GetProcAddress(hPPLZ,"Z_Set_Backfeed")); VERIFY(Z_Set_Darkness = (pfnZ_Set_Darkness) ::GetProcAddress(hPPLZ,"Z_Set_Darkness")); VERIFY(Z_Set_DebugDialog = (pfnZ_Set_DebugDialog) ::GetProcAddress(hPPLZ,"Z_Set_DebugDialog")); VERIFY(Z_Set_FlashMemory = (pfnZ_Set_FlashMemory) ::GetProcAddress(hPPLZ,"Z_Set_FlashMemory")); VERIFY(Z_Set_Format_New = (pfnZ_Set_Format_New) ::GetProcAddress(hPPLZ,"Z_Set_Format_New")); VERIFY(Z_Set_Label = (pfnZ_Set_Label) ::GetProcAddress(hPPLZ,"Z_Set_Label")); VERIFY(Z_Set_Mode = (pfnZ_Set_Mode) ::GetProcAddress(hPPLZ,"Z_Set_Mode")); VERIFY(Z_Set_Origin = (pfnZ_Set_Origin) ::GetProcAddress(hPPLZ,"Z_Set_Origin")); VERIFY(Z_Set_Paper = (pfnZ_Set_Paper) ::GetProcAddress(hPPLZ,"Z_Set_Paper")); VERIFY(Z_Set_Prncomport = (pfnZ_Set_Prncomport) ::GetProcAddress(hPPLZ,"Z_Set_Prncomport")); VERIFY(Z_Set_Prncomport_PC = (pfnZ_Set_Prncomport_PC) ::GetProcAddress(hPPLZ,"Z_Set_Prncomport_PC")); VERIFY(Z_Set_Reset = (pfnZ_Set_Reset) ::GetProcAddress(hPPLZ,"Z_Set_Reset")); VERIFY(Z_Set_Speed = (pfnZ_Set_Speed) ::GetProcAddress(hPPLZ,"Z_Set_Speed")); VERIFY(Z_Set_TPH = (pfnZ_Set_TPH) ::GetProcAddress(hPPLZ,"Z_Set_TPH")); VERIFY(Z_Set_Unit = (pfnZ_Set_Unit) ::GetProcAddress(hPPLZ,"Z_Set_Unit")); VERIFY(Z_Set_Gap = (pfnZ_Set_Gap) ::GetProcAddress(hPPLZ,"Z_Set_Gap")); VERIFY(Z_Set_ProcessDlg = (pfnZ_Set_ProcessDlg) ::GetProcAddress(hPPLZ,"Z_Set_ProcessDlg")); VERIFY(Z_Set_PrintWidth = (pfnZ_Set_PrintWidth) ::GetProcAddress(hPPLZ,"Z_Set_PrintWidth")); VERIFY(Z_Print_OutQuality = (pfnZ_Print_OutQuality) ::GetProcAddress(hPPLZ,"Z_Print_OutQuality")); VERIFY(Z_GetUSBBufferLen = (pfnZ_GetUSBBufferLen) ::GetProcAddress(hPPLZ,"Z_GetUSBBufferLen")); VERIFY(Z_EnumUSB = (pfnZ_EnumUSB) ::GetProcAddress(hPPLZ,"Z_EnumUSB")); VERIFY(Z_CreateUSBPort = (pfnZ_CreateUSBPort) ::GetProcAddress(hPPLZ,"Z_CreateUSBPort")); } CZTestView::~CZTestView() { FreeLibrary(hPPLZ); hPPLZ = NULL; Z_Bar2d_Maxi = NULL; Z_Bar2d_PDF417 = NULL; Z_Bar2d_QRCode = NULL; Z_Clear_Memory = NULL; Z_ClosePrn = NULL; Z_CreatePrn = NULL; Z_Del_Format = NULL; Z_Del_Graphic = NULL; Z_Draw_Box = NULL; Z_Draw_Line = NULL; Z_Get_DLL_Version = NULL; Z_Get_DLL_VersionA = NULL; Z_Get_Graphic_ColorBMP = NULL; Z_Initial_Setting = NULL; Z_Load_Graphic = NULL; Z_Open_ChineseFont = NULL; Z_Print_Form = NULL; Z_Print_Out = NULL; Z_Prn_Barcode = NULL; Z_Prn_Text = NULL; Z_Prn_Text_Chinese = NULL; Z_Prn_Text_TrueType = NULL; Z_Prn_Text_TrueType_W = NULL; Z_Set_Backfeed = NULL; Z_Set_Darkness = NULL; Z_Set_DebugDialog = NULL; Z_Set_FlashMemory = NULL; Z_Set_Format_New = NULL; Z_Set_Label = NULL; Z_Set_Mode = NULL; Z_Set_Origin = NULL; Z_Set_Paper = NULL; Z_Set_Prncomport = NULL; Z_Set_Prncomport_PC = NULL; Z_Set_Reset = NULL; Z_Set_Speed = NULL; Z_Set_TPH = NULL; Z_Set_Unit = NULL; Z_Set_Gap = NULL; Z_Set_ProcessDlg = NULL; Z_Set_PrintWidth = NULL; Z_Print_OutQuality = NULL; Z_GetUSBBufferLen = NULL; Z_EnumUSB = NULL; Z_CreateUSBPort = NULL; } BOOL CZTestView::PreCreateWindow(CREATESTRUCT& cs) { return CView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CZTestView drawing void CZTestView::OnDraw(CDC* pDC) { CZTestDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); } ///////////////////////////////////////////////////////////////////////////// // CZTestView diagnostics #ifdef _DEBUG void CZTestView::AssertValid() const { CView::AssertValid(); } void CZTestView::Dump(CDumpContext& dc) const { CView::Dump(dc); } CZTestDoc* CZTestView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CZTestDoc))); return (CZTestDoc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CZTestView message handlers void CZTestView::OnLButtonDown(UINT nFlags, CPoint point) { CClientDC dc(this); dc.TextOut(point.x,point.y,"You press!"); int nUSBDataLen; char *pbuf; //PPLZDLL Test code start Z_CreatePrn(1,NULL); // USB Port Open //nUSBDataLen = Z_GetUSBBufferLen()+1; //pbuf = (char *)new char[nUSBDataLen]; //memset(pbuf, 0, nUSBDataLen); //Z_EnumUSB(pbuf); //Z_CreateUSBPort(1); Z_Set_ProcessDlg(1); //Z_Get_DLL_Version(1); //Z_Get_DLL_VersionA(1); //Z_Set_DebugDialog(1); //Z_Clear_Memory(); //Z_Set_Backfeed(0); //Z_Set_Darkness(20); //Z_Set_Origin(100); //Z_Set_Paper('Y'); Z_Set_Speed(1); //Z_Set_Unit('M'); //Z_Set_TPH('D'); Z_Prn_Text(10,10,1,'A',20,18,1,"A123456"); Z_Prn_Text_TrueType(30,50,20,"Times New Roman",1,400,0,0,0,"AB","TrueType Font",0); //Z_Prn_Text_TrueType_W(100,50,20,16,"Arial",4,400,0,0,0,"CD","Library Function Test",0); Z_Draw_Box(10,10,150,50,5); Z_Draw_Line(10,100,100,15); Z_Prn_Barcode(100,150,1,2,3,20,'3',0,"12345",'y','y','y','y','y'); Z_Bar2d_QRCode(50, 200, 1, 5, 3, 1, "QRCode", 0); Z_Print_Out(1,1); Z_ClosePrn(); CView::OnLButtonDown(nFlags, point); }