home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / prtgrafc.zip / PRTDEMO.C < prev    next >
C/C++ Source or Header  |  1996-01-01  |  50KB  |  1,293 lines

  1. /* Version of 95/06/26 by Peter Kanis */
  2. /************************************************************************
  3. *  Project     : PRTGRAPH                 Date    : 95/05/11            *
  4. *  Module      : C Library Demo                                         *
  5. *  Filename    : prtdemo.c                Author  : Peter Kanis         *
  6. *************************************************************************
  7. *                                                                       *
  8. *  Description:                                                         *
  9. *                                                                       *
  10. *  Export:                                                              *
  11. *                                                                       *
  12. *  Intenal:                                                             *
  13. *                                                                       *
  14. *  Locals:      none                                                    *
  15. *                                                                       *
  16. *  Revisions:   none                                                    *
  17. *                                                                       *
  18. *************************************************************************
  19. *                                                                       *
  20. *  (c) ADD Consulting  All Rights Reserved                              *
  21. *                                                                       *
  22. *************************************************************************/
  23.  
  24. #define INCL_WIN
  25. #define INCL_SPL
  26. #define INCL_DEV
  27. #define INCL_BASE
  28. #define INCL_DOS
  29. #include <os2.h>
  30. #include "prtdemo.h"
  31.  
  32. /***** Default printing font ********************************************/
  33.  
  34. PSZ         pszDefFont = "10.Helvetica Bold";
  35.  
  36. /***** Available line spacings ******************************************/
  37.  
  38. PSZ         achLineSpc[] = {
  39.                 "10", "20", "30", "40", "50", "60", "70", "80", "90", "100",    
  40.                 "110", "120", "130", "140", "150", "160", "170", "180", "190", "200",   
  41.                 "210", "220", "230", "240", "250", "260", "270", "280", "290", "300",   
  42.                 "310", "320", "330", "340", "350", "360", "370", "380", "390", "400",   
  43.                 "410", "420", "430", "440", "450", "460", "470", "480", "490", "500",   
  44.                 "510", "520", "530", "540", "550", "560", "570", "580", "590", "600" };
  45.  
  46. /***** Buffer for printing font *****************************************/
  47.  
  48. char        achPrtFont[ FACESIZE + 1];
  49.  
  50. HAB         Hab;
  51. HMQ         Hmq;
  52. HWND        hwndTop = NULLHANDLE,
  53.             hwndDlg = NULLHANDLE;
  54. PILIST      pItems = NULL;
  55. PILIST      pCurItem = NULL;
  56.  
  57. HGRPRT      hPrt = NULLHANDLE;
  58.  
  59. /***** Local functions **************************************************/
  60.  
  61. void PrintTable1( HTABLE);
  62. void PrintTable2( HTABLE, USHORT);
  63.  
  64. void main( void)
  65.     {
  66.     CHAR        szClassName[] = "PRINT_DEMO_WIN";
  67.     ULONG       lf = 0L;
  68.     HWND        hwnd;
  69.     QMSG        qmsg;
  70.     
  71.     /***** Initialise the Pm environment ********************************/
  72.         
  73.     Hab = WinInitialize(0);
  74.     Hmq = WinCreateMsgQueue( Hab, 0);
  75.     
  76.     /***** Initialise Printing DLL **************************************/
  77.     
  78.     WinRegisterClass( Hab,
  79.                       szClassName,
  80.                       (PFNWP)DemoWndProc,
  81.                       0L,
  82.                       sizeof(PVOID));
  83.  
  84.      hwndTop = WinCreateStdWindow( HWND_DESKTOP,
  85.                                    0L, &lf, szClassName,
  86.                                    "", 0L, NULLHANDLE, 
  87.                                    ID_WINDOW,
  88.                                    &hwnd);
  89.  
  90.     
  91.     while( WinGetMsg( Hab, &qmsg, NULLHANDLE, 0, 0))
  92.         WinDispatchMsg( Hab, &qmsg);
  93.  
  94.     /***** Destroy the PM environment ***********************************/
  95.     
  96.     WinDestroyWindow( hwndTop);
  97.     WinDestroyMsgQueue( Hmq);
  98.     WinTerminate( Hab);
  99.     DelItemList();
  100.     
  101.     /***** Terminate printing DLL ***************************************/
  102.     
  103.     PrtGTerm( hPrt);
  104.     
  105.     return;
  106.     
  107.     } /* end of main() */
  108.  
  109. /*
  110. *************************************************************************/
  111.  
  112. MRESULT EXPENTRY DemoDlgProc( HWND      hwnd,
  113.                               ULONG     msg,
  114.                               MPARAM    mp1,
  115.                               MPARAM    mp2)
  116.  
  117. /************************************************************************
  118. *                                                                       *
  119. * Description : Dialog procedure for the demo dialog                    *
  120. *                                                                       *
  121. * Function    : 
  122. *                                                                       *
  123. * Return      :                                                         *
  124. *                                                                       *
  125. *************************************************************************/
  126.  
  127.     { 
  128.     BOOL                brc;
  129.     PSZ                 pszFont,
  130.                         pp, pq;
  131.     USHORT              rc;
  132.     PROP_TYPE           prop;
  133.     char                cFamName[ FACESIZE],
  134.                         buffer[ 256];
  135.     HPOINTER            hptr;
  136.     HACCEL              hacl;
  137.     HWND                hwndMenu;
  138.     SWCNTRL             swctl;
  139.     PID                 pid;
  140.  
  141.  
  142.     switch ( msg)
  143.         {
  144.         case WM_INITDLG :
  145.             
  146.             /***** Get the DLL version string & build title *************/
  147.             
  148. //            hPrt = PrtGInit( hwnd, ( PFNNP )NewPageFunc);
  149.             hPrt = PrtGInit( hwnd, NULL);
  150.  
  151.             prop = PrtGGet( hPrt, PRT_VERSION, &rc);
  152.             pp = strdup( prop.string);
  153.             sprintf( buffer, "PrtGraph Demo C/C++ v%s", pp);
  154.             
  155.             /***** Add entry to switch list *****************************/
  156.             
  157.             WinQueryWindowProcess(hwnd, &pid, NULL);/* gets process id */
  158.             
  159.             /***** initialize switch structure **************************/
  160.             
  161.             swctl.hwnd = hwnd;
  162.             swctl.hwndIcon = NULLHANDLE;
  163.             swctl.hprog = NULLHANDLE;
  164.             swctl.idProcess = pid;
  165.             swctl.idSession = 0;
  166.             swctl.uchVisibility = SWL_VISIBLE;
  167.             swctl.fbJump = SWL_JUMPABLE;
  168.             strcpy(swctl.szSwtitle, buffer);
  169.  
  170.             WinCreateSwitchEntry( Hab, &swctl);
  171.  
  172.             /***** Set the title to the dialog **************************/
  173.             
  174.             prop = PrtGGet( hPrt, PRT_CURRENTPRINTER, &rc);
  175.             pq = strdup( prop.string);
  176.             sprintf( buffer, "PrtGraph Demo C/C++ v%s - %s", pp, pq);
  177.             
  178.             free( pp);
  179.             free( pq);
  180.  
  181.             WinSetDlgItemText( hwnd, FID_TITLEBAR, buffer);
  182.             
  183.             /***** Load the menu ****************************************/
  184.             
  185.             hwndMenu = WinLoadMenu( hwnd, 0L, DEMO_DLG);
  186.             WinEnableWindowUpdate( hwndMenu, TRUE);
  187.             
  188.             /***** Load and set the accel. table ************************/
  189.             
  190.             hacl = WinLoadAccelTable( Hab, 0L, DEMO_DLG);
  191.             WinSetAccelTable( Hab, hacl, hwnd);
  192.             
  193.             /***** Load and set the icon ********************************/
  194.             
  195.             hptr = WinLoadPointer( HWND_DESKTOP, 0L, DEMO_DLG);
  196.             WinPostMsg( hwnd, WM_SETICON, (MPARAM) hptr, 0L);
  197.             
  198.             /***** Centre the dialog on the screen **********************/
  199.             
  200.             DemoCentreWin( hwnd);
  201.             
  202.             /***** Initialise the fields ********************************/
  203.             
  204.             DemoDlgInit( hwnd);
  205.             
  206.             /***** Get status texts and positions for the fields ********/
  207.             
  208.             DemoDlgGetItemPositions( hwnd);
  209.             return( 0L);
  210.             
  211.         case WM_HITTEST :
  212.             
  213.             /***** Interactive status line ******************************/
  214.             
  215.             DemoDlgSetStatusText( hwnd, mp1);
  216.             return( WinDefDlgProc( hwnd, msg, mp1,mp2));
  217.  
  218.         case WM_COMMAND :
  219.             switch( SHORT1FROMMP( mp1))
  220.                 {
  221.                 case PB_ABOUT :
  222.                     pp = PrtGVersion();
  223.                     AddProductInfoDlg( Hab, hwnd, "PrtGraph Demo C/C++", pp);
  224.                     free( pp); 
  225.                     return(0L);
  226.                 
  227.                 case PB_PRINTER :
  228.                     pq = PrtGPrinterDlg( hPrt, hwnd, "Choose your printer !!");
  229.                     pp = PrtGVersion();
  230.                     if( pp)
  231.                         sprintf( buffer, "PrtGraph Demo C/C++ v%s - %s", pp, pq);
  232.                     else
  233.                         sprintf( buffer, "PrtGraph Demo C/C++ v%s - (None)", pp);
  234.                     WinSetDlgItemText( hwnd, FID_TITLEBAR, buffer);
  235.                     return(0L);
  236.                         
  237.                 case PB_JOBPROPS :
  238.                     PrtGJobProperties( hPrt, hwnd);
  239.                     return(0L);
  240.                 
  241.                 case PB_PRINT :
  242.                     hptr = WinQuerySysPointer( HWND_DESKTOP, SPTR_WAIT, TRUE);
  243.                     WinSetPointer(HWND_DESKTOP, hptr);
  244.                     brc = DemoPrint( hwnd);
  245.                     hptr = WinQuerySysPointer( HWND_DESKTOP, SPTR_ARROW, TRUE);
  246.                     WinSetPointer(HWND_DESKTOP, hptr);
  247.                     return(0L);
  248.                 
  249.                 case PB_FONT :
  250.                     
  251.                     /***** Get the current Family Name ******************/
  252.                     
  253.                     WinQueryDlgItemText( hwnd, EF_FONT, 256, buffer);
  254.                     pp = strchr( buffer, ( int)'.');
  255.                     if ( pp)
  256.                         {
  257.                         pp++;
  258.                         pq = strchr( pp, ( int)' ');
  259.                         if( pq)
  260.                             *pq = '\0';
  261.                         } /* end of if */
  262.                     else
  263.                         pp = buffer;
  264.  
  265.                     strcpy( cFamName, pp);
  266.                     
  267.                     pszFont = PrtGFontDlg( hPrt, "Choose font for printing", cFamName);
  268.                     if( pszFont)
  269.                         WinSetDlgItemText( hwnd, EF_FONT, pszFont);
  270.                     return(0L);
  271.  
  272.                 case DID_CANCEL :
  273.                     WinDismissDlg( hwnd, 0);
  274.                     WinPostMsg( hwndTop, WM_QUIT, 0L, 0L);
  275.                     return(0L);
  276.                 }
  277.  
  278.             break;
  279.  
  280.         default :
  281.             return( WinDefDlgProc( hwnd, msg, mp1,mp2));
  282.  
  283.         }
  284.  
  285.     return(0L);
  286.  
  287.     } /* end of DemoDlgProc() */
  288.  
  289. /*
  290. *************************************************************************/
  291.  
  292. VOID DemoCentreWin( HWND     hwnd)
  293.  
  294. /************************************************************************
  295. *                                                                       *
  296. * Description : Centre the window in the screen                         *
  297. *                                                                       *
  298. * Function    : 
  299. *                                                                       *
  300. * Return      :                                                         *
  301. *                                                                       *
  302. *************************************************************************/
  303.  
  304.     { 
  305.     SWP         swp;
  306.     LONG        cx, cy;
  307.         
  308.     cy = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN);
  309.     cx = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN);
  310.  
  311.     WinQueryWindowPos( hwnd, &swp);
  312.     swp.x = (cx - swp.cx) / 2;
  313.     swp.y = (cy - swp.cy) / 2;
  314.     swp.cx++;
  315.     swp.fl = SWP_RESTORE | SWP_SIZE | SWP_MOVE | SWP_SHOW;
  316.     WinSetWindowPos( hwnd, HWND_TOP, swp.x, swp.y,
  317.                      swp.cx, swp.cy, swp.fl);
  318.     swp.cx--;
  319.     WinSetWindowPos( hwnd, HWND_TOP, swp.x, swp.y,
  320.                      swp.cx, swp.cy, swp.fl);
  321.     
  322.     } /* end of DemoCentreWin() */
  323.  
  324. /*
  325. *************************************************************************/
  326.  
  327. VOID DemoDlgSetStatusText( HWND       hwnd,
  328.                            MPARAM     mp)
  329.  
  330. /************************************************************************
  331. *                                                                       *
  332. * Description : Set the status text                                     *
  333. *                                                                       *
  334. * Function    : 
  335. *                                                                       *
  336. * Return      :                                                         *
  337. *                                                                       *
  338. *************************************************************************/
  339.  
  340.     { 
  341.     POINTL      ptl;
  342.     PILIST      p;
  343.     
  344.     ptl.x = (LONG)SHORT1FROMMP( mp);
  345.     ptl.y = (LONG)SHORT2FROMMP( mp);
  346.     
  347.     if ( pCurItem)
  348.         if(( ptl.x > pCurItem->lleft) && 
  349.            ( ptl.x < pCurItem->lright) &&
  350.            ( ptl.y > pCurItem->lbottom) && 
  351.            ( ptl.y < pCurItem->ltop))
  352.                 return;
  353.     
  354.     p = pItems;
  355.     while( p)
  356.         {
  357.         if(( ptl.x > p->lleft) && 
  358.            ( ptl.x < p->lright) &&
  359.            ( ptl.y > p->lbottom) && 
  360.            ( ptl.y < p->ltop))
  361.             {
  362.             pCurItem = p;
  363.             WinSetDlgItemText( hwnd, ST_HINT, pCurItem->cStatusText);
  364.             p = NULL;
  365.             return;
  366.             }
  367.         else
  368.             p = p->pnext;
  369.         }
  370.     
  371.     } /* end of DemoDlgSetStatusText() */
  372.  
  373. /*
  374. *************************************************************************/
  375.  
  376. VOID DemoDlgInit( HWND    hwnd)
  377.  
  378. /************************************************************************
  379. *                                                                       *
  380. * Description : Initialise the buttons and fields in the dialog         *
  381. *                                                                       *
  382. * Function    : 
  383. *                                                                       *
  384. * Return      :                                                         *
  385. *                                                                       *
  386. *************************************************************************/
  387.  
  388.     { 
  389.     
  390.     /***** Set header group data ****************************************/
  391.     
  392.     WinSendDlgItemMsg( hwnd, SPIN_HW, SPBM_SETLIMITS, MPFROMSHORT( 240), MPFROMSHORT( 0));
  393.     WinSendDlgItemMsg( hwnd, SPIN_HW, SPBM_SETCURRENTVALUE, MPFROMSHORT( 28), 0);
  394.     WinSendDlgItemMsg( hwnd, SPIN_HS, SPBM_SETLIMITS, MPFROMSHORT( 15), MPFROMSHORT( 0));
  395.     WinSendDlgItemMsg( hwnd, SPIN_HS, SPBM_SETCURRENTVALUE, MPFROMSHORT( 8), 0);
  396.     WinCheckButton( hwnd, CB_HEADER, 1);
  397.     WinCheckButton( hwnd, CB_ALLPAGES, 1);
  398.     
  399.     /***** set footer goup data *****************************************/
  400.     
  401.     WinSendDlgItemMsg( hwnd, SPIN_FW, SPBM_SETLIMITS, MPFROMSHORT( 240), MPFROMSHORT( 0));
  402.     WinSendDlgItemMsg( hwnd, SPIN_FW, SPBM_SETCURRENTVALUE, MPFROMSHORT( 14), 0);
  403.     WinSendDlgItemMsg( hwnd, SPIN_FS, SPBM_SETLIMITS, MPFROMSHORT( 15), MPFROMSHORT( 0));
  404.     WinSendDlgItemMsg( hwnd, SPIN_FS, SPBM_SETCURRENTVALUE, 0, 0);
  405.     WinCheckButton( hwnd, CB_FOOTER, 1);
  406.     
  407.     /***** set page border goup *****************************************/
  408.     
  409.     WinSendDlgItemMsg( hwnd, SPIN_BW, SPBM_SETLIMITS, MPFROMSHORT( 240), MPFROMSHORT( 0));
  410.     WinSendDlgItemMsg( hwnd, SPIN_BW, SPBM_SETCURRENTVALUE, 0, 0);
  411.     WinSendDlgItemMsg( hwnd, SPIN_BS, SPBM_SETLIMITS, MPFROMSHORT( 15), MPFROMSHORT( 0));
  412.     WinSendDlgItemMsg( hwnd, SPIN_BS, SPBM_SETCURRENTVALUE, 0, 0);
  413.     WinCheckButton( hwnd, CB_BORDER, 0);
  414.     
  415.     /***** set line spacing *********************************************/
  416.     
  417.     WinSendDlgItemMsg( hwnd, SPIN_INTERL, SPBM_SETARRAY, MPFROMP( achLineSpc), MPFROMSHORT( 60));
  418.     WinSendDlgItemMsg( hwnd, SPIN_INTERL, SPBM_SETCURRENTVALUE, MPFROMSHORT( 11), 0);
  419.     
  420.     /***** set left margin **********************************************/
  421.     
  422.     WinSendDlgItemMsg( hwnd, SPIN_LM, SPBM_SETLIMITS, MPFROMSHORT( 100), MPFROMSHORT( 0));
  423.     WinSendDlgItemMsg( hwnd, SPIN_LM, SPBM_SETCURRENTVALUE, MPFROMSHORT( 25), 0);
  424.     
  425.     /***** set right margin *********************************************/
  426.     
  427.     WinSendDlgItemMsg( hwnd, SPIN_RM, SPBM_SETLIMITS, MPFROMSHORT( 100), MPFROMSHORT( 0));
  428.     WinSendDlgItemMsg( hwnd, SPIN_RM, SPBM_SETCURRENTVALUE, MPFROMSHORT( 20), 0);
  429.     
  430.     /***** set top margin ***********************************************/
  431.     
  432.     WinSendDlgItemMsg( hwnd, SPIN_TM, SPBM_SETLIMITS, MPFROMSHORT( 100), MPFROMSHORT( 0));
  433.     WinSendDlgItemMsg( hwnd, SPIN_TM, SPBM_SETCURRENTVALUE, MPFROMSHORT( 20), 0);
  434.     
  435.     /***** set bottom margin ********************************************/
  436.     
  437.     WinSendDlgItemMsg( hwnd, SPIN_BM, SPBM_SETLIMITS, MPFROMSHORT( 100), MPFROMSHORT( 0));
  438.     WinSendDlgItemMsg( hwnd, SPIN_BM, SPBM_SETCURRENTVALUE, MPFROMSHORT( 25), 0);
  439.     
  440.     /***** set default radio button *************************************/
  441.     
  442.     WinCheckButton( hwnd, RB_TEXTL, 1);
  443.     
  444.     /***** Set the font field *******************************************/
  445.     
  446.     WinSetDlgItemText( hwnd, EF_FONT, pszDefFont);
  447.  
  448.     } /* end of DemoDlgInit() */
  449.  
  450. /*
  451. *************************************************************************/
  452.  
  453. VOID DemoDlgGetItemPositions( HWND       hwnd)
  454.  
  455. /************************************************************************
  456. *                                                                       *
  457. * Description : Build list of Items with Status texts                   *
  458. *                                                                       *
  459. * Function    : 
  460. *                                                                       *
  461. * Return      :                                                         *
  462. *                                                                       *
  463. *************************************************************************/
  464.  
  465.     { 
  466.     PILIST      p = NULL;
  467.     SWP         swp;
  468.     USHORT      cnt,
  469.                 usTextId;
  470.     
  471.     for ( cnt = CB_ALLPAGES; cnt <= SPIN_TM; cnt++)
  472.         {
  473.         usTextId = cnt + DEMO_BASE;
  474.         if( pItems)
  475.             {
  476.             p->pnext = ( PILIST) calloc( 1, sizeof( ILIST));
  477.             p = p->pnext;
  478.             }
  479.         else
  480.             {
  481.             pItems = ( PILIST) calloc( 1, sizeof( ILIST));
  482.             p = pItems;
  483.             }
  484.         p->hwnd = WinWindowFromID( hwnd, cnt);
  485.         p->Id = cnt;
  486.         WinQueryWindowPos( p->hwnd, &swp);
  487.         p->lleft = swp.x;
  488.         p->lright = swp.x + swp.cx;
  489.         p->ltop = swp.y + swp.cy;
  490.         p->lbottom = swp.y;
  491.         WinLoadString( Hab, 0L, usTextId, 128, p->cStatusText);
  492.         } /* end of for */
  493.     
  494.     
  495.     } /* end of DemoDlgGetItemPositions() */
  496.  
  497. /*
  498. *************************************************************************/
  499.  
  500. VOID DelItemList( )
  501.  
  502. /************************************************************************
  503. *                                                                       *
  504. * Description : Destroy pItems                                          *
  505. *                                                                       *
  506. * Function    : 
  507. *                                                                       *
  508. * Return      :                                                         *
  509. *                                                                       *
  510. *************************************************************************/
  511.  
  512.     { 
  513.     PILIST      p,
  514.                 q;
  515.     
  516.     p = pItems;
  517.     
  518.     while( p)
  519.         {
  520.         q = p;
  521.         p = p->pnext;
  522.         free( q);
  523.         }
  524.         
  525.     } /* end of DelItemList() */
  526.  
  527.  
  528. /************************************************************************/
  529. /*                                                                      */
  530. /* Printing functions.                                                  */
  531. /*                                                                      */
  532. /************************************************************************/
  533.  
  534. /*
  535. *************************************************************************/
  536.  
  537. BOOL PrepareJob( HWND    hwnd)
  538.  
  539. /************************************************************************
  540. *                                                                       *
  541. * Description : Prepare Headers footers and page borders from fields    *
  542. *               dialog.                                                 *
  543. * Function    : 
  544. *                                                                       *
  545. * Return      :                                                         *
  546. *                                                                       *
  547. *************************************************************************/
  548.  
  549.     { 
  550.     HHEADER             hhdr;
  551.     HFOOTER             hftr;
  552.     USHORT              rc;
  553.     BOOL                bFlag1, bFlag2;
  554.     ULONG               ulData,
  555.                         ulFill,
  556.                         ulLine,
  557.                         ulPts,
  558.                         ullm,
  559.                         ulrm,
  560.                         ultm,
  561.                         ulbm,
  562.                         ulPb,
  563.                         ulPs;
  564.     PSZ                 pszData,
  565.                         pszFont,
  566.                         p,
  567.                         pszTitle = "Test Printing (C/C++)";
  568.     
  569.     /***** Initialise Data structures ***********************************/
  570.     
  571.     pszData = ( PSZ) malloc( 256);
  572.     pszFont = ( PSZ) malloc( 256);
  573.     
  574.     /***** Get the font for printing ************************************/
  575.  
  576.     WinQueryDlgItemText( hwnd, EF_FONT, 256, pszData);
  577.     p = strchr( pszData, ( int)'.');
  578.     if( p)
  579.         {
  580.         *p = '\0';
  581.         ulPts = atol( pszData);
  582.         p++;
  583.         strcpy( achPrtFont, p);
  584.         }
  585.     else
  586.         strcpy( achPrtFont, "Helvetica Bold");
  587.         
  588.     /***** Check if we want headers *************************************/
  589.     
  590.     bFlag1 = ( BOOL)WinQueryButtonCheckstate( hwnd, CB_HEADER);
  591.     
  592.     /***** Check for header on all pages ********************************/
  593.         
  594.     bFlag2 = ( BOOL)WinQueryButtonCheckstate( hwnd, CB_ALLPAGES);
  595.     
  596.     /***** Get header fill style ****************************************/
  597.     
  598.     WinSendMsg( WinWindowFromID( hwnd, SPIN_HS),
  599.                 SPBM_QUERYVALUE, &ulFill, 
  600.                 MPFROM2SHORT( 0, SPBQ_DONOTUPDATE));
  601.     
  602.     /***** Get header line thickness ************************************/
  603.     
  604.     WinSendMsg( WinWindowFromID( hwnd, SPIN_HW),
  605.                 SPBM_QUERYVALUE, &ulLine, 
  606.                 MPFROM2SHORT( 0, SPBQ_DONOTUPDATE));
  607.     
  608.     /***** Set printing colours *****************************************/
  609.     
  610.     PrtGSetPrintColors( hPrt, CLR_BLACK, CLR_BLUE, CLR_YELLOW);
  611.     
  612.     /***** Build the header struct for 3 lines **************************/
  613.     
  614.     hhdr = PrtGDefineHeader( bFlag1, bFlag2, achPrtFont, ulPts, ulFill, ulLine, 3);
  615.     
  616.     /***** Define header texts ******************************************/
  617.     
  618.     PrtGAddHeaderLine( hhdr, 1, "$c|");
  619.     PrtGAddHeaderLine( hhdr, 2, "$lADD Consulting (CH)$r@");
  620.     PrtGAddHeaderLine( hhdr, 3, "Demo for PrtGrafC Dynamic Link Library for C/C++");
  621.     PrtGSetHdrLineFont( hhdr, 1, NULL, 14);
  622.     PrtGDefineHdrColors( hhdr, CLR_BLACK, CLR_RED, CLR_CYAN);
  623.     
  624.     /***** Set the header data for the job ******************************/
  625.     
  626.     rc = PrtGSetHeader( hPrt, hhdr);
  627.     
  628.     /***** Free allocated resources *************************************/
  629.     
  630.     hhdr = PrtGDestroyHdrDef( hhdr);
  631.     if( rc)
  632.         return( FALSE);
  633.     
  634.     /***** Check if we want footers *************************************/
  635.     
  636.     bFlag1 = ( BOOL)WinQueryButtonCheckstate( hwnd, CB_FOOTER);
  637.     
  638.     /***** Get fill style for footers ***********************************/
  639.     
  640.     WinSendMsg( WinWindowFromID( hwnd, SPIN_FS),
  641.                 SPBM_QUERYVALUE, &ulFill, 
  642.                 MPFROM2SHORT( 0, SPBQ_DONOTUPDATE));
  643.     
  644.     /***** Get Line thickness for footers *******************************/
  645.     
  646.     WinSendMsg( WinWindowFromID( hwnd, SPIN_FW),
  647.                 SPBM_QUERYVALUE, &ulLine, 
  648.                 MPFROM2SHORT( 0, SPBQ_DONOTUPDATE));
  649.  
  650.     ulPts = 8;
  651.     
  652.     /***** Build the footer struct **************************************/
  653.     
  654.     hftr = PrtGDefineFooter( bFlag1, achPrtFont, ulPts, ulFill, ulLine, "$▌$rpage $#");
  655.     PrtGDefineFtrColors( hftr, CLR_BLACK, CLR_RED, CLR_CYAN);
  656.     
  657.     /***** Set the footer data for the job ******************************/
  658.         
  659.     rc = PrtGSetFooter( hPrt, hftr);
  660.     
  661.     /***** Free allocated resources *************************************/
  662.     
  663.     hftr = PrtGDestroyFtrDef( hftr);
  664.     if( rc)
  665.         return( FALSE);
  666.     
  667.     /***** Get the inter-line space setting *****************************/
  668.     
  669.     WinSendDlgItemMsg( hwnd, SPIN_INTERL,
  670.                        SPBM_QUERYVALUE, MPFROMP( pszData), 
  671.                        MPFROM2SHORT( 256, SPBQ_DONOTUPDATE));
  672.  
  673.     ulData = atol( pszData);
  674.     rc = PrtGSetLineSpace( hPrt, ( USHORT)ulData);
  675.     if( rc)
  676.         return( FALSE);
  677.     
  678.     /***** Get the margin settings **************************************/
  679.     
  680.     WinSendMsg( WinWindowFromID( hwnd, SPIN_LM),
  681.                 SPBM_QUERYVALUE, &ullm, 
  682.                 MPFROM2SHORT( 0, SPBQ_DONOTUPDATE));
  683.     WinSendMsg( WinWindowFromID( hwnd, SPIN_RM),
  684.                 SPBM_QUERYVALUE, &ulrm, 
  685.                 MPFROM2SHORT( 0, SPBQ_DONOTUPDATE));
  686.     WinSendMsg( WinWindowFromID( hwnd, SPIN_TM),
  687.                 SPBM_QUERYVALUE, &ultm, 
  688.                 MPFROM2SHORT( 0, SPBQ_DONOTUPDATE));
  689.     WinSendMsg( WinWindowFromID( hwnd, SPIN_BM),
  690.                 SPBM_QUERYVALUE, &ulbm, 
  691.                 MPFROM2SHORT( 0, SPBQ_DONOTUPDATE));
  692.     
  693.     /***** Check if we want a page border *******************************/
  694.     
  695.     rc = WinQueryButtonCheckstate( hwnd, CB_BORDER);
  696.     if ( rc)
  697.         {
  698.         WinSendMsg( WinWindowFromID( hwnd, SPIN_BW),
  699.                     SPBM_QUERYVALUE, &ulPb, 
  700.                     MPFROM2SHORT( 0, SPBQ_DONOTUPDATE));
  701.         WinSendMsg( WinWindowFromID( hwnd, SPIN_BS),
  702.                     SPBM_QUERYVALUE, &ulPs, 
  703.                     MPFROM2SHORT( 0, SPBQ_DONOTUPDATE));
  704.         } /* end of if */
  705.     else
  706.         {
  707.         ulPb = 0;
  708.         ulPs = 0;
  709.         } /* end of else */
  710.     
  711.     /***** Set the margins for the job **********************************/
  712.     
  713.     rc = PrtGSetMargins( hPrt, ullm, ulrm, ultm, ulbm, ulPb, ulPs);
  714.     if( rc)
  715.         return( FALSE);
  716.     
  717.     /***** Open the print job *******************************************/
  718.         
  719.     rc = PrtGOpenPrintJob( hPrt, pszTitle, 0, 0);
  720.     if( rc)
  721.         return( FALSE);
  722.         
  723.     return ( TRUE);
  724.          
  725.     } /* end of PrepareJob() */
  726.  
  727. /*
  728. *************************************************************************/
  729.  
  730. BOOL DemoPrint( HWND     hwnd)
  731.  
  732. /************************************************************************
  733. *                                                                       *
  734. * Description : Decide what to print and print it.                      *
  735. *                                                                       *
  736. * Function    : 
  737. *                                                                       *
  738. * Return      :                                                         *
  739. *                                                                       *
  740. *************************************************************************/
  741.  
  742.     { 
  743.     ULONG       ulPts;  
  744.  
  745.     PSZ         pszMask = "Hello everyone, this is some text in %s %lu point which "
  746.                           "wraps over several lines. This is so that you can "
  747.                           "see how the functions in the graphic printing DLL work. "
  748.                           "We hope that you will find them useful.";
  749.     PSZ         pszText;
  750.     
  751.     if( !PrepareJob( hwnd))
  752.         return( FALSE);
  753.  
  754.     if ( WinQueryButtonCheckstate( hwnd, RB_TEXTL))
  755.         {
  756.         ulPts = 8; 
  757.         pszText = ( PSZ)malloc( 1024);
  758.         while ( ulPts <= 24)
  759.             {
  760.             sprintf( pszText, pszMask, achPrtFont, ulPts);
  761.             PrtGPrintLine( hPrt, achPrtFont, ulPts, pszText);
  762.             PrtGPrintLine( hPrt, achPrtFont, ulPts, "");
  763.             ulPts = ulPts + 2;
  764.             } /* end of while */
  765.         free( pszText);
  766.         }
  767.         
  768.     else if ( WinQueryButtonCheckstate( hwnd, RB_TEXTR))
  769.         {
  770.         ulPts = 8; 
  771.         pszText = ( PSZ)malloc( 1024);
  772.         while ( ulPts <= 24)
  773.             {
  774.             sprintf( pszText, pszMask, achPrtFont, ulPts);
  775.             PrtGPrintRight( hPrt, achPrtFont, ulPts, pszText);
  776.             PrtGPrintRight( hPrt, achPrtFont, ulPts, "");
  777.             ulPts = ulPts + 2;
  778.             } /* end of while */
  779.         free( pszText);
  780.         }
  781.  
  782.     else if ( WinQueryButtonCheckstate( hwnd, RB_TEXTC))
  783.         {
  784.         ulPts = 8; 
  785.         pszText = ( PSZ)malloc( 1024);
  786.         while ( ulPts <= 24)
  787.             {
  788.             sprintf( pszText, pszMask, achPrtFont, ulPts);
  789.             PrtGPrintCentered( hPrt, achPrtFont, ulPts, pszText);
  790.             PrtGPrintCentered( hPrt, achPrtFont, ulPts, "");
  791.             ulPts = ulPts + 2;
  792.             } /* end of while */
  793.         free( pszText);
  794.         }
  795.  
  796.     else if ( WinQueryButtonCheckstate( hwnd, RB_TEXTJ))
  797.         {
  798.         ulPts = 8; 
  799.         pszText = ( PSZ)malloc( 1024);
  800.         while ( ulPts <= 24)
  801.             {
  802.             sprintf( pszText, pszMask, achPrtFont, ulPts);
  803.             PrtGPrintJustified( hPrt, achPrtFont, ulPts, pszText);
  804.             PrtGPrintJustified( hPrt, achPrtFont, ulPts, "");
  805.             ulPts = ulPts + 2;
  806.             } /* end of while */
  807.         free( pszText);
  808.         }
  809.  
  810.     else if ( WinQueryButtonCheckstate( hwnd, RB_BITMAP))
  811.         {
  812.         PrtGPrintLine( hPrt, achPrtFont, 14, "Hello everyone, this is boxed printout of the ADD logo");
  813.         PrtGPrintBitmap( hPrt, "C:\\OS2\\BITMAP\\ADDLOGO.BMP", 40, 90, 130, 170, LINE_THICK, CLR_DEFAULT);
  814.         PrtGNewPage( hPrt);
  815.         PrtGPrintLine( hPrt, achPrtFont, 14, "Picture of the print demo window");
  816.         PrtGPrintWinImage( hPrt, hwndDlg, 0, 0, 0, 0, 0, CLR_DEFAULT);
  817.         }
  818.  
  819.     else if ( WinQueryButtonCheckstate( hwnd, RB_TABLES))
  820.         DemoPrintTables( );
  821.  
  822.     else if ( WinQueryButtonCheckstate( hwnd, RB_STYLES))
  823.         DemoPrintStyles( );
  824.         
  825.     else if ( WinQueryButtonCheckstate( hwnd, RB_TABBED))
  826.         DemoPrintTabbed();
  827.     
  828.     if ( PrtGClosePrintJob( hPrt))
  829.         return( FALSE);
  830.     else
  831.         return( TRUE);
  832.  
  833.     } /* end of DemoPrint() */
  834.  
  835. /*
  836. *************************************************************************/
  837.  
  838. VOID DemoPrintTables( )
  839.  
  840. /************************************************************************
  841. *                                                                       *
  842. * Description :                                                         *
  843. *                                                                       *
  844. * Function    : 
  845. *                                                                       *
  846. * Return      :                                                         *
  847. *                                                                       *
  848. *************************************************************************/
  849.  
  850.     { 
  851.     HTABLE      htbl;
  852.     ULONG       aulT1[ 3] = { 45, 50, 40 };
  853.     ULONG       aulT2[ 4] = { 25, 50, 40, 30 };
  854.     
  855.     /********************************************************************/
  856.     /* Define a table with no running headers and three columns.        */
  857.     /* Cells are not filled and have 0.25mm line thickness.             */
  858.     /********************************************************************/
  859.  
  860.     PrtGPrintLine( hPrt, achPrtFont, 12, "The following table is defined without headers...");
  861.  
  862.     htbl = PrtGDefineTable( TRUE, FALSE, FALSE, 14, 0, 0, 0, "", 0, 3, 15);
  863.  
  864.     /***** Add the three columns ****************************************/
  865.     
  866.     PrtGAddColumn( htbl, 1, aulT1[ 0], ""); 
  867.     PrtGAddColumn( htbl, 2, aulT1[ 1], ""); 
  868.     PrtGAddColumn( htbl, 3, aulT1[ 2], ""); 
  869.     
  870.     /***** Start printing the table *************************************/
  871.     
  872.     PrintTable1( htbl);
  873.  
  874.     /***** Destroy table definition *************************************/
  875.     
  876.     htbl = PrtGDestroyTblDef( htbl);
  877.     
  878.     /********************************************************************/
  879.     /* Define a table with running headers and three columns.           */
  880.     /* Cells are not filled and have 0.25mm line thickness.             */
  881.     /********************************************************************/
  882.  
  883.     PrtGPrintLine( hPrt, achPrtFont, 12, "The same table with running headers...");
  884.     
  885.     htbl = PrtGDefineTable( TRUE, TRUE, TRUE, 
  886.                             LINE_THIN, FILL_LIGHT, LINE_MEDIUM, FILL_HALF, 
  887.                             "Helvetica Bold", 
  888.                             12L, 3, 10);
  889.  
  890.     PrtGDefineTableColors( htbl, 
  891.                            CLR_BLACK, CLR_BLUE, CLR_YELLOW,
  892.                            CLR_BLACK, CLR_RED, CLR_CYAN);
  893.                            
  894.     /***** Add the three columns ****************************************/
  895.     
  896.     PrtGAddColumn( htbl, 1, aulT1[ 0], "Column 1"); 
  897.     PrtGAddColumn( htbl, 2, aulT1[ 1], "Column 2"); 
  898.     PrtGAddColumn( htbl, 3, aulT1[ 2], "Column 3"); 
  899.     
  900.     /***** Start printing the table *************************************/
  901.     
  902.     PrintTable1( htbl);
  903.  
  904.     /***** Destroy table definition *************************************/
  905.     
  906.     htbl = PrtGDestroyTblDef( htbl);
  907.     
  908.     /********************************************************************/
  909.     /* Define a four column table with running headers.                 */
  910.     /* The headers will be repeated on each page.                       */
  911.     /********************************************************************/
  912.     
  913.     PrtGPrintLine( hPrt, achPrtFont, 12, "The following table is defined with running headers"
  914.                  " headers and a fill style...");
  915.     
  916.     htbl = PrtGDefineTable( TRUE, TRUE, TRUE, 
  917.                             14L, 0L, 28L, 8L, 
  918.                             "Helvetica Bold", 
  919.                             12L, 4, 20);
  920.  
  921.     /***** Add the four columns *****************************************/
  922.     
  923.     PrtGAddColumn( htbl, 1, aulT2[ 0], "Col N°"); 
  924.     PrtGAddColumn( htbl, 2, aulT2[ 1], "Text"); 
  925.     PrtGAddColumn( htbl, 3, aulT2[ 2], "Random N°"); 
  926.     PrtGAddColumn( htbl, 4, aulT2[ 3], "Text 2"); 
  927.  
  928.     /***** Start the table **********************************************/
  929.  
  930.     PrintTable2( htbl, 20);
  931.         
  932.     htbl = PrtGDestroyTblDef( htbl);
  933.     
  934.     } /* end of DemoPrintTables() */
  935.  
  936.  
  937. /*
  938. *************************************************************************/
  939.  
  940. VOID DemoPrintStyles( )
  941.  
  942. /************************************************************************
  943. *                                                                       *
  944. * Description :                                                         *
  945. *                                                                       *
  946. * Function    : 
  947. *                                                                       *
  948. * Return      :                                                         *
  949. *                                                                       *
  950. *************************************************************************/
  951.  
  952.     { 
  953.     ULONG           ulWide,
  954.                     ulHigh,
  955.                     ulblx,
  956.                     ulbly,
  957.                     ultrx,
  958.                     ultry,
  959.                     ulhinc,
  960.                     ulvinc,
  961.                     ulvpos1,
  962.                     ulvpos2,
  963.                     ulhpos,
  964.                     ulFill;
  965.     char            buffer[ 64];
  966.     
  967.     /***** Get the page size ********************************************/
  968.     
  969.     PrtGGetPageSize( hPrt, &ulWide, &ulHigh);
  970.  
  971.     /***** Calculate positions for printing *****************************/
  972.     
  973.     ulvpos1 = ( ULONG)((ulHigh / 3) * 2);
  974.     ulvpos2 = ( ULONG)(ulHigh / 3);
  975.     ulvinc = ( ULONG)( ulvpos2 / 3);
  976.  
  977.     ulbly = ulvpos1; 
  978.     ultry = ulvpos1 + ulvinc;
  979.  
  980.     ulhpos = ( ULONG)( ulWide / 8);
  981.     ulhinc = ( ULONG)(( ulhpos / 3) * 2);
  982.  
  983.     ulblx = 5;
  984.     ultrx = ulblx + ulhinc;
  985.     
  986.     /***** Say what we are printing *************************************/
  987.     
  988.     PrtGPrintLine( hPrt, achPrtFont, 10, "Defined styles for filling");
  989.     
  990.     /***** print a row of boxes with different styles *******************/
  991.     
  992.     for( ulFill = 0; ulFill <= 7; ulFill++)
  993.         {
  994.         PrtGPrintBox( hPrt, ulblx, ulbly, ultrx, ultry, 28, ulFill, CLR_DEFAULT, CLR_DEFAULT);
  995.         PrtGGoto( hPrt, ulblx, ulbly - 10, FALSE);
  996.         sprintf( buffer, "Style %lu", ulFill);
  997.         PrtGPrintLeft( hPrt, achPrtFont, 10, buffer);
  998.         ulblx += ulhpos;
  999.         ultrx += ulhpos;
  1000.         }
  1001.  
  1002.     /***** print a row of boxes with different styles *******************/
  1003.     
  1004.     ulblx = 5;
  1005.     ultrx = ulblx + ulhinc;
  1006.     ulbly = ulvpos2;
  1007.     ultry = ulvpos2 + ulvinc;
  1008.     
  1009.     for( ulFill = 8; ulFill <= 15; ulFill++)
  1010.         {
  1011.         PrtGPrintBox( hPrt, ulblx, ulbly, ultrx, ultry, 28, ulFill, CLR_DEFAULT, CLR_DEFAULT);
  1012.         PrtGGoto( hPrt, ulblx, ulbly - 10, FALSE);
  1013.         sprintf( buffer, "Style %lu", ulFill);
  1014.         PrtGPrintLeft( hPrt, achPrtFont, 10, buffer);
  1015.         ulblx += ulhpos;
  1016.         ultrx += ulhpos;
  1017.         }
  1018.     
  1019.     } /* end of DemoPrintStyles() */
  1020.  
  1021.  
  1022. /*
  1023. *************************************************************************/
  1024.  
  1025. VOID DemoPrintTabbed( )
  1026.  
  1027. /************************************************************************
  1028. *                                                                       *
  1029. * Description :                                                         *
  1030. *                                                                       *
  1031. * Function    : 
  1032. *                                                                       *
  1033. * Return      :                                                         *
  1034. *                                                                       *
  1035. *************************************************************************/
  1036.  
  1037.     { 
  1038.     ULONG       ulWide,
  1039.                 ulHigh,
  1040.                 ulx,
  1041.                 uly,
  1042.                 ulvinc,
  1043.                 ulhinc;
  1044.     USHORT      numtabs,
  1045.                 i;
  1046.     char        buffer[ 64];
  1047.     
  1048.     PrtGGetPageSize( hPrt, &ulWide, &ulHigh);
  1049.  
  1050.     /***** Calculate the number of tabs *********************************/
  1051.     
  1052.     numtabs = ( ULONG)( ulWide / 10) - 1;
  1053.     
  1054.     /***** Print '|' at each tab position *******************************/
  1055.     
  1056.     PrtGPrintLine( hPrt, achPrtFont, 10, "Tab positions are shown on the next line");
  1057.     PrtGPrintLine( hPrt, "", 0, "");
  1058.     PrtGPrintLeft( hPrt, "",  0, "|");
  1059.  
  1060.     for ( i = 0; i < numtabs; i++)
  1061.         {
  1062.         PrtGTab( hPrt);
  1063.         PrtGPrintLeft( hPrt, "",  0, "|");
  1064.         } /* end of for */
  1065.     
  1066.     /***** show some moves **********************************************/
  1067.  
  1068.     PrtGPrintLine( hPrt, "", 0, "");
  1069.     PrtGPrintLine( hPrt, "", 0, "");
  1070.  
  1071.     PrtGPrintLeft( hPrt, "",  0, "Here we are");
  1072.     PrtGMoveX( hPrt, 10, FALSE);
  1073.     PrtGPrintLeft( hPrt, "",  0, "1 cm right");
  1074.  
  1075.     PrtGMoveY( hPrt, -10, FALSE);
  1076.     PrtGPrintLeft( hPrt, "",  0, "1 cm down ");
  1077.     PrtGMoveY( hPrt, 5, TRUE);
  1078.     PrtGPrintLeft( hPrt, "",  0, "5 pts up ");
  1079.     PrtGMoveY( hPrt, -5, TRUE);
  1080.     PrtGPrintLeft( hPrt, "",  0, "5 pts down");
  1081.  
  1082.     /***** Go to the bottom of the page *********************************/
  1083.     
  1084.     PrtGPrintLine( hPrt, "", 0, "");
  1085.  
  1086.     PrtGMoveX( hPrt, 100, FALSE);
  1087.     PrtGPrintLeft( hPrt, "",  0, "10 cm right");
  1088.  
  1089.     PrtGMoveX( hPrt, -50, FALSE);
  1090.     PrtGPrintLeft( hPrt, "",  0, "5 cm left");
  1091.  
  1092.     PrtGGoto( hPrt, 10, 10, FALSE);
  1093.     PrtGPrintLine( hPrt, "", 20, "The End");
  1094.  
  1095.     
  1096.     } /* end of DemoPrintTabbed() */
  1097.  
  1098.  
  1099. /* */
  1100. /***********************************************************************/
  1101.  
  1102. MRESULT EXPENTRY DemoWndProc(  HWND hwnd,
  1103.                                ULONG msg,
  1104.                                MPARAM mp1,
  1105.                                MPARAM mp2)
  1106.  
  1107. /************************************************************************
  1108. *                                                                       *
  1109. *  Description     : Main Window procedure for Demo program             *
  1110. *                                                                       *
  1111. *  Function        : Message dependant                                  *
  1112. *                                                                       *
  1113. *  Return          : Message dependant                                  *
  1114. *                                                                       *
  1115. ************************************************************************/
  1116.  
  1117.     {
  1118.  
  1119.     switch( msg)
  1120.         {
  1121.         case WM_CREATE :
  1122.  
  1123.             /***** Load the dialog **********************************************/
  1124.     
  1125.             hwndDlg = WinLoadDlg( HWND_DESKTOP,
  1126.                                   hwnd,
  1127.                                   (PFNWP)DemoDlgProc,
  1128.                                   NULLHANDLE,
  1129.                                   DEMO_DLG,
  1130.                                   NULL);
  1131.     
  1132.             return( 0L);
  1133.             
  1134.         default:
  1135.             return( WinDefWindowProc(hwnd, msg, mp1, mp2) );
  1136.         }
  1137.     
  1138.     } /* end of DemoWndProc() */
  1139.  
  1140. /*
  1141. *************************************************************************/
  1142.  
  1143. void PrintTable1( HTABLE    htbl)
  1144.  
  1145. /************************************************************************
  1146. *                                                                       *
  1147. * Description :                                                         *
  1148. *                                                                       *
  1149. * Function    : 
  1150. *                                                                       *
  1151. * Return      :                                                         *
  1152. *                                                                       *
  1153. *************************************************************************/
  1154.  
  1155.     { 
  1156.  
  1157.     if ( !PrtGStartTable( hPrt, htbl))
  1158.         {
  1159.  
  1160.         /***** Start printing a row *************************************/
  1161.         
  1162.         PrtGStartRow( hPrt);
  1163.         
  1164.         /***** write to col 1 *******************************************/
  1165.         
  1166.         PrtGStartCol( hPrt, 1);
  1167.         PrtGPrintRight( hPrt, "Helvetica", 10, "This is some text in the first column. It is not very long,");
  1168.         
  1169.         /***** write to col 2 *******************************************/
  1170.         
  1171.         PrtGStartCol( hPrt, 2);
  1172.         PrtGPrintJustified( hPrt, "Helvetica Bold", 10, "This is some text in the second column. It is not very long,");
  1173.         PrtGPrintJustified( hPrt, "", 0, "This text has several lines and with a bit of luck should force a new page.");
  1174.         PrtGPrintJustified( hPrt, "", 0,"If it does then we have a test of a cell rolling over from one page to the next and we will not have to write any more.");
  1175.         
  1176.         /***** write to col 3 *******************************************/
  1177.         
  1178.         PrtGStartCol( hPrt, 3);
  1179.         PrtGPrintCentered( hPrt, "Helvetica Bold", 14, "This is some text in the third column. It is not very long,");
  1180.         
  1181.         /***** print out the row ****************************************/
  1182.         
  1183.         PrtGEndRow( hPrt);
  1184.         
  1185.         /***** start the next row ***************************************/
  1186.         
  1187.         PrtGStartRow( hPrt);
  1188.         
  1189.         /***** write to col 1 *******************************************/
  1190.         
  1191.         PrtGStartCol( hPrt, 1);
  1192.         PrtGPrintRight( hPrt, "CG Times", 10, "This is some text in the first column. It is not very long,");
  1193.         
  1194.         /***** write to col 2 *******************************************/
  1195.         
  1196.         PrtGStartCol( hPrt, 2);
  1197.         PrtGPrintLeft( hPrt, "Helvetica Bold", 10, "This is some text in the second column. It is not very long and should be left justified.");
  1198.         PrtGPrintCentered( hPrt, "", 0, "This text has several lines and with a bit of luck should be centred.");
  1199.         PrtGPrintJustified( hPrt, "", 0, "This text here was designed to be justified and should roll over several lines, of course the last line will be left aligned.");
  1200.         PrtGPrintRight( hPrt, "", 0, "This last bit of text should finally show all the styles in one cell as it is right aligned.");
  1201.         
  1202.         /***** write to col 3 *******************************************/
  1203.         
  1204.         PrtGStartCol( hPrt, 3);
  1205.         PrtGPrintJustified( hPrt, "CG Times", 8, "This is some text in the third column. It is not very long,");
  1206.         
  1207.         /***** print out the row ****************************************/
  1208.         
  1209.         PrtGEndRow( hPrt);
  1210.         
  1211.         /***** Terminate the table **************************************/
  1212.         
  1213.         PrtGEndTable( hPrt);
  1214.         
  1215.         } /* end of if */
  1216.     else
  1217.         PrtGPrintLeft( hPrt, "Helvetica Bold", 14, "ERROR - Failed to create the table...");
  1218.     
  1219.     } /* end of PrintTable1() */
  1220.  
  1221. /*
  1222. *************************************************************************/
  1223.  
  1224. void PrintTable2( HTABLE    htbl,
  1225.                   USHORT    cnt)
  1226.  
  1227. /************************************************************************
  1228. *                                                                       *
  1229. * Description :                                                         *
  1230. *                                                                       *
  1231. * Function    : 
  1232. *                                                                       *
  1233. * Return      :                                                         *
  1234. *                                                                       *
  1235. *************************************************************************/
  1236.  
  1237.     { 
  1238.     USHORT      i;
  1239.     char        buffer[ 256];
  1240.     
  1241.     if ( !PrtGStartTable( hPrt, htbl))
  1242.         {
  1243.         for ( i = 1; i <= cnt; i++)
  1244.             {
  1245.             PrtGStartRow( hPrt);
  1246.             PrtGStartCol( hPrt, 1);
  1247.             sprintf( buffer, "%u", i);
  1248.             PrtGPrintLeft( hPrt, "Helvetica Bold", 10, buffer);
  1249.             PrtGStartCol( hPrt, 2);
  1250.             PrtGPrintLeft( hPrt, "Helvetica Italic", 10, "Some Helvetica Italic text" );
  1251.             PrtGStartCol( hPrt, 3);
  1252.             sprintf( buffer, "%d", rand());
  1253.             PrtGPrintRight( hPrt, "Helvetica", 10, buffer);
  1254.             PrtGStartCol( hPrt, 4);
  1255.             PrtGPrintRight( hPrt, "Helvetica", 10, "PJK");
  1256.             PrtGEndRow( hPrt);
  1257.             } /* end of for */
  1258.         PrtGEndTable( hPrt);
  1259.         }
  1260.     else
  1261.         PrtGPrintLeft( hPrt, "Helvetica Bold", 14, "ERROR - Failed to create the table...");
  1262.  
  1263.     } /* end of PrintTable2() */
  1264.  
  1265. /*
  1266. *************************************************************************/
  1267.  
  1268. VOID APIENTRY NewPageFunc( HGRPRT  hp,
  1269.                            USHORT  usPage,
  1270.                            BOOL    bTable)
  1271.  
  1272. /************************************************************************
  1273. *                                                                       *
  1274. * Description :                                                         *
  1275. *                                                                       *
  1276. * Function    : 
  1277. *                                                                       *
  1278. * Return      :                                                         *
  1279. *                                                                       *
  1280. *************************************************************************/
  1281.  
  1282.     { 
  1283.     DosBeep( 1000, 500);
  1284.     } /* end of NewPageFunc() */
  1285.  
  1286. /************************************************************************/
  1287. /*                                                                      */
  1288. /*                         (c) ADD Consulting 1995                      */
  1289. /*                                                                      */
  1290. /*                               END OF FILE.                           */
  1291. /*                                                                      */
  1292. /************************************************************************/
  1293.