home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / graphics / gdi / gdidemo / maze.c < prev    next >
C/C++ Source or Header  |  1997-10-05  |  4KB  |  156 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. | MAZE MODULE
  14. \*---------------------------------------------------------------------------*/
  15.  
  16. #include <windows.h>
  17. #include "gdidemo.h"
  18. #include  "maze.h"
  19.  
  20. /*---------------------------------------------------------------------------*\
  21. | CREATE MAZE WINDOW PROCEDURE
  22. \*---------------------------------------------------------------------------*/
  23. HWND FAR CreateMazeWindow(HWND hWndClient, int nItem)
  24. {
  25.     HANDLE          hInstance;
  26.     MDICREATESTRUCT mcs;
  27.     static char buffer[256];
  28.  
  29.  
  30.     hInstance = GETINSTANCE(hWndClient);
  31.     LoadString (hInstance, MAZETITLE, buffer, 256);
  32.  
  33.     /*
  34.     ** Initialize the MDI create struct for creation of the
  35.     ** test window.
  36.     */
  37.     mcs.szClass = MAZECLASS;
  38.     mcs.szTitle = buffer;
  39.     mcs.hOwner  = hInstance;
  40.     mcs.x       = CW_USEDEFAULT;
  41.     mcs.y       = CW_USEDEFAULT;
  42.     mcs.cx      = CW_USEDEFAULT;
  43.     mcs.cy      = CW_USEDEFAULT;
  44.     mcs.style   = 0l;
  45.     mcs.lParam  = (LONG)nItem;
  46.  
  47.     return((HWND)SendMessage(hWndClient,WM_MDICREATE,0,(LONG)(LPMDICREATESTRUCT)&mcs));
  48. }
  49.  
  50.  
  51. /*---------------------------------------------------------------------------*\
  52. | MAZE WINDOW PROCEDURE
  53. \*---------------------------------------------------------------------------*/
  54. LONG APIENTRY MazeProc(HWND hWnd, UINT wMsg, WPARAM wParam, LONG lParam)
  55. {
  56.     switch(wMsg)
  57.     {
  58.         case WM_CREATE:
  59.             MazeCreateProc(hWnd);
  60.             break;
  61.  
  62.  
  63.         case WM_COMMAND:
  64.             MazeCommandProc(hWnd,wParam,lParam);
  65.             break;
  66.  
  67.         case WM_TIMER:
  68.             DrawMaze(hWnd);
  69.             break;
  70.  
  71.  
  72.         case WM_PAINT:
  73.             MazePaintProc(hWnd);
  74.             break;
  75.  
  76.  
  77.         case WM_DESTROY:
  78.             MazeDestroyProc(hWnd);
  79.             break;
  80.  
  81.  
  82.         default:
  83.             return(DefMDIChildProc(hWnd,wMsg,wParam,lParam));
  84.     }
  85.     return(0l);
  86. }
  87.  
  88.  
  89. /*---------------------------------------------------------------------------*\
  90. | MAZE CREATE PROCEDURE
  91. \*---------------------------------------------------------------------------*/
  92. BOOL MazeCreateProc(HWND hWnd)
  93. {
  94.     PMAZEDATA ppd;
  95.  
  96.  
  97.     if(AllocWindowInfo(hWnd,sizeof(MAZEDATA)))
  98.     {
  99.         if(ppd = (PMAZEDATA)LockWindowInfo(hWnd))
  100.         {
  101.             UnlockWindowInfo(hWnd);
  102.             return(TRUE);
  103.         }
  104.         FreeWindowInfo(hWnd);
  105.     }
  106.     return(FALSE);
  107. }
  108.  
  109.  
  110. /*---------------------------------------------------------------------------*\
  111. | MAZE COMMAND PROCEDURE
  112. \*---------------------------------------------------------------------------*/
  113. BOOL MazeCommandProc(HWND hWnd, WPARAM wParam, LONG lParam)
  114. {
  115.     hWnd   = hWnd;
  116.     wParam = wParam;
  117.     lParam = lParam;
  118.  
  119.     return(TRUE);
  120. }
  121.  
  122.  
  123. /*---------------------------------------------------------------------------*\
  124. | MAZE PAINT PROCEDURE
  125. \*---------------------------------------------------------------------------*/
  126. VOID MazePaintProc(HWND hWnd)
  127. {
  128.     HDC         hDC;
  129.     PAINTSTRUCT ps;
  130.  
  131.  
  132.     if(hDC = BeginPaint(hWnd,&ps))
  133.         EndPaint(hWnd,&ps);
  134.  
  135.     return;
  136. }
  137.  
  138.  
  139. /*---------------------------------------------------------------------------*\
  140. | MAZE DESTROY PROCEDURE
  141. \*---------------------------------------------------------------------------*/
  142. VOID MazeDestroyProc(HWND hWnd)
  143. {
  144.     KillTimer(hWnd,1);
  145.     FreeWindowInfo(hWnd);
  146.     return;
  147. }
  148.  
  149.  
  150. VOID DrawMaze(HWND hWnd)
  151. {
  152.     hWnd = hWnd;
  153.  
  154.     return;
  155. }
  156.