home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / clndrlib.zip / caldemo.cpp < prev    next >
C/C++ Source or Header  |  1997-08-11  |  1KB  |  61 lines

  1. #define INCL_WIN
  2. #include <os2.h>
  3. #include <string.h>
  4. #include <stdio.h>
  5. #include "calendar.h"
  6. #include "calres.h"
  7.  
  8. extern "C" {
  9. MRESULT EXPENTRY DlgWndProc(HWND hwnd, ULONG ulMsg, MPARAM mp1, MPARAM mp2);
  10. }
  11.  
  12. int main(void)
  13. {
  14.     HAB    hab;
  15.     HMQ    hmq;
  16.     
  17.     hab = WinInitialize(0);
  18.     hmq = WinCreateMsgQueue(hab, 0);
  19.  
  20.     WinDlgBox(HWND_DESKTOP,HWND_DESKTOP,DlgWndProc, NULLHANDLE,
  21.                 DLG_DEMO, NULL );
  22.     
  23.     WinDestroyMsgQueue(hmq);
  24.     WinTerminate(hab);
  25.     return(0);
  26. }
  27.  
  28.  
  29.  
  30. MRESULT EXPENTRY DlgWndProc(HWND hwnd, ULONG ulMsg, MPARAM mp1, MPARAM mp2)
  31. {
  32.     char    tmp[60];
  33.     
  34.     switch(ulMsg)
  35.     {
  36.         case WM_COMMAND:
  37.         if(SHORT1FROMMP(mp1) == BTN_CALENDAR)
  38.         {
  39.          Date d;
  40.             Calendar *cal;
  41.             
  42.             //Stop multipule instance
  43.             WinEnableControl(hwnd, BTN_CALENDAR, FALSE);
  44.  
  45.             cal = new Calendar;
  46.             cal->show();
  47.             cal->getDate(&d);
  48.             sprintf(tmp, "%s, %i %s %i", d.dow, d.day, d.mnth, d.year);
  49.             WinSetWindowText(WinWindowFromID(hwnd, EF_DATE), tmp);
  50.             delete cal;
  51.             WinEnableControl(hwnd, BTN_CALENDAR, TRUE);
  52.             // keep dialog alive
  53.             return MRFROMSHORT(TRUE);
  54.         }
  55.         default:
  56.          
  57.         return WinDefDlgProc(hwnd, ulMsg, mp1, mp2);
  58.     }
  59. }
  60.  
  61.