home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 October / PCWorld_2002-10_cd.bin / Software / Topware / fprint / fpdk400.exe / samples / msvc / callback.mfc / FPCALLM.CPP < prev    next >
C/C++ Source or Header  |  1999-10-15  |  4KB  |  135 lines

  1. // fpcallm.cpp : Defines the initialization routines for the DLL.
  2. //
  3. #include "stdafx.h"
  4. #include "fpcallm.h"
  5. #include "calldlg.h"
  6. #include "fpapi.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. //
  15. //    Note!
  16. //
  17. //        If this DLL is dynamically linked against the MFC
  18. //        DLLs, any functions exported from this DLL which
  19. //        call into MFC must have the AFX_MANAGE_STATE macro
  20. //        added at the very beginning of the function.
  21. //
  22. //        For example:
  23. //
  24. //        extern "C" BOOL PASCAL EXPORT ExportedFunction()
  25. //        {
  26. //            AFX_MANAGE_STATE(AfxGetStaticModuleState());
  27. //            // normal function body here
  28. //        }
  29. //
  30. //        It is very important that this macro appear in each
  31. //        function, prior to any calls into MFC.  This means that
  32. //        it must appear as the first statement within the 
  33. //        function, even before any object variable declarations
  34. //        as their constructors may generate calls into the MFC
  35. //        DLL.
  36. //
  37. //        Please see MFC Technical Notes 33 and 58 for additional
  38. //        details.
  39. //
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. // CMFCcallbackApp
  43.  
  44. BEGIN_MESSAGE_MAP(CMFCcallbackApp, CWinApp)
  45.     //{{AFX_MSG_MAP(CMFCcallbackApp)
  46.         // NOTE - the ClassWizard will add and remove mapping macros here.
  47.         //    DO NOT EDIT what you see in these blocks of generated code!
  48.     //}}AFX_MSG_MAP
  49. END_MESSAGE_MAP()
  50.  
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CMFCcallbackApp construction
  53.  
  54. CMFCcallbackApp::CMFCcallbackApp()
  55. {
  56. }
  57.  
  58. /////////////////////////////////////////////////////////////////////////////
  59. // The one and only CMFCcallbackApp object
  60.  
  61. CMFCcallbackApp theApp;
  62.  
  63. /*--------------------------------------------------------------------------
  64. |    fpOnStartDocA
  65. |
  66. |        FinePrint job callback function.
  67. --------------------------------------------------------------------------*/
  68. extern "C" DWORD WINAPI fpOnStartDocA (FpDocCallbackA *pDoc)
  69. {
  70.     CCallbackDialog    dlg;
  71.     HFinePrint    hfp = 0;
  72.     TCHAR        szPrinter[256] = {0};
  73.     LPTSTR        pszMsg = new TCHAR [1024];
  74.  
  75.     if (fpOpen (pDoc->szFinePrinter, &hfp) == 0) {
  76.         fpGetLayoutAttr (hfp, eliDestPrinter, szPrinter, sizeof (szPrinter));
  77.         fpSetLayoutAttr (hfp, eliLayout, (void *) eLayout8);
  78.         fpClose (hfp, FALSE);
  79.     }
  80.  
  81.     // bring up a dialog box
  82.     MessageBeep (0);
  83.     switch (dlg.DoModal ()) {
  84.     case PB_Early:
  85.         // show the FinePrint dialog now
  86.         pDoc->dwShowDlg = ShowDlg_Early;
  87.         return (TRUE);
  88.     case PB_Late:
  89.         // show the FinePrint dialog later
  90.         pDoc->dwShowDlg = ShowDlg_Late;
  91.         return (TRUE);
  92.     }
  93.     // abort the print job
  94.     return (FALSE);
  95.  
  96. #if 0
  97.     TCHAR    sz[256];
  98.  
  99.     // bring up a message box
  100.     _stprintf (
  101.         sz,
  102.         TEXT ("Print job \"%s\" on printer \"%s\".\n\n\
  103. \tYES = show FP dialog now\n\
  104. \tNO = show FP dialog later\n\
  105. \tCANCEL = abort job"),
  106.         pDoc->szJobName,
  107.         pDoc->szFinePrinter);
  108.     switch (MessageBox (NULL, sz, TEXT ("FinePrint callback DLL"), MB_SETFOREGROUND | MB_YESNOCANCEL)) {
  109.     case IDYES:
  110.         // show the FinePrint dialog now
  111.         pDoc->dwShowDlg = ShowDlg_Early;
  112.         return (TRUE);
  113.     case IDNO:
  114.         // show the FinePrint dialog later
  115.         pDoc->dwShowDlg = ShowDlg_Late;
  116.         return (TRUE);
  117.     default:
  118.         // abort the print job
  119.         return (FALSE);
  120.     }
  121. #endif
  122. }
  123.  
  124. /*--------------------------------------------------------------------------
  125. |    fpOnEndDocA
  126. |
  127. |        FinePrint job callback function.
  128. --------------------------------------------------------------------------*/
  129. extern "C" DWORD WINAPI fpOnEndDocA (FpDocCallbackA *pDoc)
  130. {
  131.     MessageBeep (0);
  132.     MessageBox (NULL, TEXT ("In fpOnEndDoc callback."), TEXT ("FinePrint callback DLL"), MB_SETFOREGROUND | MB_ICONINFORMATION | MB_OK);
  133.     return (TRUE);
  134. }
  135.