home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / winbase / ipc / ddeml / clock / clock.h < prev    next >
Text File  |  1997-10-05  |  6KB  |  219 lines

  1.  
  2. /******************************************************************************\
  3. *       This is a part of the Microsoft Source Code Samples. 
  4. *       Copyright (C) 1993-1997 Microsoft Corporation.
  5. *       All rights reserved. 
  6. *       This source code is only intended as a supplement to 
  7. *       Microsoft Development Tools and/or WinHelp documentation.
  8. *       See these sources for detailed information regarding the 
  9. *       Microsoft samples programs.
  10. \******************************************************************************/
  11.  
  12.  
  13. /*--------------------------------------------------------------------------*/
  14. /*  Typedefs and Structures                                                 */
  15. /*--------------------------------------------------------------------------*/
  16.  
  17. /* Don't change without updating GETTIME.ASM. */
  18. typedef struct tagTIME
  19.   {
  20.     INT     hour;   /* 0 - 11 hours for analog clock */
  21.     INT     hour12; /* 12 hour format */
  22.     INT     hour24; /* 24 hour format */
  23.     INT     minute;
  24.     INT     second;
  25.     INT     ampm;   /* 0 - AM , 1 - PM */
  26.   } TIME;
  27.  
  28. typedef struct
  29. {
  30.     SHORT sin;
  31.     SHORT cos;
  32. } TRIG;
  33.  
  34. TRIG CirTab[] = {     // circle sin, cos, table
  35.     { 0,     -7999  },
  36.     { 836,   -7956  },
  37.     { 1663,  -7825  },
  38.     { 2472,  -7608  },
  39.     { 3253,  -7308  },
  40.     { 3999,  -6928  },
  41.     { 4702,  -6472  },
  42.     { 5353,  -5945  },
  43.     { 5945,  -5353  },
  44.     { 6472,  -4702  },
  45.     { 6928,  -4000  },
  46.     { 7308,  -3253  },
  47.     { 7608,  -2472  },
  48.     { 7825,  -1663  },
  49.     { 7956,  -836   },
  50.  
  51.     { 8000,  0      },
  52.     { 7956,  836    },
  53.     { 7825,  1663   },
  54.     { 7608,  2472   },
  55.     { 7308,  3253   },
  56.     { 6928,  4000   },
  57.     { 6472,  4702   },
  58.     { 5945,  5353   },
  59.     { 5353,  5945   },
  60.     { 4702,  6472   },
  61.     { 3999,  6928   },
  62.     { 3253,  7308   },
  63.     { 2472,  7608   },
  64.     { 1663,  7825   },
  65.     { 836,   7956   },
  66.  
  67.     { 0,     7999   },
  68.     { -836,  7956   },
  69.     { -1663, 7825   },
  70.     { -2472, 7608   },
  71.     { -3253, 7308   },
  72.     { -4000, 6928   },
  73.     { -4702, 6472   },
  74.     { -5353, 5945   },
  75.     { -5945, 5353   },
  76.     { -6472, 4702   },
  77.     { -6928, 3999   },
  78.     { -7308, 3253   },
  79.     { -7608, 2472   },
  80.     { -7825, 1663   },
  81.     { -7956, 836    },
  82.  
  83.     { -7999, -0     },
  84.     { -7956, -836   },
  85.     { -7825, -1663  },
  86.     { -7608, -2472  },
  87.     { -7308, -3253  },
  88.     { -6928, -4000  },
  89.     { -6472, -4702  },
  90.     { -5945, -5353  },
  91.     { -5353, -5945  },
  92.     { -4702, -6472  },
  93.     { -3999, -6928  },
  94.     { -3253, -7308  },
  95.     { -2472, -7608  },
  96.     { -1663, -7825  },
  97.     { -836 , -7956  }
  98. };
  99.  
  100. typedef struct tagCLOCKDISPSTRUCT
  101.   {
  102.     /* Clock display format for main window/icon outut */
  103.     /* either  IDM_ANALOG, or IDM_DIGITAL */
  104.     WORD    wFormat;
  105.  
  106.     /* Various boolean settings for the clock style
  107.      * and current settings */
  108.     BOOL bMinimized;
  109.     BOOL bMaximized;
  110.     BOOL bTopMost;
  111.     BOOL bNoTitle;
  112.     BOOL bTmpHide;
  113.     BOOL bIconic;
  114.     BOOL bColor;
  115.     BOOL bNewFont;
  116.  
  117.     /* X and Y offset within client area of window
  118.      * or icon where digital clock will be displayed */
  119.     POINT   line1;
  120.  
  121.     /* Y offset within icon area to second line where
  122.      * minute will be displayed */
  123.     INT     yline2;
  124.  
  125.     /* length of the digital clock readout string,
  126.      * required by the text out function.
  127.      * if the time format is 24 hour, this value is
  128.      * set so that the AM/PM indicator is not output */
  129.     WORD    wDigTimeLen;
  130.  
  131.     /* buffer to store digital time in.  the hour/minute/ampm
  132.      * sections of this buffer are only modified if they
  133.      * change from the previous call. */
  134.     CHAR    szDigTime[20];
  135.  
  136.     /* buffer to hold the win.ini international indicators
  137.      * for 1159, and 2359 AM/PM 12 hour time format.
  138.      * szAMPM[0] holds AM, szAMPM[1] holds PM indicator */
  139.     CHAR    szAMPM[2][7];
  140.  
  141.     /* intl time format (like DOS) 0 - 12 hour, 1 - 24 hour */
  142.     WORD    wTimeFormat;
  143.  
  144.     /* intl time seperator character */
  145.     CHAR    cTimeSep;
  146.   } CLOCKDISPSTRUCT;
  147.  
  148.  
  149. /*--------------------------------------------------------------------------*/
  150. /*  Function Templates                                                      */
  151. /*--------------------------------------------------------------------------*/
  152.  
  153. void NEAR GetTime(TIME *);
  154. void NEAR ConvTime(TIME *);
  155.  
  156. LONG APIENTRY ClockWndProc(HWND, UINT, WPARAM, LONG);
  157.  
  158.  
  159. /*--------------------------------------------------------------------------*/
  160. /*  Constants                                                               */
  161. /*--------------------------------------------------------------------------*/
  162.  
  163. #define IDD_ABOUT 400
  164.  
  165.     /* Main Menu ID defines */
  166.  
  167. #define IDM_ANALOG       1
  168. #define IDM_DIGITAL      2
  169. #define IDM_ABOUT        4
  170. //--------------
  171. #define IDM_TOPMOST      5
  172. #define IDM_NOTITLE      6
  173. //--------------
  174.  
  175.  
  176. /* Temp ID for dialogs. */
  177. #define ID_JUNK     0xCACC
  178.  
  179.     /* String Resource definitions */
  180.  
  181. #define IDS_APPNAME      1
  182. #define IDS_DATA         2
  183. #define IDS_TOOMANY      3
  184. #define IDS_FONTFILE     4
  185.  
  186. #define IDS_INTL        16
  187. #define IDS_ITIME       18
  188. #define IDS_S1159       19
  189. #define IDS_S2359       20
  190. #define IDS_STIME       22
  191. #define IDS_CLKFORMAT   23
  192.  
  193. #define IDS_1159        24
  194. #define IDS_2359        25
  195. #define IDS_TIMESEP             27
  196. #define IDS_USNAME      29
  197. #define IDS_INIFILE     30
  198. //--------------
  199. #define IDS_TOPMOST     31
  200. //--------------
  201.  
  202. #define HOURSCALE       65
  203. #define MINUTESCALE     80
  204. #define HHAND           TRUE
  205. #define MHAND           FALSE
  206. #define SECONDSCALE     80
  207. #define MAXBLOBWIDTH    25
  208. #define BUFLEN          30
  209. #define REPAINT         0
  210. #define HANDPAINT       1
  211.  
  212. #define UPDATE                  0
  213. #define REDRAW                  1
  214.  
  215. #define OPEN_TLEN               450
  216. #define ICON_TLEN               45000
  217.  
  218. #define CLKSCALE                ((INT)8000)
  219.