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

  1. #pragma    title("Printer Driver  --  Version 1  --  (PrnWnd.C)")
  2. #pragma    subtitle("   Application Window - Interface Definitions")
  3.  
  4. #pragma    info(noext)
  5.  
  6. #define    INCL_WIN           /* Include OS/2 PM Windows Interface    */
  7.  
  8. #include <os2.h>
  9.  
  10. #include "appdefs.h"
  11. #include "prnsetup.h"
  12.  
  13. /* This    module contains    application window procedure.            */
  14.  
  15. /* Filename:   PrnWnd.C                            */
  16.  
  17. /*  Version:   1                            */
  18. /*  Created:   1995-02-09                        */
  19. /*  Revised:   1995-02-09                        */
  20.  
  21. /* Routines:   MRESULT EXPENTRY    PrintDriverWndProc(HWND    hWnd,        */
  22. /*                           ULONG msg,        */
  23. /*                           MPARAM mp1,        */
  24. /*                           MPARAM mp2);        */
  25.  
  26. /************************************************************************/
  27. /************************************************************************/
  28. /************************************************************************/
  29. /* DISCLAIMER OF WARRANTIES:                        */
  30. /* -------------------------                        */
  31. /* The following [enclosed] code is sample code    created    by IBM        */
  32. /* Corporation and Prominare Inc.  This    sample code is not part    of any    */
  33. /* standard IBM    product    and is provided    to you solely for the purpose    */
  34. /* of assisting    you in the development of your applications.  The code    */
  35. /* is provided "AS IS",    without    warranty of any    kind.  Neither IBM nor    */
  36. /* Prominare shall be liable for any damages arising out of your    */
  37. /* use of the sample code, even    if they    have been advised of the    */
  38. /* possibility of such damages.                        */
  39. /************************************************************************/
  40. /************************************************************************/
  41. /************************************************************************/
  42. /*               D I S C L A I M E R                */
  43. /* This    code is    provided on an as is basis with    no implied support.    */
  44. /* It should be    considered freeware that cannot    be rebundled as        */
  45. /* part    of a larger "*ware" offering without our consent.        */
  46. /************************************************************************/
  47. /************************************************************************/
  48. /************************************************************************/
  49.  
  50. /* Copyright ╕ International Business Machines Corp., 1995.        */
  51. /* Copyright ╕ 1995  Prominare Inc.  All Rights    Reserved.        */
  52.  
  53. /* --------------------------------------------------------------------    */
  54.  
  55. #pragma    subtitle("   Client Window - Client Window Procedure")
  56. #pragma    page( )
  57.  
  58. /* --- PrintDriverWndProc ------------------------------ [ Public ] ---    */
  59. /*                                    */
  60. /*     This function is    used to    process    the messages sent to the    */
  61. /*     applications client window.                    */
  62. /*                                    */
  63. /*     Upon Entry:                            */
  64. /*                                    */
  65. /*     HWND   hWnd; = Window Handle                    */
  66. /*     ULONG  msg;  = PM Message                    */
  67. /*     MPARAM mp1;  = Message Parameter    1                */
  68. /*     MPARAM mp2;  = Message Parameter    2                */
  69. /*                                    */
  70. /*     Upon Exit:                            */
  71. /*                                    */
  72. /*     PrintDriverWndProc = Message Handling Result            */
  73. /*                                    */
  74. /* --------------------------------------------------------------------    */
  75.  
  76. MRESULT    EXPENTRY PrintDriverWndProc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  77.  
  78. {
  79. RECTL rcl;                /* Window Rectangle            */
  80. HPS   hPS;                /* Presentation Space Handle    */
  81.  
  82.  
  83. switch ( msg )
  84.    {
  85.             /* Window being    created, perform window        */
  86.             /* initialization                */
  87.    case    WM_CREATE :
  88.             /************************************************/
  89.             /* PDSGetTemplate is used to allow controls in    */
  90.             /* windows.  Do    not remove this    function if you    */
  91.             /* intend to include controls within the window.*/
  92.             /************************************************/
  93.  
  94.     PDSGetTemplate(hWnd, WIN_PRINTDRIVER);
  95.     break;
  96.             /* Process key press from keyboard        */
  97.    case    WM_CHAR    :
  98.             /************************************************/
  99.             /* PDSKeyProc is used to allow controls    in    */
  100.             /* windows.  Do    not remove this    function if you    */
  101.             /* intend to include controls within the window.*/
  102.             /************************************************/
  103.  
  104.     return(PDSKeyProc(hWnd,    msg, mp1, mp2));
  105.             /* Process control selections            */
  106.             /* Process menu    and button selections        */
  107.    case    WM_COMMAND :
  108.     switch ( SHORT1FROMMP(mp1) )
  109.         {
  110.         case IDM_PRINTERSETUP :
  111.         WinDlgBox(HWND_DESKTOP,    hwndPrnSetupFrame, (PFNWP)PrnSetupDlgProc,
  112.               (HMODULE)NULL, DLG_PRNSETUP, (PVOID)&prn);
  113.         break;
  114.         }
  115.     break;
  116.             /* Erase window    background            */
  117.  
  118.    case    WM_ERASEBACKGROUND :
  119.     WinQueryWindowRect(hWnd, &rcl);
  120.     WinFillRect((HPS)LONGFROMMP(mp1), &rcl,    SYSCLR_WINDOW);
  121.     break;
  122.             /* Paint client    window                */
  123.    case    WM_PAINT :
  124.     hPS = WinBeginPaint(hWnd, (HPS)NULL, &rcl);
  125.     WinFillRect(hPS, &rcl, SYSCLR_WINDOW);
  126.     WinEndPaint(hPS);
  127.     break;
  128.             /* Window being    destroyed, perform clean-up    */
  129.             /* operations                    */
  130.    case    WM_DESTROY :
  131.     break;
  132.  
  133.             /* Default message processing            */
  134.    default :
  135.        return(WinDefWindowProc(hWnd, msg, mp1, mp2));
  136.    }
  137. return(0L);
  138. }
  139.