It is installed by the setup application and prints a Repository-based FormLayout onto your Windows Default printer.
/*===========================================================================*/ /* Copyright (C) 2006-2009 by */ /* */ /* -- TEC-IT Datenverarbeitung GmbH -- */ /* -- team for engineering and consulting in information technologies -- */ /* */ /* All rights reserved. */ /* */ /* This is a part of the TEC-IT Standard Software. */ /* */ /* This source code is only intended as a supplement to the References */ /* and related electronic documentation provided with the product. */ /* */ /* See these sources for detailed information regarding this product */ /*===========================================================================*/ /*============================================================================= This sample application shows how to use the TFORMer Runtime DLL ---------------------------------------------------------------------------- History: (2006-05-01) : rebuilt and tested =============================================================================*/ /* define TECIT_DLLIMPORT before including TFormer6.h */ #define TECIT_DLLIMPORT #include "../TFORMer Runtime DLL/TFormer6.h" #undef TECIT_DLLIMPORT /* standard includes */ #include <stdio.h> #include <conio.h> /* need by _getch */ #include <ctype.h> /*============================================================================= forward declarations =============================================================================*/ void PrintErrorInfo (ERRCODE eCode, HTFORM hTForm); /*============================================================================= defines =============================================================================*/ #define TFORMER_REPOSITORY_PATH "..\\..\\Demo Repository\\" #define TFORMER_REPOSITORY_FILE "Demos.tfr" #define TFORMER_PROJECT "TFORMer_Runtime_Examples" #define TFORMER_FORM "BarcodeLabels" #define SAMPLE_DATAFILE "importdata.txt" #define SAFE_OP(function) if ((eCode = function) != ErrOk) \ { \ printf(#function " caused Error!\n"); \ PrintErrorInfo (eCode, hTForm); \ if (hTForm) \ TFormer_Exit (hTForm); \ printf ("\nPress any key!"); \ nKey = _getch(); \ return eCode; \ } /*============================================================================= MAIN =============================================================================*/ int main(int argc, char* argv[]) { ERRCODE eCode; HTFORM hTForm = NULL; CHAR szPath[] = TFORMER_REPOSITORY_PATH TFORMER_REPOSITORY_FILE; int nKey; printf ("\n**************************************************************************"); printf ("\nSample Application: Printing Form : " TFORMER_FORM ); printf ("\n located in Project : " TFORMER_PROJECT ); printf ("\n of Repository : " TFORMER_REPOSITORY_FILE ); printf ("\n Programming Language : ANSI C"); printf ("\n"); printf ("\n (c) 2006-2007 TEC-IT Datenverarbeitung GmbH"); printf ("\n www.tec-it.com"); printf ("\n office@tec-it.com"); printf ("\n**************************************************************************"); printf ("\n"); hTForm = TFormer_Init (NULL); if ( hTForm ) { /* ------------------- Repository Settings ------------------------ */ SAFE_OP (TFormer_SetRepositoryName (hTForm, szPath)); /* set the repository */ SAFE_OP (TFormer_SetProjectName (hTForm, TFORMER_PROJECT)); /* and the project */ SAFE_OP (TFormer_SetFormName (hTForm, TFORMER_FORM)); /* and the name of the form */ /* ------------------- Printer Settings --------------------------- */ SAFE_OP (TFormer_SetPrinterName (hTForm, NULL, NULL)); /* use the default printer of the system */ SAFE_OP (TFormer_SetNumberOfCopies (hTForm, 1)); /* set number of copies to be printed */ /* ------------------- Adding New Data Records -------------------- */ SAFE_OP (TFormer_NewRecord (hTForm)); /* add first data record */ SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleNo", "20021001")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleName", "Sound Blaster Audigy 2")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticlePrice", "175")); SAFE_OP (TFormer_NewRecord (hTForm)); /* add second data record */ SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleNo", "20021002")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleName", "Creative Labs X-Fi ")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticlePrice", "130")); SAFE_OP (TFormer_NewRecord (hTForm)); /* add third data record */ SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleNo", "20021003")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleName", "Creative Labs Live!")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticlePrice", "29")); SAFE_OP (TFormer_NewRecord (hTForm)); /* add fourth data record */ SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleNo", "20021004")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleName", "Griffin Technology iMic ")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticlePrice", "30")); SAFE_OP (TFormer_NewRecord (hTForm)); /* add fifth data record */ SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleNo", "20021005")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleName", "MadDog MultiMedia Predator")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticlePrice", "30")); SAFE_OP (TFormer_NewRecord (hTForm)); /* add sixth data record */ SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleNo", "20021006")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleName", "Creative Labs PCMCIA ")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticlePrice", "90")); /* or import the data from a text file (CSV format). SAFE_OP (TFormer_ResetData (hTForm)); SAFE_OP (TFormer_SetTxtDataFile (hTForm, SAMPLE_DATAFILE, ',', '\"')); */ /* ------------------ Start printing ------------------------- */ SAFE_OP (TFormer_Print (hTForm)); /* ------------------- Exit TFORMer -------------------------- */ /* we do not use SAFE_OP here cause we cannot read any Error Information from TFORMer after a call to TFormer_Exit since the hTForm is invalid afterwards */ eCode = TFormer_Exit (hTForm); /* hTForm is not valid anymore after a call to TFORMer_Exit */ hTForm = NULL; /* has Exit caused any error? */ if (eCode != ErrOk) { PrintErrorInfo (eCode, NULL); } else printf ("\nPrint job finished successfully.\n"); } else { printf ("Error: Could not create dll instance.\n"); return ERROR_DLL_INIT_FAILED; } return 0; } /*============================================================================= Prints error information provided by TFORMer dll =============================================================================*/ void PrintErrorInfo (ERRCODE eCode, HTFORM hTForm) { LPCSTR pszErrDesc = NULL; LPCSTR pszErrInfo = NULL; LPCSTR pszErrSource = NULL; if (hTForm) { pszErrDesc = TFormer_GetLastErrorDescription (hTForm); pszErrInfo = TFormer_GetLastErrorInformation (hTForm); pszErrSource = TFormer_GetLastErrorSource (hTForm); if (pszErrDesc && pszErrDesc[0]) printf("TFError : %s\n", pszErrDesc); if (pszErrInfo && pszErrInfo[0]) printf("TFInformation : %s\n", pszErrInfo); if (pszErrSource && pszErrSource[0]) printf("TFSource : %s\n", pszErrSource); } if (!pszErrDesc || !pszErrDesc[0]) { /* try to fetch Error Information from system */ FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, eCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */ (LPSTR)&pszErrDesc, 0, NULL ); if (pszErrDesc) { printf("Error: %s \n", pszErrDesc); LocalFree ((LPVOID)pszErrDesc); } } }
© 2006-2009 - all rights reserved by TEC-IT Datenverarbeitung GmbH |
![]() |
Generated on Wed Sep 2 16:01:09 2009 for TFORMer Runtime DLL/Shared Library with doxygen 1.5.8 |