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

  1. #define INCL_PM
  2. #include <os2.h>
  3.  
  4. #define USERDATASIZE 0L
  5.  
  6. #include "dayregst.h"
  7.  
  8. HAB    hanchor;
  9. HWND   hclient;
  10. HWND   hframe;
  11.  
  12. PFNWP pfentry;
  13. CHAR ClassName[] = "me";
  14. HWND hwndentry;
  15. HWND hMenu;
  16. WNDPARAMS wp;
  17. CHAR      buf[4];
  18.  
  19. MRESULT EXPENTRY WinProc ( HPS hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 )
  20.    {
  21.    switch ( msg )
  22.       {
  23.  
  24.       case WM_SIZE:
  25.          hwndentry = WinCreateWindow(hwnd,
  26.             "DAYFIELD",
  27.             "MONDAY",
  28.             WS_VISIBLE, 
  29.             20,20,
  30.             100,15,
  31.             hwnd,
  32.             HWND_TOP,
  33.             1,
  34.             NULL,
  35.             NULL);
  36.  
  37.          hwndentry = WinCreateWindow(hwnd,
  38.             "DAYFIELD",
  39.             "TUESDAY",
  40.             WS_VISIBLE | ES_MARGIN,
  41.             20,50,
  42.             100,15,
  43.             hwnd,
  44.             HWND_TOP,
  45.             1,
  46.             NULL,
  47.             NULL);
  48.          return TRUE;
  49.          break;
  50.  
  51.       case WM_ERASEBACKGROUND:
  52.          return TRUE;
  53.          break;
  54.  
  55.       case WM_BUTTON2DOWN:
  56.          wp.fsStatus = WPM_CCHTEXT | WPM_TEXT;
  57.          wp.cchText = sizeof(buf);
  58.          wp.pszText = buf;
  59.          WinSendMsg(hwndentry,
  60.                   WM_QUERYWINDOWPARAMS,
  61.                   (MPARAM) &wp,
  62.                   0);
  63.          WinMessageBox(HWND_DESKTOP,
  64.             hwnd,                      /* client-window handle  */
  65.             buf,                       /* body of the message   */
  66.             "entry text",              /* title of the message  */
  67.             0,                         /* message box id        */
  68.             MB_OK | MB_ICONHAND);      /* icon and button flags */
  69.          break;
  70.  
  71.       default:
  72.          return WinDefWindowProc ( hwnd, msg, mp1, mp2 );
  73.       }
  74.    return 0L;
  75.    }
  76.  
  77.  
  78. main()
  79.  
  80.    {
  81.    HMQ    hmqueue;
  82.    QMSG   msg;
  83.    ULONG  fs;
  84.  
  85.    hanchor = WinInitialize(NULL);
  86.    hmqueue = WinCreateMsgQueue ( hanchor, 0 );
  87.    WinRegisterClass (
  88.                  hanchor,
  89.                  ClassName,
  90.                  WinProc,
  91.                  0L,
  92.                  USERDATASIZE);
  93.  
  94.     // you must register the day field class
  95.     RegisterDayFieldClass ( hanchor );
  96.  
  97.     fs = FCF_TITLEBAR
  98.             | FCF_SIZEBORDER
  99.             | FCF_SYSMENU
  100.             | FCF_TASKLIST
  101.             | FCF_MINMAX
  102.             | FCF_SHELLPOSITION
  103.             ;
  104.  
  105.    hframe = WinCreateStdWindow (
  106.                  HWND_DESKTOP,
  107.                  WS_VISIBLE,
  108.                  &fs,
  109.                  ClassName,
  110.                  "",
  111.                  0L,
  112.                  NULL,
  113.                  0,
  114.                  &hclient);
  115.  
  116.    while ( WinGetMsg ( hanchor, &msg, NULL, 0, 0 ))
  117.          {
  118.          WinDispatchMsg ( hanchor, &msg );
  119.          }
  120.  
  121.    WinDestroyWindow ( hframe );
  122.    WinDestroyMsgQueue ( hmqueue );
  123.    WinTerminate ( hanchor );
  124.  
  125.    return 0;
  126.  
  127. }
  128.