home *** CD-ROM | disk | FTP | other *** search
/ Hot Shareware 35 / hot35.iso / ficheros / 9TOOL / CALEN32A.ZIP / EXAMPLE.C < prev    next >
C/C++ Source or Header  |  1998-01-27  |  2KB  |  79 lines

  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <io.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include "calendar.h"
  7. #include "example.h"
  8.  
  9. #if defined(WIN32)
  10. #define _Export                 __declspec(dllexport)
  11. #else
  12. #define _Export                 _export
  13. #endif
  14.  
  15. int PASCAL WinMain(HINSTANCE, HINSTANCE, LPSTR, int);
  16. BOOL _Export CALLBACK ExampleDlgProc(HWND, unsigned, WPARAM, LPARAM);
  17.  
  18. int PASCAL WinMain(
  19.     HINSTANCE  hInst,          // current instance
  20.     HINSTANCE  hPrev,          // previous instance
  21.     LPSTR   lpszCmdLine,       // command line
  22.     int     iCmdShow )         // display mode
  23. {
  24.     FARPROC  fpfn;
  25.  
  26.     fpfn = MakeProcInstance((FARPROC)ExampleDlgProc, (HINSTANCE) hInst);
  27.     DialogBox((HINSTANCE) hInst, MAKEINTRESOURCE(EXAMPLEBOX), NULL, (DLGPROC)fpfn);
  28.     FreeProcInstance(fpfn);
  29.  
  30.     return TRUE;
  31. }
  32.  
  33.  
  34. BOOL FAR PASCAL ExampleDlgProc(HWND hDlg, unsigned wMsg, WPARAM wParam, LPARAM lParam)
  35. {
  36.     static CALENDAR Info;
  37.     char Date[9];
  38.  
  39.     switch (wMsg)
  40.     {
  41.         case WM_INITDIALOG:
  42.             // Calendar initialization
  43.             calInit("EVALUATE");
  44.             // Calendar customization
  45.             calGetParams(&Info);
  46.             Info.DayColor = RGB(0,0,255);
  47.             Info.SelectedDayColor = RGB(255,0,0);
  48.             Info.SelectedBkgColor = RGB(0, 128, 255);
  49.             Info.FirstDayOfWeek = MONDAY;
  50.             Info.xPos = GetSystemMetrics(SM_CXSCREEN)/4;
  51.             Info.yPos = GetSystemMetrics(SM_CYSCREEN)/4;
  52.             strcpy(Info.FontName, "Times New Roman");
  53.             calSetParams(&Info);
  54.  
  55.             return TRUE;
  56.  
  57.         case WM_COMMAND:
  58.             switch (wParam)
  59.             {
  60.                 case IDOK:
  61.                     if(Calendar(hDlg, Date, NULL))
  62.                         SetDlgItemText(hDlg, IDT_REPORT, Date);
  63.                     else
  64.                         SetDlgItemText(hDlg, IDT_REPORT, "No selection");
  65.                     break;
  66.  
  67.                 case IDCANCEL:
  68.                     EndDialog(hDlg, FALSE);
  69.                     break;
  70.  
  71.                 case IDP_DEFAULT:
  72.                     calSetDefaults();
  73.                     break;
  74.             }
  75.             break;
  76.     }
  77.     return FALSE;
  78. }
  79.