home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1996 December / CD_shareware_12-96.iso / WIN / Programa / VPE16_14.ZIP / C / VPEDEMO.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-30  |  54.0 KB  |  1,808 lines

  1. //
  2. //              VPEDEMO.CPP
  3. //              ===========
  4. //
  5. // Demonstration of VPE
  6. //
  7. // 1995, 1996 by IDEAL Software, T. Radde
  8. //
  9.  
  10. #include <windows.h>
  11. #include <string.h>
  12. #include <stdlib.h>
  13. #include <stdio.h>
  14. #include <math.h>
  15. #include <time.h>
  16.  
  17. #include "vpiface.h"
  18. #include "vpecomon.h"
  19. #include "colors.h"
  20. #include "vpedemo.rh"
  21.  
  22.  
  23.  
  24. //----------------------------------------------------------------------------
  25. // Defines:
  26. //----------------------------------------------------------------------------
  27.  
  28.  
  29.  
  30. //----------------------------------------------------------------------------
  31. // Prototypes:
  32. //----------------------------------------------------------------------------
  33. // "Hidden" in VPENGINE.DLL:
  34. BOOL FAR PASCAL _export InitCtl3d(HINSTANCE hInstance);
  35. void FAR PASCAL _export UnInstallCtl3d(HINSTANCE hInstance);
  36.  
  37.  
  38.  
  39. //----------------------------------------------------------------------------
  40. // Globals:
  41. //----------------------------------------------------------------------------
  42. HWND hMainWindow;
  43. HWND hMainDlg;
  44.  
  45. long Precision = 0;
  46. long PBackGnd = 0;
  47. long Speed = 0;
  48. long Colors = 0;
  49. long Report = 0;
  50. long Render = 0;
  51.  
  52.  
  53. char *DemoText =
  54. "The moment of impact bursts through the silence and in a roar of sound, the "
  55. "final second is prolonged in a world of echoes as if concrete and clay of "
  56. "Broadway itself was reliving its memories.\n"
  57. "The last great march past. Newsman stands limp as a whimper as audience and "
  58. "eventare locked as one. Bing Crosby coos 'You don't have to feel pain "
  59. "to sing the blues, you don't have to holla - you don't feel a thing in your "
  60. "dollar collar.' Martin Luther cries 'Everybody Sing!' and rings the grand old "
  61. "liberty bell. Leary, weary of his prison cell, walks on heaven, talks on hell.\n"
  62. "Who needs Medicare and the 35c flat rate fare, when Fred Astaire and "
  63. "Ginger Rogers are dancing through the air? From Broadway Melody stereotypes "
  64. "the band returns to 'Stars and Stripes' bringing a tear to the moonshiner, "
  65. "who's been pouring out his spirit from the illegal still. The pawn broker "
  66. "clears the noisy till and clutches his lucky dollar bill.\n"
  67. "Then the blackout.\n\n"
  68. "(Genesis, 'The Lamb lies down on Broadway')";
  69.  
  70.  
  71.  
  72. //----------------------------------------------------------------------------
  73. //                               Precision
  74. //----------------------------------------------------------------------------
  75. #define HEADLINE 1      // ordinal for storing a setting
  76.  
  77.  
  78. // Page 1 of Precision demo
  79. // ========================
  80. void page1(long hdoc)
  81. {
  82.    int y;
  83.    
  84.    y = VpeWriteBox(hdoc, 575, 200, 1625, -1,
  85.    "[Center PenSize 3]This demo shows the capabilities and precision of VPE.\n"
  86.    "Print this page and compare not only the "
  87.    "positions of the frames,\nbut the positions of each letter that can be seen.\n"
  88.    "(Switch the grid on.)\n"
  89.    "This is true WYSIWYG !!!\n('What you see is what you get')\n"
  90.    "Note, that the nearest result can be seen at a scaling of 1:1.\n"
  91.    "With every other scaling you get 'best results' in comparison to execution speed.");
  92.    
  93.    y = VpeWriteBox(hdoc, 100, y + 75, 2000, -1,
  94.    "['Arial' FontSize 14 Left Bold Italic Underline PenSize 0]"
  95.    "RIGHT ALIGNED, 0.25 cm blue frame, light-blue backgr., red bold text, Arial 9pt");
  96.    VpeStoreSet(hdoc, HEADLINE);
  97.    
  98.    VpeSelectFont(hdoc, "Arial", 9);
  99.    VpeSetPen(hdoc, 25, PS_SOLID, COLOR_BLUE);
  100.    VpeSetTextColor(hdoc, COLOR_LTRED);
  101.    VpeSetFontAttr(hdoc, ALIGN_RIGHT, 1, 0, 0);
  102.    VpeSetTransparentMode(hdoc, 0);
  103.    VpeSetBkgColor(hdoc, COLOR_CYAN);
  104.    // y+30 because frame = 0.25cm --> frame drawn around center of coordinates
  105.    // we also want a little gap between the headline and the frame
  106.    y = VpeWriteBox(hdoc, 150, y + 30, 1850, -1, DemoText);
  107.    VpeSetTransparentMode(hdoc, 1);
  108.  
  109.    VpeUseSet(hdoc, HEADLINE);
  110.    y = VpeWrite(hdoc, 250, y + 75, 2000, -1, "JUSTIFIED, no frame, Times New Roman 11pt");
  111.    
  112.    VpeSelectFont(hdoc, "Times New Roman", 11);
  113.    VpeSetFontAttr(hdoc, ALIGN_JUSTIFIED, 0, 0, 0);
  114.    y = VpeWriteBox(hdoc, 250, y + 20, 1550, -1, DemoText);
  115.  
  116.    VpeUseSet(hdoc, HEADLINE);
  117.    y = VpeWriteBox(hdoc, 250, y + 75, 2000, -1, "CENTERED, thin yellow frame, Times New Roman 11pt");
  118.    
  119.    VpeSelectFont(hdoc, "Times New Roman", 11);
  120.    VpeSetFontAttr(hdoc, ALIGN_CENTER, 0, 0, 0);
  121.    VpeSetPen(hdoc, 5, PS_SOLID, COLOR_LTYELLOW);
  122.    y = VpeWriteBox(hdoc, 150, y + 20, 1850, -1, DemoText);
  123. }
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132. // Page 2 of Precision demo
  133. // ========================
  134. void page2(long hdoc)
  135. {
  136.    int y;
  137.    
  138.    VpePageBreak(hdoc);
  139.    VpeUseSet(hdoc, HEADLINE);
  140.    y = VpeWriteBox(hdoc, 200, 200, 2000, -1, "An example of drawing (better to turn the grid off here):");
  141.    VpeSetPen(hdoc, 8, PS_SOLID, COLOR_BLACK);
  142.    VpeBox(hdoc, 200, 300, 1700, 1800);
  143.    VpeSetPen(hdoc, 3, PS_SOLID, COLOR_BLACK);
  144.         
  145.    double xr = 6, xstep = xr / 750;
  146.    double yr = 18;
  147.    double x;
  148.    char s[160];
  149.    int index, skip, first, xx, oldy, segments=0;
  150.    long p;
  151.  
  152.    // The following graph is created with VpeAddPolyPoint().
  153.    // Note, that all routines contain complex handling of clipping.
  154.    x = -xr;
  155.    skip = 0;
  156.    VpeSetPen(hdoc, 2, PS_SOLID, COLOR_BLUE);
  157.    p = VpePolyLine(hdoc, 0, 1500);
  158.         
  159.    for (xx = 200; xx < 1700; xx++)
  160.    {
  161.       y = 1050 - (pow(x, 3) - 2*pow(x, 2) - 8*x) / ( yr / 750);
  162.       x += xstep;
  163.       
  164.       if (y < 300)
  165.       {
  166.          y = 300;
  167.          skip = 1;
  168.          continue;
  169.       }
  170.       else if (y > 1800)
  171.       {
  172.          y = 1800;
  173.          skip = 1;
  174.          continue;
  175.       }
  176.       
  177.       if (skip == 1)
  178.       {
  179.          VpeAddPolyPoint(hdoc, p, -1, -1);
  180.          oldy = y;
  181.          skip = 2;
  182.       }
  183.       else
  184.       {
  185.          if (skip == 2)
  186.          {
  187.             VpeAddPolyPoint(hdoc, p, xx-1, oldy);
  188.             skip = 0;
  189.          }
  190.          VpeAddPolyPoint(hdoc, p, xx, y);
  191.          segments++;
  192.       }
  193.    }
  194.         
  195.  
  196.  
  197.    // The following graph is created directly with VpePolyLine()
  198.    POINT *points = (POINT *)malloc(3 * 1500 * sizeof(POINT));
  199.    x = -xr;
  200.    first = 1;
  201.    VpeSetPen(hdoc, 2, PS_SOLID, COLOR_LTRED);
  202.    index = 0;
  203.    for (xx = 200; xx < 1700; xx++)
  204.    {
  205.       y = 1050 - (3*pow(x, 2) - 4*x - 8) / ( yr / 750);
  206.       x += xstep;
  207.       
  208.       if (y < 300)
  209.       {
  210.          y = 300;
  211.          skip = 1;
  212.          continue;
  213.       }
  214.       else if (y > 1800)
  215.       {
  216.          y = 1800;
  217.          skip = 1;
  218.          continue;
  219.       }
  220.       
  221.       if (skip == 1)
  222.       {
  223.          if (index > 0)    // Array must not begin with -1,-1 pair!
  224.          {
  225.             points[index].x = -1;
  226.             points[index].y = -1;
  227.          }
  228.          // don't increment index here, so we don't have multiple
  229.          // (redundant AND FORBIDDEN) -1, -1 pairs in the array
  230.          oldy = y;
  231.          skip = 2;
  232.       }
  233.       else
  234.       {
  235.          if (skip == 2)
  236.          {
  237.             if (index > 0)
  238.                index++;
  239.             points[index].x = xx - 1;
  240.             points[index].y = oldy;
  241.             index++;
  242.             skip = 0;
  243.          }
  244.          points[index].x = xx;
  245.          points[index].y = y;
  246.          index++;
  247.          segments++;
  248.       }
  249.    }
  250.    
  251.    VpePolyLine(hdoc, points, index);
  252.    free(points);
  253.         
  254.  
  255.  
  256.    // The following graph is created "manually" VpeLine()
  257.    // Never use it for such tasks, it's slow and memory exhausting
  258.    // in comparision to VpePolyLine()
  259.    x = -xr;
  260.    first = 1;
  261.    VpeSetPen(hdoc, 2, PS_SOLID, COLOR_GREEN);
  262.    for (xx = 200; xx < 1700; xx++)
  263.    {
  264.       y = 1050 - (3*x - 4) / ( yr / 750);
  265.       x += xstep;
  266.       
  267.       if (y < 300)
  268.       {
  269.          y = 300;
  270.          first = 1;
  271.          continue;
  272.       }
  273.       else if (y > 1800)
  274.       {
  275.          y = 1800;
  276.          first = 1;
  277.          continue;
  278.       }
  279.       
  280.       if (first)
  281.          oldy = y;
  282.       else
  283.       {
  284.          VpeLine(hdoc, xx-1, oldy, xx, y);
  285.          segments++;
  286.          oldy = y;
  287.       }
  288.       first = 0;
  289.    }
  290.  
  291.  
  292.    VpeSetPen(hdoc, 3, PS_SOLID, COLOR_BLACK);
  293.    VpeLine(hdoc, 200, 1050, 1700, 1050);
  294.    VpeLine(hdoc, 950, 300, 950, 1800);
  295.  
  296.    VpeSelectFont(hdoc, "Arial", 10);
  297.    VpeSetFontAttr(hdoc, ALIGN_LEFT, 0, 0, 0);
  298.    VpeSetPen(hdoc, 1, PS_DOT, COLOR_BLACK);
  299.    for (xx = 1; xx < xr; xx++)
  300.    {
  301.       VpeLine(hdoc, 950 + xx * 750 / 6, 300, 950 + xx * 750 / 6, 1800);
  302.       wsprintf(s, "%d", xx);
  303.       VpePrint(hdoc, 960 + xx * 750 / 6, 1050, s);
  304.       VpeLine(hdoc, 950 - xx * 750 / 6, 300, 950 - xx * 750 / 6, 1800);
  305.       wsprintf(s, "%d", -xx);
  306.       VpePrint(hdoc, 960 - xx * 750 / 6, 1050, s);
  307.    }
  308.  
  309.    for (y = 2; y < yr; y += 2)
  310.    {
  311.       VpeLine(hdoc, 200, 1050 + y * 750 / yr, 1700, 1050 + y * 750 / yr);
  312.       wsprintf(s, "%d", y);
  313.       VpePrint(hdoc, 960, 1050 - y * 750 / yr, s);
  314.       VpeLine(hdoc, 200, 1050 - y * 750 / yr, 1700, 1050 - y * 750 / yr);
  315.       wsprintf(s, "%d", -y);
  316.       VpePrint(hdoc, 960, 1050 + y * 750 / yr, s);
  317.    }
  318.  
  319.    y = 1850;
  320.    wsprintf(s, "[S 14]The three graphs together consist of %d (number determined during runtime) single lines!\n\nVPE manages this data bulk for you FAST!", segments);
  321.    VpeWrite(hdoc, 200, y, 2000, -1, s);
  322. }
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. // Page 3 and 4 of Precision demo
  335. // ==============================
  336. void page3_4(long hdoc)
  337. {
  338.    int y;
  339.    
  340.    VpePageBreak(hdoc);
  341.  
  342.    VpeNoPen(hdoc);
  343.    VpeSetFontAttr(hdoc, ALIGN_CENTER, 0, 1, 0);
  344.    VpeSelectFont(hdoc, "Arial", 18);
  345.    VpeWrite(hdoc, 0, 150, 2100, 300, "The supported barcode-types:");
  346.    VpeSelectFont(hdoc, "Arial", 10);
  347.    VpeSetBold(hdoc, 1);
  348.    
  349.    VpeWrite(hdoc, 200, 300, 550, 400, "2 of 5:");
  350.    VpeBarcode(hdoc, 200, 360, 550, 560, BCT_2OF5, "123789", NULL);
  351.  
  352.    VpeWrite(hdoc, 700, 300, 1200, 400, "Interleaved 2 of 5:");
  353.    VpeBarcode(hdoc, 700, 360, 1200, 560, BCT_INTERLEAVED2OF5, "123895783482", NULL);
  354.  
  355.    VpeWrite(hdoc, 1350, 300, 1750, 400, "Code 39 (text on top):");
  356.    VpeSetBarcodeParms(hdoc, 1, 0);
  357.    VpeBarcode(hdoc, 1350, 360, 1750, 560, BCT_CODE39, "ABC123", NULL);
  358.  
  359.    VpeWrite(hdoc, 200, 700, 550, 800, "Code 93 (rotated):");
  360.    VpeSetBarcodeParms(hdoc, 0, 0);
  361.    VpeSetRotation(hdoc, 900);
  362.    VpeBarcode(hdoc, 275, 760, -300, -200, BCT_CODE93, "DEF987", NULL);
  363.  
  364.    VpeWrite(hdoc, 700, 700, 1200, 800, "[Rot 0]Codabar (rotated):");
  365.    VpeSetRotation(hdoc, 1800);
  366.    VpeBarcode(hdoc, 700, 760, -500, -200, BCT_CODABAR, "123456", NULL);
  367.  
  368.    VpeWrite(hdoc, 1400, 700, 1700, 800, "[Rot 0]EAN-8 (rotated):");
  369.    VpeSetRotation(hdoc, 2700);
  370.    VpeBarcode(hdoc, 1450, 760, -300, -200, BCT_EAN8, "40167794", NULL);
  371.  
  372.    VpeWrite(hdoc, 200, 1200, 500, 1400, "[Rot 0]EAN-8 + 2:");
  373.    VpeSetBarcodeParms(hdoc, 0, 1);
  374.    VpeBarcode(hdoc, 200, 1260, 500, 1460, BCT_EAN8_2, "12345670", "12");
  375.  
  376.    VpeWrite(hdoc, 700, 1200, 1200, 1400, "EAN-8 + 5:");
  377.    VpeSetBarcodeParms(hdoc, 0, 0);
  378.    VpeBarcode(hdoc, 700, 1260, 1200, 1460, BCT_EAN8_5, "98765430", "12345");
  379.  
  380.    VpeWrite(hdoc, 1350, 1200, 1750, 1400, "EAN-13:");
  381.    VpeBarcode(hdoc, 1350, 1260, 1750, 1460, BCT_EAN13, "9781556153952", NULL);
  382.  
  383.    VpeWrite(hdoc, 200, 1600, 600, 1800, "EAN-13 + 2:");
  384.    VpeBarcode(hdoc, 200, 1660, 600, 1860, BCT_EAN13_2, "4501645096787", "12");
  385.  
  386.    VpeWrite(hdoc, 700, 1600, 1200, 1800, "EAN-13 + 5:");
  387.    VpeSetBarcodeParms(hdoc, 0, 1);
  388.    VpeBarcode(hdoc, 700, 1660, 1200, 1860, BCT_EAN13_5, "9781556153952", "12345");
  389.  
  390.    VpeWrite(hdoc, 1350, 1600, 1750, 1800, "EAN-128 A:");
  391.    VpeSetBarcodeParms(hdoc, 0, 0);
  392.    VpeBarcode(hdoc, 1350, 1660, 1750, 1860, BCT_EAN128A, "EAN-128 A", NULL);
  393.  
  394.    VpeWrite(hdoc, 200, 2000, 600, 2200, "EAN-128 B:");
  395.    VpeBarcode(hdoc, 200, 2060, 600, 2260, BCT_EAN128B, "ean-128 b", NULL);
  396.  
  397.    VpeWrite(hdoc, 700, 2000, 1200, 2200, "EAN-128 C:");
  398.    VpeBarcode(hdoc, 700, 2060, 1200, 2260, BCT_EAN128C, "128902", NULL);
  399.  
  400.    VpeWrite(hdoc, 1350, 2000, 1850, 2200, "POSTNET (1.20) 5 or 9 digits:");
  401.    VpeBarcode(hdoc, 1350, 2060, 1628, 2120, BCT_POSTNET, "12345", NULL);
  402.    VpeBarcode(hdoc, 1350, 2150, 1850, 2210, BCT_POSTNET, "414649623", NULL);
  403.  
  404.    VpePageBreak(hdoc);
  405.  
  406.    VpeSetFontAttr(hdoc, ALIGN_CENTER, 0, 1, 0);
  407.    VpeSelectFont(hdoc, "Arial", 18);
  408.    VpeWrite(hdoc, 0, 150, 2100, 300, "The supported barcode-types (continued):");
  409.    VpeSelectFont(hdoc, "Arial", 10);
  410.    VpeSetBold(hdoc, 1);
  411.  
  412.    VpeWrite(hdoc, 200, 300, 550, 400, "UPC-A:");
  413.    VpeBarcode(hdoc, 200, 360, 550, 560, BCT_UPCA, "07447079382", NULL);
  414.  
  415.    VpeWrite(hdoc, 700, 300, 1100, 400, "UPC-A + 2:");
  416.    VpeBarcode(hdoc, 700, 360, 1100, 560, BCT_UPCA_2, "07447079382", "01");
  417.  
  418.    VpeWrite(hdoc, 1350, 300, 1800, 400, "UPC-A + 5:");
  419.    VpeBarcode(hdoc, 1350, 360, 1800, 560, BCT_UPCA_5, "03126764825", "94687");
  420.  
  421.    VpeWrite(hdoc, 200, 700, 550, 900, "UPC-E:");
  422.    VpeBarcode(hdoc, 200, 760, 550, 960, BCT_UPCE, "0378492", NULL);
  423.  
  424.    VpeWrite(hdoc, 700, 700, 1100, 900, "UPC-E + 2:");
  425.    VpeBarcode(hdoc, 700, 760, 1100, 960, BCT_UPCE_2, "0378492", "14");
  426.  
  427.    VpeWrite(hdoc, 1350, 700, 1800, 900, "UPC-E + 5:");
  428.    VpeBarcode(hdoc, 1350, 760, 1800, 960, BCT_UPCE_5, "0364825", "79462");
  429.  
  430.    VpeSetFontAttr(hdoc, ALIGN_LEFT, 0, 0, 0);
  431.    y = VpeWrite(hdoc, 200, 1100, 1800, VFREE,
  432.                 "VPE supports 21 barcode types. Barcodes can be rotated in 90 degree steps, the "
  433.                 "text can be drawn on bottom or top of the barcode, and also independently "
  434.                 "the add-on text. Any of these features can be combined.");
  435.  
  436.    y = VpePrint(hdoc, 500, y+100, "[S 24 U C LtYellow]Text and images");
  437.    VpePrint(hdoc, VRIGHT, VBOTTOM, "[Rot 900 C Blue] can be freely ");
  438.    VpeWriteBox(hdoc, 500, VBOTTOM, VLEFT, VFREE, "[Rot 1800 C Red CE]rotated in 90");
  439.  
  440.    // The WIDTH (after rotation it's the height) is the top of the last inserted text
  441.    // minus the bottom of the first inserted object.
  442.    VpeWriteBox(hdoc, 400, y, -(VpeGet(hdoc, VTOP) - y), VFREE, "[Rot 2700 C Green]degree steps");
  443. }
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451. // Page 5 of Precision demo
  452. // ========================
  453. void page5(long hdoc)
  454. {
  455.    int y, x;
  456.    
  457.    VpePageBreak(hdoc);
  458.    VpeUseSet(hdoc, HEADLINE);
  459.    y = VpeWriteBox(hdoc, 100, 200, 2000, -1,
  460.                    "VPE is also able to manage bitmaps for you!\n"
  461.                    "Place your logo wherever you want.");
  462.    y = VpeWriteBox(hdoc, 100, y, 1400, -1,
  463.        "[S 10 L BO IO UO](Note: These are 256-color bitmaps, in 16-color mode it doesn't look very good)");
  464.  
  465.    y = VpeWriteBox(hdoc, 100, y + 50, 1400, -1, "[N B U]VPE supports the following graphics file formats:");
  466.        VpeWriteBox(hdoc, 100, y, 1400, -1,
  467.        "-Windows and OS/2 Bitmaps (2 / 16 / 256 / True Color)\n"
  468.        "-Windows WMF (Metafile)\n"
  469.        "-AutoCAD DXF\n"
  470.        "-GIF (2 / 16 / 256 Colors)\n"
  471.        "-PCX (2 / 16 / 256 Colors)\n"
  472.        "-JPG (256 / True Color)\n"
  473.        "-TIFF 5.0 (2 / 16 / 256 / True Color, LZW / PackBits / Fax G3 & G4 / Tiled Images)\n"
  474.        "-Microsoft filters (feature, some restrictions and only 16-bit version)");
  475.    VpeSetPen(hdoc, 5, PS_SOLID, COLOR_BLACK);
  476.    VpePicture(hdoc, 1400, 150, -1, -1, "logo.bmp", PIC_KEEPIMAGE | PIC_KEEP_DIB_PAGE);
  477.    y = VpeGet(hdoc, VBOTTOM);
  478.    x = VpeGet(hdoc, VRIGHT);
  479.    VpeWriteBox(hdoc, 1400, y, x, -1, "[N S 14 CE C White BC Red TO Italic Bold]IDEAL Software");
  480.    VpeDefaultBitmapDPI(hdoc, 96, 96);
  481.    VpePicture(hdoc, 1400, VpeGet(hdoc, VBOTTOM) + 100, -1, -1, "fruits.bmp", PIC_KEEPIMAGE | PIC_KEEP_DIB_PAGE);
  482.  
  483.    y = VpeWriteBox(hdoc, 150, y + 400, 1500, -1,
  484.                "[S 14 CE PS 0]Scale your bitmaps as you like:");
  485.    y += 20;
  486.    VpeSetPen(hdoc, 3, PS_SOLID, COLOR_BLACK);
  487.    VpePicture(hdoc, 150, y, 200, -1, "logo.bmp", PIC_KEEPIMAGE | PIC_KEEP_DIB_PAGE);
  488.    VpePicture(hdoc, VpeGet(hdoc, VRIGHT) + 100, y, VpeGet(hdoc, VRIGHT) + 250, -1, "logo.bmp", PIC_KEEPIMAGE | PIC_KEEP_DIB_PAGE);
  489.    VpePicture(hdoc, VpeGet(hdoc, VRIGHT) + 100, y, VpeGet(hdoc, VRIGHT) + 750, -1, "logo.bmp", PIC_KEEPIMAGE | PIC_KEEP_DIB_PAGE);
  490.  
  491.    y = VpeGet(hdoc, VBOTTOM) + 300;
  492.    y = VpePrint(hdoc, 150, y, "[N U]Draw! Set the Pen, Background Color and Hatch Style:");
  493.    y += 50;
  494.    VpeSetTransparentMode(hdoc, 0);
  495.    VpeSetBkgColor(hdoc, COLOR_BLUE);
  496.    VpeBox(hdoc, 150, y, -300, -300);
  497.  
  498.    VpeSetHatchStyle(hdoc, HS_BDIAGONAL);
  499.    VpeSetHatchColor(hdoc, COLOR_BLUE);
  500.    VpeSetBkgColor(hdoc, COLOR_LTYELLOW);
  501.    VpeNoPen(hdoc);
  502.    long p = VpePolygon(hdoc, NULL, 4);
  503.    VpeAddPolygonPoint(hdoc, p, 250, y+400);
  504.    VpeAddPolygonPoint(hdoc, p, 500, y+600);
  505.    VpeAddPolygonPoint(hdoc, p, 300, y+700);
  506.    VpeAddPolygonPoint(hdoc, p, 150, y+1000);
  507.  
  508.    VpeSetPen(hdoc, 6, PS_SOLID, COLOR_BLACK);
  509.    p = VpePolygon(hdoc, NULL, 4);
  510.    VpeAddPolygonPoint(hdoc, p, 650, y);
  511.    VpeAddPolygonPoint(hdoc, p, 1000, y+200);
  512.    VpeAddPolygonPoint(hdoc, p, 700, y+300);
  513.    VpeAddPolygonPoint(hdoc, p, 550, y+600);
  514.  
  515.    VpeNoPen(hdoc);
  516.    VpeSetHatchStyle(hdoc, HS_DIAGCROSS);
  517.    VpeSetHatchColor(hdoc, COLOR_RED);
  518.    VpeSetBkgColor(hdoc, COLOR_CYAN);
  519.    VpeEllipse(hdoc, 750, 2150, -500, -300);
  520.  
  521.    VpeSetHatchStyle(hdoc, HS_FDIAGONAL);
  522.    VpeSetPen(hdoc, 10, PS_SOLID, COLOR_GREEN);
  523.    VpeSetTransparentMode(hdoc, 1);
  524.    int y2 = VpeWrite(hdoc, 1200, y + 200, -500, -1, "[S 12 B CE]Write text beyond,");
  525.    VpeEllipse(hdoc, 1200, y, -500, -500);
  526.    VpeWrite(hdoc, 1200, y2, -500, -1, "or above the hatching.");
  527.  
  528.    VpeSetTransparentMode(hdoc, 0);
  529.    VpeWriteBox(hdoc, 770, 2280, -460, -1, "[PS 3 PC Black HSN BC Cyan S 10 NB]Or blank the hatching out.");
  530.  
  531.    VpeSetTransparentMode(hdoc, 1);
  532. }
  533.  
  534.  
  535.    
  536.  
  537.  
  538.  
  539.  
  540.  
  541. // Page 6 of Precision demo
  542. // ========================
  543. void page6(long hdoc)
  544. {
  545.    VpePageBreak(hdoc);
  546.  
  547.    VpeNoPen(hdoc);
  548.    VpePicture(hdoc, 0, 0, -1, -1, "gew.tif", PIC_KEEPIMAGE | PIC_KEEP_DIB_PAGE);
  549.  
  550.    VpeWrite(hdoc, 250, 110, 1200, -1, "[S 24 C LtRed L PS 0]Stadt Xhausen");
  551.    VpeWrite(hdoc, 250, 500, 1000, -1, "[S 14 C Blue]Mustermann & Co.\nFeinkost Im- und Export");
  552.    VpeWrite(hdoc, 1200, 460, 1700, -1, "[S 11 B]Dⁿsseldorf");
  553.    VpeWrite(hdoc, 250, 670, 750, -1, "Schmidt");
  554.    VpeWrite(hdoc, 250, 840, 750, -1, "24.7. 1947");
  555.    VpeWrite(hdoc, 500, 835, 1000, -1, "Oberammergau");
  556.    VpeWrite(hdoc, 250, 1010, 750, -1, "Zunderstr. 93");
  557.    VpeWrite(hdoc, 1000, 1000, 1750, -1, "0 27 84 / 16 45 98");
  558.    VpeWrite(hdoc, 250, 1255, 1750, -1, "Willi-Graf-Str. 17");                   
  559.    VpeWrite(hdoc, 1000, 1255, 1750, -1, "0 27 84 / 23 54 90");
  560.    VpeWrite(hdoc, 1220, 660, 1750, -1, "Heinz - Willi");
  561.    VpeWrite(hdoc, 1100, 1500, 1950, -1,
  562.    "[S 10 J I]"
  563.    "It is very important to mention here, that the bitmap form has a resolution of 96 "
  564.    "DPI only. The print will not be very nice. Just try a 300 DPI bitmap on your own!");
  565. }
  566.  
  567.  
  568.  
  569.  
  570.   
  571.  
  572.   
  573.  
  574.  
  575. // Precision demo
  576. // ==============
  577. void precision(int mode = 0)
  578. {
  579.    long hdoc;
  580.  
  581.    if (mode == 0)
  582.    {
  583.       hdoc = VpeOpenDoc(hMainWindow, "Precision + Capabilities", -1, -1, VPE_EMBEDDED | VPE_GRID_POSSIBLE | VPE_ROUTE_HELP);
  584.       Precision = hdoc;
  585.    }
  586.    else
  587.    {
  588.       hdoc = VpeOpenDoc(hMainWindow, "Precision + Capabilities",  -1, -1, 0);
  589.       PBackGnd = hdoc;
  590.    }
  591.  
  592.    VpeSetAutoBreak(hdoc, AUTO_BREAK_NO_LIMITS);
  593.    VpeSetFontAttr(hdoc, ALIGN_LEFT, 0, 1, 1);
  594.    VpeSetPen(hdoc, 0, PS_SOLID, 0);
  595.    VpeDefineHeader(hdoc, 100, 100, 1000, 150, "Precision + Capabilities   /  IDEAL Software");
  596.    VpeSetUnderlined(hdoc, 0);
  597.    VpeDefineFooter(hdoc, 1900, 2800, 2100, 2900, "Page @PAGE");
  598.  
  599.    page1(hdoc);
  600.    page2(hdoc);
  601.    page3_4(hdoc);
  602.    page5(hdoc);
  603.    page6(hdoc);
  604.  
  605.    VpeRemoveSet(hdoc, HEADLINE);
  606.    VpeGotoPage(hdoc, 1);
  607.  
  608.    if (mode == 0)
  609.       VpePreviewDoc(hdoc, NULL, VPE_SHOW_NORMAL);
  610.    else
  611.    {
  612.       VpePrintDoc(hdoc, FALSE);
  613.       VpeCloseDoc(hdoc);
  614.    }
  615. }
  616.  
  617.  
  618.  
  619.  
  620.  
  621.  
  622. //----------------------------------------------------------------------------
  623. // Report Demo
  624. //
  625. // This all is done manually, only for your eyes...
  626. //----------------------------------------------------------------------------
  627. void reporttest()
  628. {
  629.    long hdoc;
  630.    int y;
  631.     
  632.    hdoc = VpeOpenDoc(hMainWindow, "Report", -1, -1, 0);
  633.    VpeSetAutoBreak(hdoc, AUTO_BREAK_NO_LIMITS);
  634.    Report = hdoc;
  635.    VpeSetPen(hdoc, 5, PS_SOLID, COLOR_BLACK);
  636.    VpePicture(hdoc, 1650, 150, -1, -1, "fruits.bmp", PIC_KEEPIMAGE | PIC_KEEP_DIB_PAGE);
  637.    VpeWriteBox(hdoc, 1650, VpeGet(hdoc, VBOTTOM), VpeGet(hdoc, VRIGHT), -1, "[N S 9 CE I C Blue BC Gray TO]Fruits of Doom Software");
  638.    y = VpeGet(hdoc, VBOTTOM) + 100;
  639.    VpePrint(hdoc, 150, 200, "[N S 26 U]Year End Results");
  640.    VpePrint(hdoc, 150, 400, "[N S 32]Fruits of Doom Software");
  641.  
  642.    VpeLine(hdoc, 150, y, 2000, y);
  643.    y += 50;
  644.  
  645.    VpeNoPen(hdoc);
  646.    VpePrintBox(hdoc, 150, y, "[N S 18 C Blue]Product: Apples");
  647.    y = VpeGet(hdoc, VBOTTOM) + 10;
  648.    VpePrint(hdoc, 150, y, "[S 16 C Purple]Country");
  649.    VpePrint(hdoc, 650, y, "Quantity");
  650.    VpePrint(hdoc, 1150, y, "Value (in $)");
  651.  
  652.    y = VpeGet(hdoc, VBOTTOM);
  653.    VpeSetTransparentMode(hdoc, FALSE);
  654.    VpeSetBkgColor(hdoc, COLOR_GRAY);
  655.    VpeBox(hdoc, 150, y, 1550, y+60);
  656.    VpeSetTransparentMode(hdoc, TRUE);
  657.    VpePrint(hdoc, 150, y, "[S 14 C Black]Germany");
  658.    VpeWrite(hdoc, 650, y, 900, y+60, "[R]2.450,00");
  659.    VpeWrite(hdoc, 1150, y, 1450, y+60, "120.050,00");
  660.  
  661.    y = VpeGet(hdoc, VBOTTOM);
  662.    VpeSetTransparentMode(hdoc, FALSE);
  663.    VpeSetBkgColor(hdoc, COLOR_CYAN);
  664.    VpeBox(hdoc, 150, y, 1550, y+60);
  665.    VpeSetTransparentMode(hdoc, TRUE);
  666.    VpePrint(hdoc, 150, y, "Great Britain");
  667.    VpeWrite(hdoc, 650, y, 900, y+60, "2.250,00");
  668.    VpeWrite(hdoc, 1150, y, 1450, y+60, "110.250,00");
  669.  
  670.    y = VpeGet(hdoc, VBOTTOM);
  671.    VpeSetTransparentMode(hdoc, FALSE);
  672.    VpeSetBkgColor(hdoc, COLOR_GRAY);
  673.    VpeBox(hdoc, 150, y, 1550, y+60);
  674.    VpeSetTransparentMode(hdoc, TRUE);
  675.    VpePrint(hdoc, 150, y, "France");
  676.    VpeWrite(hdoc, 650, y, 900, y+60, "1.700,00");
  677.    VpeWrite(hdoc, 1150, y, 1450, y+60, "83.300,00");
  678.  
  679.    y = VpeGet(hdoc, VBOTTOM);
  680.    VpeSetTransparentMode(hdoc, FALSE);
  681.    VpeSetBkgColor(hdoc, COLOR_CYAN);
  682.    VpeBox(hdoc, 150, y, 1550, y+60);
  683.    VpeSetTransparentMode(hdoc, TRUE);
  684.    VpePrint(hdoc, 150, y, "USA");
  685.    VpeWrite(hdoc, 650, y, 900, y+60, "3.200,00");
  686.    VpeWrite(hdoc, 1150, y, 1450, y+60, "156.800,00");
  687.  
  688.    y = VpeGet(hdoc, VBOTTOM);
  689.    VpeSetTransparentMode(hdoc, FALSE);
  690.    VpeSetBkgColor(hdoc, COLOR_GRAY);
  691.    VpeBox(hdoc, 150, y, 1550, y+60);
  692.    VpeSetTransparentMode(hdoc, TRUE);
  693.    VpePrint(hdoc, 150, y, "Australia");
  694.    VpeWrite(hdoc, 650, y, 900, y+60, "1.080,00");
  695.    VpeWrite(hdoc, 1150, y, 1450, y+60, "52.920,00");
  696.  
  697.    y = VpeGet(hdoc, VBOTTOM);
  698.    VpePrint(hdoc, 150, y, "Total");
  699.    VpeWrite(hdoc, 650, y, 900, y+60, "10.680,00");
  700.    VpeWrite(hdoc, 1150, y, 1450, y+60, "523.320,00");
  701.  
  702.  
  703.  
  704.  
  705.    y += 210;
  706.    VpePrintBox(hdoc, 150, y, "[N S 18 C Blue]Product: Oranges");
  707.    y = VpeGet(hdoc, VBOTTOM) + 10;
  708.    VpePrint(hdoc, 150, y, "[S 16 C Purple]Country");
  709.    VpePrint(hdoc, 650, y, "Quantity");
  710.    VpePrint(hdoc, 1150, y, "Value (in $)");
  711.  
  712.    y = VpeGet(hdoc, VBOTTOM);
  713.    VpeSetTransparentMode(hdoc, FALSE);
  714.    VpeSetBkgColor(hdoc, COLOR_GRAY);
  715.    VpeBox(hdoc, 150, y, 1550, y+60);
  716.    VpeSetTransparentMode(hdoc, TRUE);
  717.    VpePrint(hdoc, 150, y, "[S 14 C Black]Germany");
  718.    VpeWrite(hdoc, 650, y, 900, y+60, "[R]2.450,00");
  719.    VpeWrite(hdoc, 1150, y, 1450, y+60, "120.050,00");
  720.  
  721.    y = VpeGet(hdoc, VBOTTOM);
  722.    VpeSetTransparentMode(hdoc, FALSE);
  723.    VpeSetBkgColor(hdoc, COLOR_CYAN);
  724.    VpeBox(hdoc, 150, y, 1550, y+60);
  725.    VpeSetTransparentMode(hdoc, TRUE);
  726.    VpePrint(hdoc, 150, y, "Great Britain");
  727.    VpeWrite(hdoc, 650, y, 900, y+60, "2.250,00");
  728.    VpeWrite(hdoc, 1150, y, 1450, y+60, "110.250,00");
  729.  
  730.    y = VpeGet(hdoc, VBOTTOM);
  731.    VpeSetTransparentMode(hdoc, FALSE);
  732.    VpeSetBkgColor(hdoc, COLOR_GRAY);
  733.    VpeBox(hdoc, 150, y, 1550, y+60);
  734.    VpeSetTransparentMode(hdoc, TRUE);
  735.    VpePrint(hdoc, 150, y, "France");
  736.    VpeWrite(hdoc, 650, y, 900, y+60, "1.700,00");
  737.    VpeWrite(hdoc, 1150, y, 1450, y+60, "83.300,00");
  738.  
  739.    y = VpeGet(hdoc, VBOTTOM);
  740.    VpeSetTransparentMode(hdoc, FALSE);
  741.    VpeSetBkgColor(hdoc, COLOR_CYAN);
  742.    VpeBox(hdoc, 150, y, 1550, y+60);
  743.    VpeSetTransparentMode(hdoc, TRUE);
  744.    VpePrint(hdoc, 150, y, "USA");
  745.    VpeWrite(hdoc, 650, y, 900, y+60, "3.200,00");
  746.    VpeWrite(hdoc, 1150, y, 1450, y+60, "156.800,00");
  747.  
  748.    y = VpeGet(hdoc, VBOTTOM);
  749.    VpeSetTransparentMode(hdoc, FALSE);
  750.    VpeSetBkgColor(hdoc, COLOR_GRAY);
  751.    VpeBox(hdoc, 150, y, 1550, y+60);
  752.    VpeSetTransparentMode(hdoc, TRUE);
  753.    VpePrint(hdoc, 150, y, "Australia");
  754.    VpeWrite(hdoc, 650, y, 900, y+60, "1.080,00");
  755.    VpeWrite(hdoc, 1150, y, 1450, y+60, "52.920,00");
  756.  
  757.    y = VpeGet(hdoc, VBOTTOM);
  758.    VpePrint(hdoc, 150, y, "Total");
  759.    VpeWrite(hdoc, 650, y, 900, y+60, "10.680,00");
  760.    VpeWrite(hdoc, 1150, y, 1450, y+60, "523.320,00");
  761.  
  762.  
  763.  
  764.    y += 210;
  765.    VpePrintBox(hdoc, 150, y, "[N S 18 C Blue]Product: Bananas");
  766.    y = VpeGet(hdoc, VBOTTOM) + 10;
  767.    VpePrint(hdoc, 150, y, "[S 16 C Purple]Country");
  768.    VpePrint(hdoc, 650, y, "Quantity");
  769.    VpePrint(hdoc, 1150, y, "Value (in $)");
  770.  
  771.    y = VpeGet(hdoc, VBOTTOM);
  772.    VpeSetTransparentMode(hdoc, FALSE);
  773.    VpeSetBkgColor(hdoc, COLOR_GRAY);
  774.    VpeBox(hdoc, 150, y, 1550, y+60);
  775.    VpeSetTransparentMode(hdoc, TRUE);
  776.    VpePrint(hdoc, 150, y, "[S 14 C Black]Germany");
  777.    VpeWrite(hdoc, 650, y, 900, y+60, "[R]2.450,00");
  778.    VpeWrite(hdoc, 1150, y, 1450, y+60, "120.050,00");
  779.  
  780.    y = VpeGet(hdoc, VBOTTOM);
  781.    VpeSetTransparentMode(hdoc, FALSE);
  782.    VpeSetBkgColor(hdoc, COLOR_CYAN);
  783.    VpeBox(hdoc, 150, y, 1550, y+60);
  784.    VpeSetTransparentMode(hdoc, TRUE);
  785.    VpePrint(hdoc, 150, y, "Great Britain");
  786.    VpeWrite(hdoc, 650, y, 900, y+60, "2.250,00");
  787.    VpeWrite(hdoc, 1150, y, 1450, y+60, "110.250,00");
  788.  
  789.    y = VpeGet(hdoc, VBOTTOM);
  790.    VpeSetTransparentMode(hdoc, FALSE);
  791.    VpeSetBkgColor(hdoc, COLOR_GRAY);
  792.    VpeBox(hdoc, 150, y, 1550, y+60);
  793.    VpeSetTransparentMode(hdoc, TRUE);
  794.    VpePrint(hdoc, 150, y, "France");
  795.    VpeWrite(hdoc, 650, y, 900, y+60, "1.700,00");
  796.    VpeWrite(hdoc, 1150, y, 1450, y+60, "83.300,00");
  797.  
  798.    y = VpeGet(hdoc, VBOTTOM);
  799.    VpeSetTransparentMode(hdoc, FALSE);
  800.    VpeSetBkgColor(hdoc, COLOR_CYAN);
  801.    VpeBox(hdoc, 150, y, 1550, y+60);
  802.    VpeSetTransparentMode(hdoc, TRUE);
  803.    VpePrint(hdoc, 150, y, "USA");
  804.    VpeWrite(hdoc, 650, y, 900, y+60, "3.200,00");
  805.    VpeWrite(hdoc, 1150, y, 1450, y+60, "156.800,00");
  806.  
  807.    y = VpeGet(hdoc, VBOTTOM);
  808.    VpeSetTransparentMode(hdoc, FALSE);
  809.    VpeSetBkgColor(hdoc, COLOR_GRAY);
  810.    VpeBox(hdoc, 150, y, 1550, y+60);
  811.    VpeSetTransparentMode(hdoc, TRUE);
  812.    VpePrint(hdoc, 150, y, "Australia");
  813.    VpeWrite(hdoc, 650, y, 900, y+60, "1.080,00");
  814.    VpeWrite(hdoc, 1150, y, 1450, y+60, "52.920,00");
  815.  
  816.    y = VpeGet(hdoc, VBOTTOM);
  817.    VpePrint(hdoc, 150, y, "Total");
  818.    VpeWrite(hdoc, 650, y, 900, y+60, "10.680,00");
  819.    VpeWrite(hdoc, 1150, y, 1450, y+60, "523.320,00");
  820.  
  821.    y = VpeGet(hdoc, VBOTTOM) + 210;
  822.    VpePrint(hdoc, 150, y, "[N S 20 U]Yearly Country Sales Total: $1.569.960,00");
  823.  
  824.    // Draw a pie
  825.    // use the VpeGet()-stuff to easily position this anywhere on the paper
  826.    // ====================================================================
  827.    VpePageBreak(hdoc);
  828.    VpeSelectFont(hdoc, "Times New Roman", 12);
  829.    VpePrint(hdoc, 200, VBOTTOM, "[N S 18 U]Analyze of Paradise:");
  830.    VpeSetPen(hdoc, 3, PS_SOLID, COLOR_BLACK);
  831.    VpeSetTransparentMode(hdoc, FALSE);
  832.    VpeSetBkgColor(hdoc, COLOR_RED);
  833.  
  834.    VpePie(hdoc, 200, VpeGet(hdoc, VBOTTOM) + 100, -600, -600, 0, 300);
  835.    VpeStorePos(hdoc);
  836.    VpeBox(hdoc, VpeGet(hdoc, VRIGHT) + 200, VpeGet(hdoc, VTOP) + 20, -30, -30);
  837.    VpePrint(hdoc, VpeGet(hdoc, VRIGHT) + 30, VpeGet(hdoc, VTOP) - 10, "[N T]Apples");
  838.  
  839.    VpeRestorePos(hdoc);
  840.    VpeSetBkgColor(hdoc, COLOR_BLUE);
  841.    VpePie(hdoc, VLEFT, VTOP, VRIGHT, VBOTTOM, 300, 750);
  842.    VpeStorePos(hdoc);
  843.    VpeBox(hdoc, VpeGet(hdoc, VRIGHT) + 200, VpeGet(hdoc, VTOP) + 70, -30, -30);
  844.    VpePrint(hdoc, VpeGet(hdoc, VRIGHT) + 30, VpeGet(hdoc, VTOP) - 10, "[N T]Oranges");
  845.  
  846.    VpeRestorePos(hdoc);
  847.    VpeSetBkgColor(hdoc, COLOR_LTYELLOW);
  848.    VpePie(hdoc, VLEFT, VTOP, VRIGHT, VBOTTOM, 750, 1500);
  849.    VpeStorePos(hdoc);
  850.    VpeBox(hdoc, VpeGet(hdoc, VRIGHT) + 200, VpeGet(hdoc, VTOP) + 120, -30, -30);
  851.    VpePrint(hdoc, VpeGet(hdoc, VRIGHT) + 30, VpeGet(hdoc, VTOP) - 10, "[N T]Bananas");
  852.  
  853.    VpeRestorePos(hdoc);
  854.    VpeSetBkgColor(hdoc, COLOR_GREEN);
  855.    VpePie(hdoc, VLEFT, VTOP, VRIGHT, VBOTTOM, 1500, 2900);
  856.    VpeStorePos(hdoc);
  857.    VpeBox(hdoc, VpeGet(hdoc, VRIGHT) + 200, VpeGet(hdoc, VTOP) + 170, -30, -30);
  858.    VpePrint(hdoc, VpeGet(hdoc, VRIGHT) + 30, VpeGet(hdoc, VTOP) - 10, "[N T]Cherries");
  859.  
  860.    VpeRestorePos(hdoc);
  861.    VpeSetBkgColor(hdoc, COLOR_CYAN);
  862.    VpePie(hdoc, VLEFT, VTOP, VRIGHT, VBOTTOM, 2900, 0);
  863.    VpeStorePos(hdoc);
  864.    VpeBox(hdoc, VpeGet(hdoc, VRIGHT) + 200, VpeGet(hdoc, VTOP) + 220, -30, -30);
  865.    VpePrint(hdoc, VpeGet(hdoc, VRIGHT) + 30, VpeGet(hdoc, VTOP) - 10, "[N T]Coconuts");
  866.  
  867.    VpeSetTransparentMode(hdoc, TRUE);
  868.  
  869.    VpeGotoPage(hdoc, 1);
  870.    VpePreviewDoc(hdoc, NULL, VPE_SHOW_NORMAL);
  871. }
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879. //----------------------------------------------------------------------------
  880. //                               Colortest
  881. //----------------------------------------------------------------------------
  882. void colortest()
  883. {
  884.    const int range = 1400;
  885.    const int step = 1;
  886.    const int color_step = 2;
  887.    const int min_color = 0;
  888.    const int max_color = 255;
  889.    
  890.    long hdoc;
  891.    RECT rc;
  892.    int x, y;
  893.    int r, g, b;
  894.    int delta_r, delta_g, delta_b;
  895.    double xx, factor;
  896.    
  897.    hdoc = VpeOpenDoc(hMainWindow, "Colors", -1, -1, VPE_NO_MOUSE_SCALE | VPE_NO_USER_MOVE | VPE_NO_USER_CLOSE | VPE_NO_STATBAR | VPE_NO_RULER | VPE_NO_HELPBTN | VPE_NO_INFOBTN);
  898.    VpeSetAutoBreak(hdoc, AUTO_BREAK_NO_LIMITS);
  899.    VpeSetScale(hdoc, 0.25);
  900.    Colors = hdoc;
  901.   
  902.    VpeSetPen(hdoc, 0, PS_SOLID, COLOR_BLACK);
  903.    VpeSelectFont(hdoc, "Arial", 30);
  904.  
  905.    xx = -3.1415;
  906.    factor = 2 * fabs(xx) / (double)range * (double)step;
  907.  
  908.    r = 192;
  909.    delta_r = color_step;
  910.    g = min_color+1;
  911.    delta_g = color_step;
  912.    b = min_color+1;
  913.    delta_b = color_step;
  914.    
  915.    for (x = 100; x < range+100; x+=step)
  916.    {
  917.      y = sin(xx) * 500.0 + 500;
  918.      VpeSetTextColor(hdoc, RGB( r, g, b));
  919.      VpeWriteBox(hdoc, x, y, x+800, y + 120, "Color Test");
  920.  
  921.      if (x % 10 == 0)
  922.      {
  923.         xx += factor;
  924.         x += step;
  925.         y = sin(xx) * 500.0 + 500;
  926.         VpeSetTextColor(hdoc, COLOR_BLACK);
  927.         VpeWriteBox(hdoc, x, y, x+800, y + 120, "Color Test");
  928.      }
  929.      
  930.      xx += factor;
  931.      if (r > min_color && r < max_color)
  932.      {
  933.         r += delta_r;
  934.         if (r < min_color)
  935.            r = min_color;
  936.         if (r > max_color)
  937.            r = max_color;
  938.      }
  939.      else if (g > min_color && g < max_color)
  940.      {
  941.         g += delta_g;
  942.         if (g < min_color)
  943.            g = min_color;
  944.         if (g > max_color)
  945.            g = max_color;
  946.      }
  947.      else if (b > min_color && b < max_color)
  948.      {
  949.         b += delta_b;
  950.         if (b < min_color)
  951.            b = min_color;
  952.         if (b > max_color)
  953.            b = max_color;
  954.      }
  955.  
  956.      if (r >= max_color && b >= max_color)
  957.      {
  958.         delta_r = -color_step;
  959.         r = max_color-1;
  960.      }
  961.      if (r >= min_color && g >= max_color)
  962.      {
  963.         delta_g = -color_step;
  964.         g = max_color-1;
  965.      }
  966.      if (g == min_color && b >= max_color)
  967.      {
  968.         delta_b = -color_step;
  969.         b = max_color-1;
  970.      }
  971.  
  972.      if (r==min_color && g==min_color && b==min_color)
  973.      {
  974.         r = min_color+1; g=min_color+1; b=min_color+1;
  975.         delta_r = delta_g = delta_b = color_step;
  976.      }
  977.    }
  978.  
  979.    rc.left = 0;
  980.    rc.top = 0;
  981.    rc.right = 280;
  982.    rc.bottom =200;
  983.    VpePreviewDoc(hdoc, &rc, VPE_SHOW_NORMAL);
  984. }
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995. // ========================================================================
  996. //                            SpeedTest
  997. // ========================================================================
  998.  
  999. #define RPT_PATH        "journal.rpt"
  1000.  
  1001.  
  1002. // ========================================================================
  1003. //                            Globals
  1004. // ========================================================================
  1005. double sum_amount=0, sum_prorated=0, sum_tax=0;
  1006.  
  1007.  
  1008.  
  1009. // ========================================================================
  1010. //                            striplf
  1011. // ========================================================================
  1012. void striplf(char *s)
  1013. {
  1014.    int i;
  1015.  
  1016.    for (i=strlen(s)-1; i>=0 && s[i]=='\n'; i--)
  1017.       s[i] = 0;
  1018. }
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025. // ========================================================================
  1026. //                            stof
  1027. // ========================================================================
  1028. double stof(char *s)
  1029. {
  1030.    int i;
  1031.    char *p = s;
  1032.  
  1033.    while (*s)
  1034.    {
  1035.       if (*s == ',')
  1036.          *s = '.';
  1037.       else if (*s == '.')
  1038.       {
  1039.          for (i=0; s[i]; i++)
  1040.             s[i] = s[i+1];
  1041.       }
  1042.       s++;
  1043.    }
  1044.  
  1045.    return atof(p);
  1046. }
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054. // ========================================================================
  1055. //                            stoDM
  1056. // ========================================================================
  1057. void stoDM(char *s)
  1058. {
  1059.    int i, begin, tocopy;
  1060.    char *p, tmp[128];
  1061.  
  1062.    strcpy(tmp, s);
  1063.    p = tmp;
  1064.  
  1065.    while (*p)
  1066.    {
  1067.       if (*p == '.')
  1068.          *p = ',';
  1069.       p++;
  1070.    }
  1071.  
  1072.    i = strlen(tmp) - 3;    // 2 Nachkommastellen und tausender-punkt
  1073.    p = tmp;
  1074.    begin = TRUE;
  1075.    *s = '\0';
  1076.  
  1077.    while (i > 0)
  1078.    {
  1079.       tocopy = i % 3;
  1080.       if (tocopy == 0)
  1081.       {
  1082.          if (!begin)
  1083.             strcat(s, ".");
  1084.          tocopy = 3;
  1085.       }
  1086.       strncat(s, p, tocopy);
  1087.       p += tocopy;
  1088.       i -= tocopy;
  1089.       begin = FALSE;
  1090.    }
  1091.  
  1092.    strcat(s, p);
  1093. }
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099. // ========================================================================
  1100. //                              PrintJournal
  1101. //
  1102. // Structure of input-file
  1103. // =======================
  1104. // User-Name
  1105. // Year
  1106. // Start Month (or blank)
  1107. // End Month (or blank)
  1108. // <@>Table-Name --> start a new table!!!
  1109. // No.
  1110. // Date
  1111. // Amount
  1112. // Prorated Amount
  1113. // Tax
  1114. // Remark
  1115. // Remark
  1116. //
  1117. // NOTE: In this demo Y2 has a constant value for much faster processing
  1118. //
  1119. // ========================================================================
  1120.  
  1121. // ========================================================================
  1122. //                              GenerateReport
  1123. // ========================================================================
  1124. void GenerateReport()
  1125. {
  1126.    FILE *fh;
  1127.    int i, stepper, min, z;
  1128.    long count = 0;
  1129.    long table = 1;
  1130.  
  1131.    srand((int)clock());
  1132.    SetDlgItemText(hMainDlg, 110, "Generating pseudo report-file...");
  1133.  
  1134.    fh = fopen(RPT_PATH, "wt");
  1135.    fprintf(fh, "Test-Document\n");
  1136.    fprintf(fh, "1996\n\n");
  1137.    z = 0;
  1138.    
  1139.    while (count < 20000L)
  1140.    {
  1141.       if (z++ < rand() % 5 + 10)
  1142.       {
  1143.          stepper = 4;
  1144.          min = 3;
  1145.       }
  1146.       else
  1147.       {
  1148.          stepper = 21;
  1149.          min = 20;
  1150.          z = 0;
  1151.       }
  1152.       
  1153.       fprintf(fh, "@Table %ld\n", table++);
  1154.       for (i=rand() % stepper + min; i > 0; i--)
  1155.       {
  1156.          fprintf(fh, "%ld\n%2d.%02d.95\n", count, rand() % 28 + 1, rand() %12+1);
  1157.          fprintf(fh, "%d,%02d\n", rand(), rand() % 100);
  1158.          fprintf(fh, "%d,%02d\n", rand(), rand() % 100);
  1159.          fprintf(fh, "%d,%02d\n\n\n", rand(), rand() % 100);
  1160.          count += 7;
  1161.       }
  1162.    }
  1163.  
  1164.    fclose(fh);
  1165.    
  1166.    SetDlgItemText(hMainDlg, 110, "Report generation finished.");
  1167. }
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175. // ========================================================================
  1176. //                              PrintHeader
  1177. // ========================================================================
  1178. void PrintHeader(long hdoc, char *table)
  1179. {
  1180.    VpeSetAlign(hdoc, ALIGN_CENTER);
  1181.    VpeSelectFont(hdoc, "Arial", 14);
  1182.    VpeSetBkgColor(hdoc, COLOR_LTGRAY);
  1183.    VpeWriteBox(hdoc, VLEFTMARGIN, VBOTTOM, VRIGHTMARGIN, -60, table);
  1184.  
  1185.    VpeSetFontAttr(hdoc, ALIGN_CENTER, 1, 0, 0);
  1186.    VpeSelectFont(hdoc, "Arial", 11);
  1187.    VpeWriteBox(hdoc, VLEFTMARGIN, VBOTTOM, -200, -50, "No.");
  1188.    VpeWriteBox(hdoc, VRIGHT, VTOP, -200, VBOTTOM, "Date");
  1189.    VpeWriteBox(hdoc, VRIGHT, VTOP, -250, VBOTTOM, "Amount");
  1190.    VpeWriteBox(hdoc, VRIGHT, VTOP, -250, VBOTTOM, "Prorated Amount");
  1191.    VpeWriteBox(hdoc, VRIGHT, VTOP, -250, VBOTTOM, "Tax");
  1192.    VpeWriteBox(hdoc, VRIGHT, VTOP, VRIGHTMARGIN, VBOTTOM, "Remark");
  1193.    VpeSetFontAttr(hdoc, ALIGN_LEFT, 0, 0, 0);
  1194.    VpeSetBkgColor(hdoc, RGB(255, 255, 255));
  1195. }
  1196.  
  1197.  
  1198.  
  1199.  
  1200. // ========================================================================
  1201. //                              PrintFooter
  1202. // ========================================================================
  1203. void PrintFooter(long hdoc)
  1204. {
  1205.    char s[20];
  1206.  
  1207.    VpeSetFontAttr(hdoc, ALIGN_CENTER, 1, 0, 0);
  1208.    VpeSetBkgColor(hdoc, COLOR_LTGRAY);
  1209.    VpeWriteBox(hdoc, VLEFTMARGIN, VBOTTOM, -400, -50, "Sum");
  1210.    VpeSetFontAttr(hdoc, ALIGN_RIGHT, 1, 0, 0);
  1211.    sprintf(s, "%.2f", sum_amount);
  1212.    stoDM(s);
  1213.    VpeWriteBox(hdoc, VRIGHT, VTOP, -250, VBOTTOM, s);
  1214.    sprintf(s, "%.2f", sum_prorated);
  1215.    stoDM(s);
  1216.    VpeWriteBox(hdoc, VRIGHT, VTOP, -250, VBOTTOM, s);
  1217.    sprintf(s, "%.2f", sum_tax);
  1218.    stoDM(s);
  1219.    VpeWriteBox(hdoc, VRIGHT, VTOP, -250, VBOTTOM, s);
  1220.    VpeWriteBox(hdoc, VRIGHT, VTOP, VRIGHTMARGIN, VBOTTOM, "");
  1221.    VpeSetFontAttr(hdoc, ALIGN_LEFT, 0, 0, 0);
  1222.    VpeSetBkgColor(hdoc, RGB(255, 255, 255));
  1223. }
  1224.  
  1225.  
  1226.  
  1227.  
  1228.  
  1229. // ========================================================================
  1230. //                              PrintFoot
  1231. // ========================================================================
  1232. void PrintPageFooter(long hdoc, char *name, int page)
  1233. {
  1234.    char buf[32];
  1235.  
  1236.    VpeStorePos(hdoc);
  1237.    VpeNoPen(hdoc);
  1238.    VpeWriteBox(hdoc, VLEFTMARGIN, VBOTTOMMARGIN, VpeGet(hdoc, VRIGHTMARGIN) - 400, -50, name);
  1239.    sprintf(buf, "Journal Page %d", page);
  1240.    VpeSetAlign(hdoc, ALIGN_RIGHT);
  1241.    VpeWriteBox(hdoc, VRIGHT, VBOTTOMMARGIN, VRIGHTMARGIN, -50, buf);
  1242.    VpeSetPen(hdoc, 3, PS_SOLID, COLOR_BLACK);
  1243.    VpeRestorePos(hdoc);
  1244. }
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251. // ========================================================================
  1252. //                              PageBreak
  1253. // ========================================================================
  1254. void PageBreak(long hdoc, int page)
  1255. {
  1256.    char z[80];
  1257.    
  1258.    VpePageBreak(hdoc);
  1259.    
  1260.    if (page % 10 == 0)
  1261.    {
  1262.       wsprintf(z, "now reading inputfile and generating page %d", page);
  1263.       SetDlgItemText(hMainDlg, 110, z);
  1264.    }
  1265. }
  1266.  
  1267.  
  1268.  
  1269.  
  1270.  
  1271. // ========================================================================
  1272. //                              PrintJournal
  1273. // ========================================================================
  1274. BOOL PrintJournal()
  1275. {
  1276.    long hdoc;
  1277.    FILE *fh;
  1278.    char s[256], buf[514];
  1279.    char name[80], year[8], period[32], table[128];
  1280.    int  footer_ok = FALSE, page = 1;
  1281.  
  1282.    HCURSOR hOldCursor;
  1283.    hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  1284.    
  1285.    if ((fh=fopen(RPT_PATH, "rt")) == NULL)
  1286.    {
  1287.       SetDlgItemText(hMainDlg, 110, "ERROR: Report-file not found!");
  1288.       return FALSE;
  1289.    }
  1290.  
  1291.    hdoc = VpeOpenDoc(hMainWindow, "Speed + Tables", -1, -1, VPE_GRID_POSSIBLE);
  1292.    VpeSetAutoBreak(hdoc, AUTO_BREAK_NO_LIMITS);
  1293.    Speed = hdoc;
  1294.    VpeSetTransparentMode(hdoc, FALSE);
  1295.  
  1296.  
  1297.    // Read constant data block:
  1298.    // =========================
  1299.    fgets(name, sizeof(name), fh);
  1300.    striplf(name);
  1301.    fgets(year, sizeof(year), fh);
  1302.    striplf(year);
  1303.    fgets(s, sizeof(s), fh);
  1304.    striplf(s);
  1305.    
  1306.    if (strlen(s) > 0)
  1307.    {
  1308.       if (strncmp(s, "Month", 5) == 0)       // if "Month" possibly eliminate 2 Blanks
  1309.       {
  1310.          if (s[7] == ' ')
  1311.          {
  1312.             s[6] = s[8];
  1313.             s[7] = '\0';
  1314.          }
  1315.       }
  1316.       strcpy(period, ", ");
  1317.       strcat(period, s);
  1318.    }
  1319.    else
  1320.       *period = '\0';
  1321.  
  1322.    sprintf(s, "Journal %s%s", year, period);
  1323.    VpeSetPen(hdoc, 0, 0, COLOR_BLACK);
  1324.    VpeSetFontAttr(hdoc, ALIGN_CENTER, 0, 1, 0);
  1325.    VpeSelectFont(hdoc, "Arial", 16);
  1326.    VpeWriteBox(hdoc, VLEFTMARGIN, VTOPMARGIN, VRIGHTMARGIN, VFREE, s);
  1327.  
  1328.    VpeSetPen(hdoc, 3, PS_SOLID, COLOR_BLACK);
  1329.    VpeSetFontAttr(hdoc, ALIGN_LEFT, 0, 0, 0);
  1330.    VpeSelectFont(hdoc, "Arial", 11);
  1331.  
  1332.    // process variable data:
  1333.    // ======================
  1334.    while (!feof(fh) && fgets(s, sizeof(s), fh))
  1335.    {
  1336.       striplf(s);
  1337.       if (*s == '@')
  1338.       {
  1339.          // Beginning of a new table:
  1340.          // =========================
  1341.          if (footer_ok)
  1342.             PrintFooter(hdoc);
  1343.          sum_amount=sum_prorated=sum_tax=0;
  1344.  
  1345.          // Is the room to the page-bottom big enough for a new table ?
  1346.          if (VpeGet(hdoc, VBOTTOMMARGIN) - VpeGet(hdoc, VBOTTOM) < 400)
  1347.          {
  1348.             // No, add a new page:
  1349.             PrintPageFooter(hdoc, name, page);
  1350.             PageBreak(hdoc, page);
  1351.             page++;
  1352.          }
  1353.          else
  1354.          {
  1355.             // Beginning of new table is 1cm below previous table:
  1356.             VpeSet(hdoc, VBOTTOM, VpeGet(hdoc, VBOTTOM) + 100);
  1357.          }
  1358.          strcpy(table, s+1);
  1359.          PrintHeader(hdoc, table);
  1360.          footer_ok = FALSE;
  1361.       }
  1362.       else
  1363.       {
  1364.          // list part:
  1365.          // ==========
  1366.          footer_ok = TRUE;
  1367.          VpeSetTransparentMode(hdoc, 1);
  1368.          VpeSetAlign(hdoc, ALIGN_RIGHT);
  1369.          VpeWriteBox(hdoc, VLEFTMARGIN, VBOTTOM, -200, -50, s);
  1370.  
  1371.          fgets(s, sizeof(s), fh);
  1372.          striplf(s);
  1373.          VpeWriteBox(hdoc, VRIGHT, VTOP, -200, VBOTTOM, s);
  1374.  
  1375.          fgets(s, sizeof(s), fh);
  1376.          striplf(s);
  1377.          sum_amount += stof(s);
  1378.          stoDM(s);
  1379.          VpeWriteBox(hdoc, VRIGHT, VTOP, -250, VBOTTOM, s);
  1380.  
  1381.          fgets(s, sizeof(s), fh);
  1382.          striplf(s);
  1383.          sum_prorated += stof(s);
  1384.          stoDM(s);
  1385.          VpeWriteBox(hdoc, VRIGHT, VTOP, -250, VBOTTOM, s);
  1386.  
  1387.          fgets(s, sizeof(s), fh);
  1388.          striplf(s);
  1389.          sum_tax += stof(s);
  1390.          stoDM(s);
  1391.          VpeWriteBox(hdoc, VRIGHT, VTOP, -250, VBOTTOM, s);
  1392.  
  1393.          fgets(s, sizeof(s), fh);
  1394.          striplf(s);
  1395.          strcpy(buf, s);
  1396.          strcat(buf, " ");
  1397.          fgets(s, sizeof(s), fh);
  1398.          striplf(s);
  1399.          strcat(buf, s);
  1400.          VpeSetAlign(hdoc, ALIGN_LEFT);
  1401.          VpeSelectFont(hdoc, "Arial", 6);
  1402.          VpeWriteBox(hdoc, VRIGHT, VTOP, VRIGHTMARGIN, VBOTTOM, buf);
  1403.          VpeSelectFont(hdoc, "Arial", 11);
  1404.          VpeSetTransparentMode(hdoc, 0);
  1405.          
  1406.          if (VpeGet(hdoc, VBOTTOM) + 150 > VpeGet(hdoc, VBOTTOMMARGIN))
  1407.          {
  1408.             // Bottom of page reached:
  1409.             // =======================
  1410.             PrintFooter(hdoc);
  1411.             PrintPageFooter(hdoc, name, page);
  1412.             PageBreak(hdoc, page);
  1413.             page++;
  1414.             PrintHeader(hdoc, table);
  1415.          }
  1416.       } // else
  1417.    } // while
  1418.  
  1419.    fclose(fh);
  1420.  
  1421.    PrintFooter(hdoc);
  1422.    PrintPageFooter(hdoc, name, page);
  1423.  
  1424.    VpeGotoPage(hdoc, 1);
  1425.  
  1426.    wsprintf(s, "Generated %d pages out of textfile!", VpeGetPageCount(hdoc));
  1427.    VpeWriteBox(hdoc, 100, 100, 1000, 150, s);
  1428.  
  1429.    SetCursor(hOldCursor);
  1430.    SetDlgItemText(hMainDlg, 110, "");
  1431.  
  1432.    VpePreviewDoc(hdoc, NULL, VPE_SHOW_MAXIMIZED);
  1433.    
  1434.    return TRUE;
  1435. }
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441. // ========================================================================
  1442. //                              AutoRender
  1443. // ========================================================================
  1444. #define MAX_TEXT_LEN 64000L     // due to 16-bit windows limits
  1445.  
  1446. void AutoRender()
  1447. {
  1448.    long hdoc, len;
  1449.    FILE *fh;
  1450.    char *text;
  1451.    HCURSOR hOldCursor;
  1452.  
  1453.    if ((fh=fopen(".\\c\\vpedemo.cpp", "rb")) == NULL)
  1454.    {
  1455.       SetDlgItemText(hMainDlg, 110, "ERROR: file '.\\c\\vpedemo.cpp' not found!");
  1456.       return;
  1457.    }
  1458.  
  1459.    hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  1460.    
  1461.    text = (char *)malloc(MAX_TEXT_LEN + 1);
  1462.    len = fread(text, 1, MAX_TEXT_LEN, fh);
  1463.    text[len] = '\0';
  1464.    fclose(fh);
  1465.    
  1466.    hdoc = VpeOpenDoc(hMainWindow, "Auto Rendering", -1, -1, VPE_GRID_POSSIBLE);
  1467.    Render = hdoc;
  1468.  
  1469.    VpeSelectFont(hdoc, "Courier New", 10);
  1470.  
  1471.    // Header will be placed outside default output rectangle:
  1472.    VpeNoPen(hdoc);
  1473.    VpeSetUnderlined(hdoc, 1);
  1474.    VpeDefineHeader(hdoc, 100, 100, -700, -50, "Auto Text Break Demo - Page @PAGE");
  1475.  
  1476.    // On every intial page:
  1477.    // VLEFT   = VLEFTMARGIN
  1478.    // VTOP    = VTOPMARGIN
  1479.    // VRIGHT  = VRIGHTMARGIN
  1480.    // VBOTTOM = VBOTTOMMARGIN !!!!!!!!!!
  1481.    VpeSetUnderlined(hdoc, 0);
  1482.    VpeSetPen(hdoc, 3, PS_SOLID, 0);
  1483.    VpeWriteBox(hdoc, VLEFT, VBOTTOM, VRIGHT, VFREE, "[N TO BC LtGray CE S 12 B]Start of Listing");
  1484.    VpeWriteBox(hdoc, VLEFT, VBOTTOM, VRIGHT, VFREE, text);
  1485.    VpeWriteBox(hdoc, VLEFT, VBOTTOM, VRIGHT, VFREE, "[N TO BC LtGray CE S 12 B]End of Listing");
  1486.  
  1487.    free(text);
  1488.    VpeGotoPage(hdoc, 1);
  1489.    SetCursor(hOldCursor);
  1490.    VpePreviewDoc(hdoc, NULL, VPE_SHOW_MAXIMIZED);
  1491. }
  1492.    
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499. // ========================================================================
  1500. //                              DlgSelectProc
  1501. // ========================================================================
  1502. BOOL FAR PASCAL _export DlgSelectProc(HWND hDlg, UINT message, UINT wParam, LONG /* lParam */)
  1503. {
  1504.    switch (message)
  1505.    {
  1506.     case WM_INITDIALOG:
  1507.        hMainDlg = hDlg;
  1508.        return TRUE;
  1509.  
  1510.     case WM_COMMAND:
  1511.        SetDlgItemText(hMainDlg, 110, "");
  1512.        switch(wParam)
  1513.        {
  1514.           case ID_PRECISION:
  1515.              if (Precision)
  1516.                 SetDlgItemText(hMainDlg, 110, "Precision test is already running");
  1517.              else
  1518.              {
  1519.                 SetDlgItemText(hMainDlg, 110, "The window titled 'VPE' is the applications main window. It's content is an embedded window from the VPE-DLL!!! You just need a few lines of code!");
  1520.                 precision();
  1521.                 EnableWindow(GetDlgItem(hMainDlg, ID_CPRECISION), TRUE);
  1522.                 EnableWindow(GetDlgItem(hMainDlg, ID_PAGE_LEFT), TRUE);
  1523.                 EnableWindow(GetDlgItem(hMainDlg, ID_PAGE_RIGHT), TRUE);
  1524.              }
  1525.              break;
  1526.              
  1527.           case ID_CPRECISION:
  1528.              if (!VpeCloseDoc(Precision))
  1529.                 SetDlgItemText(hMainDlg, 110, "Can't close, task 'precision test' is currently printing");
  1530.              break;
  1531.  
  1532.           case ID_PAGE_LEFT:
  1533.              VpeSetUpdate(Precision, TRUE);
  1534.              VpeGotoPage(Precision, VpeGetCurrentPage(Precision)-1);
  1535.              VpeSetUpdate(Precision, FALSE);
  1536.              break;
  1537.              
  1538.           case ID_PAGE_RIGHT:
  1539.              VpeSetUpdate(Precision, TRUE);
  1540.              VpeGotoPage(Precision, VpeGetCurrentPage(Precision)+1);
  1541.              VpeSetUpdate(Precision, FALSE);
  1542.              break;
  1543.  
  1544.           case ID_PBACKGND:
  1545.               SetDlgItemText(hMainDlg, 110, "Here no preview is shown. Also no printer-setup is done - the settings of the default printer are taken");
  1546.               EnableWindow(GetDlgItem(hMainDlg, ID_PBACKGND), FALSE);
  1547.              precision(1);
  1548.              break;
  1549.              
  1550.  
  1551.           case ID_GENERATE:
  1552.              GenerateReport();
  1553.              break;
  1554.    
  1555.           case ID_REMOVEREP:
  1556.              remove(RPT_PATH);
  1557.              break;
  1558.  
  1559.           case ID_SPEED:
  1560.              if (Speed)
  1561.                 SetDlgItemText(hMainDlg, 110, "Speed test is already running");
  1562.              else
  1563.              {
  1564.                 if (PrintJournal())
  1565.                    EnableWindow(GetDlgItem(hMainDlg, ID_CSPEED), TRUE);
  1566.              }
  1567.              break;
  1568.              
  1569.           case ID_CSPEED:
  1570.              if (!VpeCloseDoc(Speed))
  1571.                 SetDlgItemText(hMainDlg, 110, "Can't close, task 'speed test' is currently printing");
  1572.              break;
  1573.              
  1574.           case ID_COLORS:
  1575.              if (Colors)
  1576.                 SetDlgItemText(hMainDlg, 110, "Color test is already running");
  1577.              else
  1578.              {
  1579.                 colortest();
  1580.                 EnableWindow(GetDlgItem(hMainDlg, ID_CCOLORS), TRUE);
  1581.              }
  1582.              break;
  1583.              
  1584.           case ID_CCOLORS:
  1585.              if (!VpeCloseDoc(Colors))
  1586.                 SetDlgItemText(hMainDlg, 110, "Can't close, task 'color test' is currently printing");
  1587.              break;
  1588.  
  1589.              
  1590.           case ID_REPORT:
  1591.              if (Report)
  1592.                 SetDlgItemText(hMainDlg, 110, "Report test is already running");
  1593.              else
  1594.              {
  1595.                 reporttest();
  1596.                 EnableWindow(GetDlgItem(hMainDlg, ID_CREPORT), TRUE);
  1597.              }
  1598.              break;
  1599.              
  1600.           case ID_CREPORT:
  1601.              if (!VpeCloseDoc(Report))
  1602.                 SetDlgItemText(hMainDlg, 110, "Can't close, task 'report test' is currently printing");
  1603.              break;
  1604.  
  1605.  
  1606.           case ID_AUTORENDER:
  1607.              if (Render)
  1608.                 SetDlgItemText(hMainDlg, 110, "Auto Rendering Demo is already running");
  1609.              else
  1610.              {
  1611.                 AutoRender();
  1612.                 EnableWindow(GetDlgItem(hMainDlg, ID_CRENDER), TRUE);
  1613.              }
  1614.              break;
  1615.              
  1616.           case ID_CRENDER:
  1617.              if (!VpeCloseDoc(Render))
  1618.                 SetDlgItemText(hMainDlg, 110, "Can't close, task 'Auto Render Demo' is currently printing");
  1619.              break;
  1620.  
  1621.  
  1622.           case IDOK:
  1623.           case IDCANCEL:
  1624.              if (SendMessage(hMainWindow, WM_CLOSE, 0, 0))
  1625.              {
  1626.                 EndDialog(hDlg, 0);
  1627.              }
  1628.              return TRUE;
  1629.        }
  1630.        break;
  1631.    }
  1632.    
  1633.    return FALSE;
  1634. }
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642. // ========================================================================
  1643. //                              WndProc
  1644. // ========================================================================
  1645. long FAR PASCAL _export WndProc(HWND hwnd, UINT message, UINT wParam, LONG lParam)
  1646. {
  1647.    static HANDLE  hInstance;
  1648.    static BOOL    no_close;        
  1649.    FARPROC lpfnDlgProc;
  1650.    
  1651.    switch (message)
  1652.    {
  1653.       case WM_CREATE:
  1654.          no_close = FALSE;
  1655.          hMainWindow = hwnd;
  1656.          hInstance = ((LPCREATESTRUCT) lParam)->hInstance;
  1657.          lpfnDlgProc = MakeProcInstance ((FARPROC) DlgSelectProc, hInstance);
  1658.          CreateDialog(hInstance, "DLG_TEST", hwnd, lpfnDlgProc);
  1659.          return 0;
  1660.  
  1661.  
  1662.       case VPE_DESTROYWINDOW:
  1663.          if (Precision == lParam)
  1664.          {
  1665.             Precision = 0;
  1666.             EnableWindow(GetDlgItem(hMainDlg, ID_CPRECISION), FALSE);
  1667.             EnableWindow(GetDlgItem(hMainDlg, ID_PAGE_LEFT), FALSE);
  1668.             EnableWindow(GetDlgItem(hMainDlg, ID_PAGE_RIGHT), FALSE);
  1669.          }
  1670.          else if (Speed == lParam)
  1671.          {
  1672.             Speed = 0;
  1673.             EnableWindow(GetDlgItem(hMainDlg, ID_CSPEED), FALSE);
  1674.          }
  1675.          else if (Colors == lParam)
  1676.          {
  1677.             Colors = 0;
  1678.             EnableWindow(GetDlgItem(hMainDlg, ID_CCOLORS), FALSE);
  1679.          }
  1680.          else if (Report == lParam)
  1681.          {
  1682.             Report = 0;
  1683.             EnableWindow(GetDlgItem(hMainDlg, ID_CREPORT), FALSE);
  1684.          }
  1685.          else if (Render == lParam)
  1686.          {
  1687.             Render = 0;
  1688.             EnableWindow(GetDlgItem(hMainDlg, ID_CRENDER), FALSE);
  1689.          }
  1690.          break;
  1691.  
  1692.                               
  1693.       case VPE_PRINT:
  1694.       case VPE_PRINTCANCEL:
  1695.          if (wParam)
  1696.          {
  1697.             no_close++;
  1698.          }
  1699.          else
  1700.          {
  1701.             no_close--;
  1702.             if (lParam == PBackGnd)
  1703.             {
  1704.                PBackGnd = 0;
  1705.                EnableWindow(GetDlgItem(hMainDlg, ID_PBACKGND), TRUE);
  1706.                if (message == VPE_PRINT)
  1707.                   SetDlgItemText(hMainDlg, 110, "Message: Background-Processing finished.");
  1708.                else
  1709.                   SetDlgItemText(hMainDlg, 110, "Message: Background-Processing aborted.");
  1710.             }
  1711.          }
  1712.          return 0;
  1713.  
  1714.  
  1715.       case VPE_HELP:
  1716.          MessageBox(hwnd, "User requested help!", "Note:", MB_OK);
  1717.          break;
  1718.  
  1719.       case WM_SIZE:
  1720.          if (Precision)   // this is an embedded window
  1721.          {
  1722.             MoveWindow(VpeWindowHandle(Precision), 0, 0, LOWORD(lParam), HIWORD(lParam), FALSE);
  1723.          }
  1724.          return 0;
  1725.  
  1726.  
  1727.       case WM_KEYDOWN:
  1728.          if (Precision)   // this is an embedded window
  1729.          {
  1730.             SendMessage(VpeWindowHandle(Precision), WM_KEYDOWN, wParam, lParam);
  1731.          }
  1732.          return 0;
  1733.  
  1734.  
  1735.       case WM_CLOSE:
  1736.          if (!no_close)      // can't close, because printing?
  1737.          {
  1738.             DestroyWindow(hwnd);
  1739.             return 1;
  1740.          }
  1741.          MessageBox(hwnd, "Can't close, job is printing!", "WARNING:", MB_OK);
  1742.          return 0;
  1743.                 
  1744.              
  1745.       case WM_DESTROY:
  1746.          PostQuitMessage(0);
  1747.          return 0;
  1748.    }
  1749.  
  1750.    return DefWindowProc (hwnd, message, wParam, lParam) ;
  1751. }
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761. // ========================================================================
  1762. //                              WinMain
  1763. // ========================================================================
  1764. int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance,
  1765.                     LPSTR , int nCmdShow)
  1766. {
  1767.    static char szAppName [] = "VPE";
  1768.    MSG         msg ;
  1769.    HWND        hwnd ;
  1770.    WNDCLASS    wndclass ;
  1771.  
  1772.    InitCtl3d(hInstance);
  1773.  
  1774.    if (!hPrevInstance)
  1775.    {
  1776.       wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
  1777.       wndclass.lpfnWndProc   = WndProc ;
  1778.       wndclass.cbClsExtra    = 0 ;
  1779.       wndclass.cbWndExtra    = 0 ;
  1780.       wndclass.hInstance     = hInstance ;
  1781.       wndclass.hIcon         = LoadIcon (hInstance, "APP_ICON");
  1782.       wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
  1783.       wndclass.hbrBackground = GetStockObject (WHITE_BRUSH) ;
  1784.       wndclass.lpszMenuName  = szAppName ;
  1785.       wndclass.lpszClassName = szAppName ;
  1786.       RegisterClass(&wndclass) ;
  1787.    }
  1788.  
  1789.    hwnd = CreateWindow(szAppName, szAppName,
  1790.                        WS_OVERLAPPEDWINDOW,
  1791.                        CW_USEDEFAULT, CW_USEDEFAULT,
  1792.                        CW_USEDEFAULT, CW_USEDEFAULT,
  1793.                        NULL, NULL, hInstance, NULL) ;
  1794.  
  1795.      
  1796.    ShowWindow (hwnd, nCmdShow) ;
  1797.    UpdateWindow (hwnd) ;
  1798.  
  1799.    while (GetMessage (&msg, NULL, 0, 0))
  1800.    {
  1801.            TranslateMessage (&msg) ;
  1802.            DispatchMessage (&msg) ;
  1803.    }
  1804.  
  1805.    UnInstallCtl3d(hInstance);
  1806.    return msg.wParam;
  1807. }
  1808.