home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / prnt1.zip / PrnSetup.C < prev    next >
C/C++ Source or Header  |  1995-03-01  |  5KB  |  146 lines

  1. #pragma    title("Printer Driver  --  Version 1  --  (PrnSetup.C)")
  2. #pragma    subtitle("   main Entry Poiint - Interface Definitions")
  3.  
  4. #pragma    info(noext, nopar)
  5.  
  6. #define    INCL_DOS           /* Include OS/2 DOS Kernal        */
  7. #define    INCL_WIN           /* Include OS/2 PM Windows Interface    */
  8.  
  9. #include <os2.h>
  10.  
  11. #include "appdefs.h"
  12. #include "prnsetup.h"
  13.  
  14. /* This    module contains    main function for the Print Driver application.    */
  15.  
  16. /* The executable is created using the following options:        */
  17. /*                                    */
  18. /* Option           Value                        */
  19. /* ------           -----                        */
  20. /* Op Sys           OS/2 PM Executable                */
  21. /* Optimization           Maximize                        */
  22. /* Compile Type           Subsystem                    */
  23. /* CPU               80486                        */
  24. /* Warning Level       3                        */
  25. /*                                    */
  26. /* Equivalent command line invocation:                    */
  27. /*                                    */
  28. /*  Icc    -C -G4 -O+ -Rn -W3 PrnSetup.C          IBM C    Set++        */
  29. /*  BCC    -Ox -v-    -w -c PrnSetup.C          Borland C++ for OS/2    */
  30. /*  Wcl386 -c -ms -4s -s -ox -zp4 -w3 PrnSetup.C  WATCOM C/C++        */
  31.  
  32. /* Filename:   PrnSetup.C                        */
  33.  
  34. /*  Version:   1                            */
  35. /*  Created:   1995-02-09                        */
  36. /*  Revised:   1995-02-09                        */
  37.  
  38. /* Routines:   int main( );                        */
  39.  
  40. /************************************************************************/
  41. /************************************************************************/
  42. /************************************************************************/
  43. /* DISCLAIMER OF WARRANTIES:                        */
  44. /* -------------------------                        */
  45. /* The following [enclosed] code is sample code    created    by IBM        */
  46. /* Corporation and Prominare Inc.  This    sample code is not part    of any    */
  47. /* standard IBM    product    and is provided    to you solely for the purpose    */
  48. /* of assisting    you in the development of your applications.  The code    */
  49. /* is provided "AS IS",    without    warranty of any    kind.  Neither IBM nor    */
  50. /* Prominare shall be liable for any damages arising out of your    */
  51. /* use of the sample code, even    if they    have been advised of the    */
  52. /* possibility of such damages.                        */
  53. /************************************************************************/
  54. /************************************************************************/
  55. /************************************************************************/
  56. /*               D I S C L A I M E R                */
  57. /* This    code is    provided on an as is basis with    no implied support.    */
  58. /* It should be    considered freeware that cannot    be rebundled as        */
  59. /* part    of a larger "*ware" offering without our consent.        */
  60. /************************************************************************/
  61. /************************************************************************/
  62. /************************************************************************/
  63.  
  64. /* Copyright ╕ International Business Machines Corp., 1995.        */
  65. /* Copyright ╕ 1995  Prominare Inc.  All Rights    Reserved.        */
  66.  
  67. /* --------------------------------------------------------------------    */
  68.  
  69. PSZ pszPrnSetupClassName = (PSZ)"PrnSetup";
  70.  
  71.  
  72. INT main(INT argc, CHAR    *argv[ ])
  73.  
  74. {
  75. QMSG  qmsg;               /* PM Message Queue Holder        */
  76.  
  77.                /* Initialize the program for PM    and create the    */
  78.                /* message queue                    */
  79. hAB = WinInitialize(0UL);
  80. hmqPrnSetup = WinCreateMsgQueue(hAB, 0L);
  81.  
  82.  
  83.                /* Register the window class            */
  84.  
  85. if ( !WinRegisterClass(hAB, pszPrnSetupClassName, (PFNWP)PrintDriverWndProc,
  86.                CS_SYNCPAINT | CS_SIZEREDRAW, 0UL) )
  87.    return(0);
  88.                /* Create the main program window        */
  89.  
  90. if ( !(hwndPrnSetupFrame = CreateStdWindow(HWND_DESKTOP, WS_VISIBLE,
  91.                        FCF_NOBYTEALIGN | FCF_TASKLIST |
  92.                        FCF_TITLEBAR    | FCF_ICON |
  93.                        FCF_SYSMENU | FCF_MENU | FCF_MINMAX |
  94.                        FCF_SIZEBORDER,
  95.                        pszPrnSetupClassName, (PSZ)"Print Driver", 0L,
  96.                        (HMODULE)NULL, WIN_PRINTDRIVER, &hwndPrnSetup, 16, 147, 203,    97)) )
  97.    return(0);
  98.  
  99.  
  100. InitApp(hwndPrnSetupFrame, hwndPrnSetup, "Printer Setup Driver");
  101.  
  102.                /* Create Help instance and associate it    with    */
  103.                /* the programs frame window            */
  104.  
  105. if ( (hwndHelp = WinCreateHelpInstance(hAB, &helpinit))    != (HWND)NULL )
  106.    WinAssociateHelpInstance(hwndHelp, hwndPrnSetupFrame);
  107.  
  108.                /* Get default printer to use            */
  109.  
  110. if ( PrnCreatePrinterList(&prn)    )
  111.    prn.hAB = hAB;
  112.                /* Get and dispatch the message to program    */
  113.                /* windows                    */
  114.  
  115. while (    WinGetMsg(hAB, &qmsg, (HWND)NULL, 0UL, 0UL) )
  116.    WinDispatchMsg(hAB, &qmsg);
  117.  
  118.                /* Destroy the printer list            */
  119. if ( prn.hAB !=    0UL )
  120.    PrnDestroyPrinterList(&prn);
  121.  
  122.                /* Destroy the Help instance associated with the    */
  123.                /* the programs frame window            */
  124.  
  125. if ( hwndHelp )
  126.    {
  127.    WinAssociateHelpInstance((HWND)NULL,    hwndPrnSetupFrame);
  128.    WinDestroyHelpInstance(hwndHelp);
  129.    }
  130.  
  131.  
  132.                /* Have received    a WM_QUIT, start the program    */
  133.                /* shutdown by destroying the program windows    */
  134.                /* and destroying the message queue        */
  135.  
  136. WinDestroyWindow(hwndPrnSetupFrame);
  137.  
  138. WinDestroyMsgQueue(hmqPrnSetup);
  139.  
  140.                /* Notify PM that main program thread not needed    */
  141.                /* any longer                    */
  142. WinTerminate(hAB);
  143.                /* Exit back to OS/2 cleanly            */
  144. return(0);
  145. }
  146.