home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / except1.zip / WndProc.C < prev    next >
C/C++ Source or Header  |  1994-08-23  |  4KB  |  140 lines

  1. #pragma    title("Exception Example  --  Version 1.0  --  (WndProc.C)")
  2. #pragma    subtitle("   Module Purpose - Interface Definitions")
  3.  
  4. #define    INCL_WIN           /* Include OS/2 PM Windows Interface    */
  5.  
  6. #pragma    info(noext)
  7.  
  8. #include <os2.h>
  9.  
  10. #include "appdefs.h"
  11. #include "except.h"
  12. #include "heapmem.h"
  13.  
  14. /* This    module contains    routine    used to    process    the window procedure    */
  15. /* for the applicaiton.                            */
  16.  
  17. /* Filename:   WndProc.C                        */
  18.  
  19. /*  Version:   1.0                            */
  20. /*  Created:   1994-08-23                        */
  21. /*  Revised:   1994-08-23                        */
  22.  
  23. /* Routines:                                */
  24.  
  25.  
  26. /* Copyright ╕ 1994, 1995  Prominare Inc.  All Rights Reserved.        */
  27.  
  28. /* --------------------------------------------------------------------    */
  29.  
  30. static INTERNALADDRESSLIST aial[ ] = { { (PFNINTADD)ExceptionExampleWndProc, "ExceptionExampleWndProc"    },
  31.                        { NULL, NULL } };
  32.  
  33. INTERNALADDRESS    intaddWndProc =     { __FILE__, 0,    aial };
  34.  
  35. #pragma    subtitle("   Client Window - Client Window Procedure")
  36. #pragma    page( )
  37.  
  38. /* --- ExceptionExampleWndProc ------------------------- [ Public ] ---    */
  39. /*                                    */
  40. /*     This function is    used to    process    the messages sent to the    */
  41. /*     applications client window.                    */
  42. /*                                    */
  43. /*     Upon Entry:                            */
  44. /*                                    */
  45. /*     HWND   hWnd; = Window Handle                    */
  46. /*     ULONG  msg;  = PM Message                    */
  47. /*     MPARAM mp1;  = Message Parameter    1                */
  48. /*     MPARAM mp2;  = Message Parameter    2                */
  49. /*                                    */
  50. /*     Upon Exit:                            */
  51. /*                                    */
  52. /*     ExceptionExampleWndProc = Message Handling Result        */
  53. /*                                    */
  54. /* --------------------------------------------------------------------    */
  55.  
  56. MRESULT    EXPENTRY ExceptionExampleWndProc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  57.  
  58. {
  59. RECTL rcl;                /* Window Rectangle            */
  60. HPS   hPS;                /* Presentation Space Handle    */
  61.  
  62. switch ( msg )
  63.    {
  64.             /* Process key press from keyboard        */
  65.    case    WM_CHAR    :
  66.             /************************************************/
  67.             /* PDSKeyProc is used to allow controls    in    */
  68.             /* windows.  Do    not remove this    function if you    */
  69.             /* intend to include controls within the window.*/
  70.             /************************************************/
  71.  
  72.        return(PDSKeyProc(hWnd, msg, mp1, mp2));
  73.  
  74.             /* Process menu    and button selections        */
  75.    case    WM_COMMAND :
  76.        switch (    SHORT1FROMMP(mp1) )
  77.        {
  78.        case    IDM_DIALOGUE1EXCEPTION :
  79.            WinDlgBox(HWND_DESKTOP, hwndExceptFrame,    (PFNWP)DialogueException1DlgProc,
  80.              (HMODULE)NULL,    DLG_DIALOGUE1EXCEPTION,    NULL);
  81.            break;
  82.  
  83.        case    IDM_DIALOGUE2EXCEPTION :
  84.            WinDlgBox(HWND_DESKTOP, hwndExceptFrame,    (PFNWP)DialogueException2DlgProc,
  85.              (HMODULE)NULL,    DLG_DIALOGUE2EXCEPTION,    NULL);
  86.            break;
  87.        }
  88.        break;
  89.             /* Process control selections            */
  90.    case    WM_CONTROL :
  91.     switch ( SHORT2FROMMP(mp1) )
  92.         {
  93.         }
  94.     break;
  95.             /* Window being    created, perform window        */
  96.             /* initialization                */
  97.    case    WM_CREATE :
  98.        hHeap = HeapAlloc(8192UL, 8192UL);
  99.  
  100.             /************************************************/
  101.             /* PDSGetTemplate is used to allow controls in    */
  102.             /* windows.  Do    not remove this    function if you    */
  103.             /* intend to include controls within the window.*/
  104.             /************************************************/
  105.  
  106.     PDSGetTemplate(hWnd, WIN_EXCEPTIONEXAMPLE);
  107.     break;
  108.             /* Window being    destroyed, perform clean-up    */
  109.             /* operations                    */
  110.    case    WM_DESTROY :
  111.        HeapRelease(hHeap);
  112.        break;
  113.             /* Erase window    background            */
  114.  
  115.    case    WM_ERASEBACKGROUND :
  116.        WinQueryWindowRect(hWnd,    &rcl);
  117.        WinFillRect((HPS)LONGFROMMP(mp1), &rcl, SYSCLR_WINDOW);
  118.        break;
  119.             /* Perform menu    initialization            */
  120.    case    WM_INITMENU :
  121.        switch (    SHORT1FROMMP(mp1) )
  122.        {
  123.       case IDM_FILE    :
  124.            break;
  125.  
  126.        }
  127.        break;
  128.             /* Paint client    window                */
  129.    case    WM_PAINT :
  130.        WinFillRect(hPS = WinBeginPaint(hWnd, (HPS)NULL,    &rcl), &rcl, SYSCLR_WINDOW);
  131.        WinEndPaint(hPS);
  132.        break;
  133.  
  134.             /* Default message processing            */
  135.    default :
  136.        return(WinDefWindowProc(hWnd, msg, mp1, mp2));
  137.    }
  138. return(0L);
  139. }
  140.