home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / DAYFIELD.ZIP / DAYWINPR.C < prev    next >
C/C++ Source or Header  |  1989-07-28  |  4KB  |  137 lines

  1. /* ----------------------------------------------------------------------
  2. .context DayWinProc
  3. .category Day-Field-Windows
  4. MRESULT EXPENTRY DayWinProc ( HWND   hwnd,
  5.                               USHORT msg,
  6.                               MPARAM mp1,
  7.                               MPARAM mp2 );
  8.  
  9. Description:
  10.      This procedure is the Window Procedure for the Field class window.
  11.  
  12. Parameter     Description
  13. -------------------------------------------------------------------------
  14. hwnd          A handle (32 bit) for the window to which the message is
  15.               addressed.
  16.  
  17. msg           A USHORT identifying the type of message that is being
  18.               received.
  19.  
  20. mp1           Message type specific 32 bit value.
  21.  
  22. mp2           Message type specific 32 bit value.
  23.  
  24.  
  25.  
  26. Returns:  
  27.      a MRESULT: a 32 bit pointer to a void data type
  28.  
  29. Comments: 
  30.      The DayFIELD class is used to allow the user to enter PRIMARY or
  31. SECONDARY to
  32. an entry field.  All other values are not allowed or cause the focus to
  33. shift to other windows.  This is done by subclassing the default
  34. WC_ENTRYFIELD window class and only passing the allowed WM_CHAR msgs.
  35. All messages that are meant for the subclassed WC_ENTRYFIELD window are
  36. passed on to it.  All other messages are handled here.
  37.  
  38. References: 
  39.      Charles Petzolds Programming the OS/2 Presentation Manager.
  40.  
  41. See Also:  DayCreate, DaySubWinProc, WinSubclassWindow
  42. .ref DayCreate, DaySubWinProc, WinSubclassWindow
  43.  
  44. Development History: 
  45.   Date         Programmer          Description of modification   
  46.   07/11/1989   Paul Montgomery     Initial development           
  47. -------------------------------------------------------------------- */
  48.  
  49. #define INCL_PM
  50. #define INCL_DOSMODULEMGR
  51. #include <os2.h>
  52.  
  53. #include "day.h"
  54. #include "daycrate.h"
  55.  
  56. MRESULT EXPENTRY DayWinProc ( HPS hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 )
  57.    {              
  58.    PDAYINFO   pdayi;
  59.    PSWP       pswp;
  60.    HPS        hps;
  61.  
  62.    pdayi = (PDAYINFO)WinQueryWindowULong(hwnd, PDAYI_OFFSET);
  63.    switch ( msg )
  64.       {
  65.       case WM_PAINT:
  66.          WinSetWindowPos(pdayi->hwndEntry, HWND_TOP,
  67.             pdayi->xoffset,
  68.             pdayi->yoffset,
  69.             0,
  70.             0,
  71.             SWP_ACTIVATE | SWP_MOVE | SWP_SHOW); /* flags  */
  72.          hps = WinBeginPaint(hwnd, NULL, NULL);
  73.          WinEndPaint(hps);
  74.          return 0;
  75.          break;
  76.  
  77.       case WM_CREATE:
  78.          return DayCreate(hwnd, mp1, mp2);
  79.          break;
  80.  
  81.       case EM_CLEAR:
  82.       case EM_CUT:
  83.       case EM_COPY:
  84.       case EM_PASTE:
  85.       case EM_QUERYCHANGED:
  86.       case EM_QUERYFIRSTCHAR:
  87.       case EM_QUERYSEL:
  88.       case EM_SETFIRSTCHAR:
  89.       case EM_SETSEL:
  90.       case EM_SETTEXTLIMIT:
  91.       case WM_ACTIVATE:
  92.       case WM_BUTTON1DOWN:
  93.       case WM_BUTTON2DOWN:
  94.       case WM_BUTTON3DOWN:
  95.       case WM_BUTTON1DBLCLK:
  96.       case WM_BUTTON1UP:
  97.       case WM_SETFOCUS:
  98.       case WM_FOCUSCHANGE:
  99.       case WM_HITTEST:
  100.       case WM_QUERYWINDOWPARAMS:
  101.       case WM_SETWINDOWPARAMS:
  102.       case WM_SETSELECTION:
  103.       case WM_TIMER:
  104.       case WM_ENABLE:
  105.       case WM_MOUSEMOVE:
  106.       case WM_CHAR:
  107.       case WM_QUERYDLGCODE:
  108.          return WinSendMsg(pdayi->hwndEntry, msg, mp1, mp2);
  109.          break;
  110.  
  111.       case WM_ADJUSTWINDOWPOS:
  112.          pswp = (PSWP)mp1;
  113.          pswp->x -= pdayi->xoffset;
  114.          pswp->y -= pdayi->yoffset;
  115.          pswp->cx += pdayi->xoffset * 2;
  116.          pswp->cy += pdayi->yoffset * 2;
  117.          return TRUE;
  118.          break;
  119.  
  120.       case WM_CONTROL:
  121.          return WinSendMsg(WinQueryWindow(hwnd, QW_PARENT,FALSE),
  122.                            msg, mp1, mp2);
  123.          break;
  124.  
  125.       case WM_DESTROY:
  126.          DosFreeModule(WinQueryWindowULong(hwnd, DAYHMOD_OFFSET));
  127.          DosFreeSeg(SELECTOROF(pdayi));
  128.          return 0;
  129.          break;
  130.  
  131.       default:
  132.          return WinDefWindowProc ( hwnd, msg, mp1, mp2 );
  133.       }
  134.    return 0L;
  135.    }
  136.  
  137.