home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / msj / msjv2_5 / maze / maze.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-02  |  3.7 KB  |  144 lines

  1. /*
  2.  
  3. Figure 15
  4. =========
  5.  
  6. */
  7.  
  8. /*
  9.  * DDE MAZE - HEADER FILE
  10.  *
  11.  * LANGUAGE : Microsoft C
  12.  * MODEL        : Small
  13.  * STATUS    : Operational
  14.  *
  15.  * 09/22/87 - Kevin P. Welch - initial creation.
  16.  *
  17.  */
  18.  
  19. #define MAZE_COLS            3
  20. #define MAZE_ROWS            5
  21.  
  22. #define SC_GRAB_BALL        0x0100
  23. #define SC_GRAB_FOCUS    0x0101
  24.  
  25. #define HI                HIWORD(lPrm)
  26. #define LO                LOWORD(lPrm)
  27.  
  28. #define RGB_BLACK            RGB(0x00,0x00,0x00)
  29. #define RGB_WHITE            RGB(0xFF,0xFF,0xFF)
  30.  
  31. /*
  32.  * BALL DATA STRUCTURE DEFINITIONS
  33.  *
  34.  */
  35.  
  36. #define BALL_WIDTH    6
  37. #define BALL_HEIGHT    6
  38.  
  39. #define RANDOM_MOTION    (((rand()%2)*2)-1)
  40.  
  41. #define H_BOUNCE(a,b)    ((a<=0)?1:((a>=b)?-1:Ball.iHorzMotion))
  42. #define V_BOUNCE(a,b)    ((a<=0)?1:((a>=b)?-1:Ball.iVertMotion))
  43.  
  44. #define ADVISE_OFF    (!Link[i].bAdviseBall)
  45.  
  46. #define OUTSIDE_LEFT    (Ball.rPosn.left<=Link[i].rHole.left)
  47. #define OUTSIDE_RIGHT    (Link[i].rHole.right<=Ball.rPosn.right)
  48. #define OUTSIDE_TOP    (Ball.rPosn.top<=Link[i].rHole.top)
  49. #define OUTSIDE_BOTTOM    (Link[i].rHole.bottom<=Ball.rPosn.bottom)
  50.  
  51. #define OUTSIDE_WIDTH    ((OUTSIDE_LEFT)||(OUTSIDE_RIGHT))
  52. #define OUTSIDE_HEIGHT    ((OUTSIDE_TOP)||(OUTSIDE_BOTTOM))
  53.  
  54. #define OUTSIDE_HOLE    ((ADVISE_OFF)||(OUTSIDE_WIDTH)||(OUTSIDE_HEIGHT))
  55.  
  56. typedef struct {
  57.     RECT        rPosn;        /* current ball position */
  58.     long        lTimeIn;    /* time ball entered maze */
  59.     int        iHorzMotion;    /* vertical ball motion offset */
  60.     int        iVertMotion;    /* horizontal ball motion offset */
  61.     BOOL        bIsBouncing;    /* ball bouncing flag */
  62. } BALL;
  63.  
  64. /*
  65.  * MAZE DATA STRUCTURE DEFINITIONS
  66.  *
  67.  */
  68.  
  69. #define DISPLAY_WIDTH            (Maze.wWidth+BALL_WIDTH)
  70. #define DISPLAY_HEIGHT            (Maze.wHeight+BALL_HEIGHT)
  71.  
  72. typedef struct {
  73.     WORD        wNum;        /* maze window number */
  74.     WORD        wLinks;        /* number of maze links */
  75.     WORD        wWidth;        /* width of maze client area */
  76.     WORD        wHeight;    /* height of maze client area */
  77.     BOOL        bInitiate;    /* in initiate flag */
  78.     BOOL        bGrabBall;    /* grab the ball flag */
  79.     BOOL        bGrabFocus;    /* grab the focus flag */
  80.     WORD        wGoingAway;    /* maze going away counter */
  81. } MAZE;
  82.  
  83.  
  84. /*
  85.  * COMMUNICATION LINK DATA STRUCTURE DEFINITIONS
  86.  *
  87.  */
  88.  
  89. #define MAX_LINK            32
  90.  
  91. #define HOLE_WIDTH            20
  92. #define HOLE_HEIGHT            14
  93.  
  94. typedef struct {
  95.     HWND        hWnd;        /* client window handle */
  96.     WORD        wNum;        /* client window number */
  97.     RECT        rHole;        /* client hole position */
  98.     BOOL        bAdviseBall;    /* advise client of ball flag */
  99.     BOOL        bAdviseStat;    /* advise client of stats flag */
  100. } LINK;
  101.  
  102.  
  103. /*
  104.  * DYNAMIC DATA EXCHANGE DEFINITIONS
  105.  *
  106.  */
  107.  
  108. #define ACCEPTED        0x8000
  109. #define REJECTED        0x0000
  110.  
  111. #define WM_DDE_INITIATE     0x03e0
  112. #define WM_DDE_TERMINATE    0x03e1
  113. #define WM_DDE_ADVISE         0x03e2
  114. #define WM_DDE_UNADVISE       0x03e3
  115. #define WM_DDE_ACK            0x03e4
  116. #define WM_DDE_DATA           0x03e5
  117. #define WM_DDE_REQUEST       0x03e6
  118. #define WM_DDE_POKE           0x03e7
  119. #define WM_DDE_EXECUTE        0x03e8
  120.  
  121. #define SEND(a,b,c)        SendMessage(a,b,hWnd,c)
  122. #define POST(a,b,c)        PostMessage(a,b,hWnd,c)
  123.  
  124. #define DDE_INITIATE(a,b,c)    SEND(a,WM_DDE_INITIATE,MAKELONG(b,c))
  125. #define DDE_TERMINATE(a)    POST(a,WM_DDE_TERMINATE,0L)
  126. #define DDE_ADVISE(a,b)        Advise(a,hWnd,b)
  127. #define DDE_UNADVISE(a,b)    POST(a,WM_DDE_UNADVISE,MAKELONG(0,b))
  128. #define DDE_ACK(a,b,c)        POST(a,WM_DDE_ACK,MAKELONG(b,c))
  129. #define DDE_DATA(a,b,c,d,e)    Transmit(a,hWnd,WM_DDE_DATA,b,c,d,e)
  130. #define DDE_POKE(a,b,c,d,e)    Transmit(a,hWnd,WM_DDE_POKE,b,c,d,e)
  131.  
  132. typedef struct {
  133.     WORD    fEmpty:12;    /* reserved for future use */
  134.     WORD    fResponse:1;    /* in response to request */
  135.     WORD    fRelease:1;    /* release data */
  136.     WORD    fNoData:1;    /* null data handle ok */
  137.     WORD    fAck:1;        /* Ack expected */
  138.     WORD    cfFormat;    /* clipboard data format */
  139.     BYTE    info[30];    /* data buffer */
  140. } DATA;
  141.  
  142. typedef DATA *        PDATA;
  143. typedef DATA FAR *    LPDATA;
  144.