MAZE.C
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:4k
源码类别:

Windows编程

开发平台:

Visual C++

  1. /******************************************************************************
  2. *       This is a part of the Microsoft Source Code Samples. 
  3. *       Copyright (C) 1993-1997 Microsoft Corporation.
  4. *       All rights reserved. 
  5. *       This source code is only intended as a supplement to 
  6. *       Microsoft Development Tools and/or WinHelp documentation.
  7. *       See these sources for detailed information regarding the 
  8. *       Microsoft samples programs.
  9. ******************************************************************************/
  10. /*---------------------------------------------------------------------------*
  11. | MAZE MODULE
  12. *---------------------------------------------------------------------------*/
  13. #include <windows.h>
  14. #include "gdidemo.h"
  15. #include  "maze.h"
  16. /*---------------------------------------------------------------------------*
  17. | CREATE MAZE WINDOW PROCEDURE
  18. *---------------------------------------------------------------------------*/
  19. HWND FAR CreateMazeWindow(HWND hWndClient, int nItem)
  20. {
  21.     HANDLE          hInstance;
  22.     MDICREATESTRUCT mcs;
  23.     static char buffer[256];
  24.     hInstance = GETINSTANCE(hWndClient);
  25.     LoadString (hInstance, MAZETITLE, buffer, 256);
  26.     /*
  27.     ** Initialize the MDI create struct for creation of the
  28.     ** test window.
  29.     */
  30.     mcs.szClass = MAZECLASS;
  31.     mcs.szTitle = buffer;
  32.     mcs.hOwner  = hInstance;
  33.     mcs.x       = CW_USEDEFAULT;
  34.     mcs.y       = CW_USEDEFAULT;
  35.     mcs.cx      = CW_USEDEFAULT;
  36.     mcs.cy      = CW_USEDEFAULT;
  37.     mcs.style   = 0l;
  38.     mcs.lParam  = (LONG)nItem;
  39.     return((HWND)SendMessage(hWndClient,WM_MDICREATE,0,(LONG)(LPMDICREATESTRUCT)&mcs));
  40. }
  41. /*---------------------------------------------------------------------------*
  42. | MAZE WINDOW PROCEDURE
  43. *---------------------------------------------------------------------------*/
  44. LONG APIENTRY MazeProc(HWND hWnd, UINT wMsg, WPARAM wParam, LONG lParam)
  45. {
  46.     switch(wMsg)
  47.     {
  48.         case WM_CREATE:
  49.             MazeCreateProc(hWnd);
  50.             break;
  51.         case WM_COMMAND:
  52.             MazeCommandProc(hWnd,wParam,lParam);
  53.             break;
  54.         case WM_TIMER:
  55.             DrawMaze(hWnd);
  56.             break;
  57.         case WM_PAINT:
  58.             MazePaintProc(hWnd);
  59.             break;
  60.         case WM_DESTROY:
  61.             MazeDestroyProc(hWnd);
  62.             break;
  63.         default:
  64.             return(DefMDIChildProc(hWnd,wMsg,wParam,lParam));
  65.     }
  66.     return(0l);
  67. }
  68. /*---------------------------------------------------------------------------*
  69. | MAZE CREATE PROCEDURE
  70. *---------------------------------------------------------------------------*/
  71. BOOL MazeCreateProc(HWND hWnd)
  72. {
  73.     PMAZEDATA ppd;
  74.     if(AllocWindowInfo(hWnd,sizeof(MAZEDATA)))
  75.     {
  76.         if(ppd = (PMAZEDATA)LockWindowInfo(hWnd))
  77.         {
  78.             UnlockWindowInfo(hWnd);
  79.             return(TRUE);
  80.         }
  81.         FreeWindowInfo(hWnd);
  82.     }
  83.     return(FALSE);
  84. }
  85. /*---------------------------------------------------------------------------*
  86. | MAZE COMMAND PROCEDURE
  87. *---------------------------------------------------------------------------*/
  88. BOOL MazeCommandProc(HWND hWnd, WPARAM wParam, LONG lParam)
  89. {
  90.     hWnd   = hWnd;
  91.     wParam = wParam;
  92.     lParam = lParam;
  93.     return(TRUE);
  94. }
  95. /*---------------------------------------------------------------------------*
  96. | MAZE PAINT PROCEDURE
  97. *---------------------------------------------------------------------------*/
  98. VOID MazePaintProc(HWND hWnd)
  99. {
  100.     HDC         hDC;
  101.     PAINTSTRUCT ps;
  102.     if(hDC = BeginPaint(hWnd,&ps))
  103.         EndPaint(hWnd,&ps);
  104.     return;
  105. }
  106. /*---------------------------------------------------------------------------*
  107. | MAZE DESTROY PROCEDURE
  108. *---------------------------------------------------------------------------*/
  109. VOID MazeDestroyProc(HWND hWnd)
  110. {
  111.     KillTimer(hWnd,1);
  112.     FreeWindowInfo(hWnd);
  113.     return;
  114. }
  115. VOID DrawMaze(HWND hWnd)
  116. {
  117.     hWnd = hWnd;
  118.     return;
  119. }