home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / os2sdk / os2sdk12 / hanoi / hanoi.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-06  |  3.5 KB  |  89 lines

  1. /* This header file does all the necessary includes and defines all the
  2.    structures and constants needed for the hanoi program                 */
  3.  
  4. #define INCL_WIN
  5. #define INCL_WINHEAP
  6. #define INCL_WINDIALOGS
  7. #define INCL_GPIPRIMITIVES
  8. #define INCL_DOSPROCESS
  9. #define _MT
  10.  
  11. #include <os2.h>
  12. #include <dos.h>
  13. #include <stdio.h>
  14. #include <string.h>
  15. #include <process.h>
  16. #include <stdlib.h>
  17.  
  18. /* This structure is passed into the recursive Hanoi() procedure and contains
  19.    the current window handle as well as a flag indicating the current
  20.    processing status.  If the fContinueCalc flag becomes FALSE, that
  21.    indicates that the user has selected stop from the menu bar and that
  22.    the procedure should exit the recursive process and terminate. */
  23.  
  24. typedef struct
  25. {
  26.    HWND hwnd;
  27.    BOOL fContinueCalc;
  28. } CALCPARAM;
  29. typedef CALCPARAM FAR *PCALCPARAM;
  30.  
  31.  
  32. MRESULT EXPENTRY ClientWndProc  (HWND, USHORT, MPARAM, MPARAM);
  33. MRESULT EXPENTRY EntryFldDlgProc(HWND, USHORT, MPARAM, MPARAM);
  34. VOID _cdecl FAR CalcThread(PCALCPARAM);
  35. VOID DrawDisk(HPS,BYTE,BYTE,BYTE);
  36. VOID MoveDisk(HPS,BYTE,BYTE);
  37. VOID Hanoi(PCALCPARAM, BYTE, BYTE, BYTE, BYTE);
  38. VOID EnableMenuItem(HWND hwnd, SHORT sMenuItem, BOOL fEnable);
  39. VOID SetupTowers(VOID);
  40.  
  41.  
  42. #define STACKSIZE        8192
  43. #define MAXDISKCNT         16    /* Maximum # of disks allowable */
  44. #define BASEXOFFSET        10    /* X offset for platform base   */
  45. #define BASEYOFFSET        10    /* Y offset for platform base   */
  46. #define BASETHICK          10    /* Base thickness               */
  47. #define BASELEN           300    /* Base width                   */
  48. #define POSTOFFSET         62    /* First post offset from edge  */
  49. #define POSTSPACE         100    /* Distance between posts       */
  50. #define POSTWIDTH           5    /* Width of each post           */
  51. #define POSTHALF            2    /* 1/2 width for centering      */
  52. #define POSTEXTRAHT        25    /* Post height above top disk   */
  53. #define DISKTHICK           3    /* Thickness of each disk       */
  54. #define DISKSPACE         (DISKTHICK+1)     /* Thickness + space */
  55. #define MINDISKWIDTH       11    /* Width of the smallest disk   */
  56. #define MAXDISKWIDTH       91    /* Width of the thickest disk   */
  57. #define BOTDISKYPOS        (BASEYOFFSET+BASETHICK+DISKSPACE-DISKTHICK)
  58.  
  59. #define fDRAW               1    /* Indicate draw to DrawDisk()  */
  60. #define fERASE              0    /* Indicate erase               */
  61.  
  62. #define DEFAULTSIZE         5    /* Default number of disks      */
  63. #define MSGBUFSIZE         25    /* Space needed for sprintf msg */
  64.  
  65. /****** Resource IDs *****/
  66.  
  67.  
  68. #define ID_MAINMENU    1
  69. #define BMP_HANOI      1
  70. #define IDM_START      2
  71. #define IDM_STOP       3
  72. #define IDM_SET        4
  73. #define ID_SETCOUNT    5
  74. #define ID_ENTRYFLD    6
  75. #define UM_CALC_DONE   (WM_USER+0) /* Message posted when thread terminates */
  76.  
  77. /* Macro for drawing a rectangle.  Assumes hps and ptl structs are defined
  78.    in the calling module. */
  79.  
  80. #define DrawRect(x1,y1,x2,y2,color)  ptl.x = (LONG) (x1);             \
  81.                                      ptl.y = (LONG) (y1);             \
  82.                                      GpiSetCurrentPosition(hps,&ptl); \
  83.                                      ptl.x = (LONG) (x2);             \
  84.                                      ptl.y = (LONG) (y2);             \
  85.                                      GpiSetColor(hps,color);          \
  86.                                      GpiBox(hps,DRO_FILL,&ptl,0L,0L);
  87.  
  88. 
  89.