home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible / OpenGL_Superbible_Waite_Group_Press_1996.iso / book / chapt10 / tank / borland / centerwnd.c < prev    next >
C/C++ Source or Header  |  1996-07-04  |  2KB  |  74 lines

  1. // CenterWnd.c
  2. // This file contains the window procedure and code related to the
  3. // window in the upper center of the main window. This window just
  4. // displays movement instructions
  5.  
  6. #include <windows.h>    // Normal Windows stuff
  7. #include <gl\gl.h>        // OpenGL
  8. #include <gl\glu.h>        // OpenGL utility library
  9. #include "externs.h"    // Data shared between files
  10.  
  11.  
  12. ////////////////////////////////////////////////////////////
  13. ////////////////////////////////////////////////////////////
  14. // Window procedure, handles all messages for this window
  15. LRESULT CALLBACK WndProcCenter(HWND    hWnd,
  16.                             UINT    message,
  17.                             WPARAM  wParam,
  18.                             LPARAM  lParam)
  19.     {
  20.     switch (message)
  21.         {
  22.         // This window will hardly ever be updated, or even invalidated
  23.         case WM_PAINT:
  24.             {    
  25.             PAINTSTRUCT ps;
  26.             char cWorkspace[64];    // String workspace
  27.             RECT    rect;            // Dimensions of the window
  28.             int iCurrRow = 0;        // Text Row (in pixels)
  29.  
  30.             BeginPaint(hWnd,&ps);
  31.             
  32.             // Get the dimensions of the window
  33.             GetClientRect(hWnd, &rect);
  34.  
  35.             // Display the instructions title
  36.             strcpy(cWorkspace,"** INSTRUCTIONS **");
  37.             iCurrRow = DrawText(ps.hdc,cWorkspace,strlen(cWorkspace),&rect, DT_CENTER | DT_TOP);
  38.  
  39.             // Double space down
  40.             iCurrRow *=2;
  41.             rect.top = iCurrRow;
  42.             strcpy(cWorkspace,"<- Left Arrow to Turn Left");
  43.             iCurrRow += DrawText(ps.hdc,cWorkspace,strlen(cWorkspace),&rect, DT_CENTER | DT_TOP);
  44.  
  45.             rect.top = iCurrRow;
  46.             strcpy(cWorkspace,"-> Right Arrow to Turn Right");
  47.             iCurrRow += (DrawText(ps.hdc,cWorkspace,strlen(cWorkspace),&rect, DT_CENTER | DT_TOP)*2);
  48.  
  49.             // Up and down arrow instructions
  50.             rect.top = iCurrRow;
  51.             strcpy(cWorkspace,"/\\ Up Arrow to Move Forward");
  52.             iCurrRow += DrawText(ps.hdc,cWorkspace,strlen(cWorkspace),&rect, DT_CENTER | DT_TOP);
  53.  
  54.             rect.top = iCurrRow;
  55.             strcpy(cWorkspace,"\\/ Down Arrow to Move Back");
  56.             iCurrRow += DrawText(ps.hdc,cWorkspace,strlen(cWorkspace),&rect, DT_CENTER | DT_TOP);
  57.  
  58.             // Put at bottom of rectangle
  59.             strcpy(cWorkspace,"(c) Copyright, 1996 Waite Group Press");
  60.             DrawText(ps.hdc,cWorkspace,strlen(cWorkspace),&rect, DT_CENTER | DT_BOTTOM | DT_SINGLELINE);
  61.  
  62.             EndPaint(hWnd, &ps);
  63.             }
  64.             
  65.         default:   // Passes it on if unproccessed
  66.             return (DefWindowProc(hWnd, message, wParam, lParam));
  67.  
  68.         }
  69.  
  70.     return (0L);
  71.     }
  72.  
  73.  
  74.