home *** CD-ROM | disk | FTP | other *** search
/ Total Destruction / Total_Destruction.iso / addons / Lccwin32.exe / Lccwin32 / lccpub / demo / simple / SIMPLE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-12-28  |  1.9 KB  |  73 lines

  1. #include <windows.h>            // required for all Windows applications
  2. #include <windowsx.h>
  3. #include "globals.h"            // prototypes specific to this application
  4. #include "resource.h"
  5.  
  6. //
  7. //  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
  8. //
  9. //  PURPOSE:  Processes messages
  10. //
  11. //  PARAMETERS:
  12. //    hwnd     - window handle
  13. //    uMessage - message number
  14. //    wparam   - additional information (dependant of message number)
  15. //    lparam   - additional information (dependant of message number)
  16. //
  17. //  MESSAGES:
  18. //
  19. //    WM_COMMAND    - exit command
  20. //    WM_DESTROY    - destroy window
  21. //
  22. //  RETURN VALUE:
  23. //
  24. //    Depends on the message number.
  25. //
  26. //  COMMENTS:
  27. //
  28. //
  29.  
  30. LRESULT CALLBACK WndProc(HWND hwnd,
  31.                          UINT uMessage,
  32.                          WPARAM wparam,
  33.                          LPARAM lparam)
  34. {
  35.     switch (uMessage)
  36.     {
  37.  
  38.         //
  39.         // **TODO** Add cases here for application messages
  40.         //
  41.  
  42.         case WM_COMMAND: // message: command from application menu
  43.  
  44.             // Message packing of wparam and lparam have changed for Win32,
  45.             // so use the GET_WM_COMMAND macro to unpack the commnad
  46.  
  47.             switch (GET_WM_COMMAND_ID(wparam,lparam))
  48.             {
  49.  
  50.                 //
  51.                 // **TODO** Add cases here for application specific commands
  52.                 //
  53.  
  54.                 case IDM_EXIT:
  55.                     DestroyWindow(hwnd);
  56.                     break;
  57.  
  58.  
  59.                 default:
  60.                     return DefWindowProc(hwnd, uMessage, wparam, lparam);
  61.             }
  62.             break;
  63.  
  64.         case WM_DESTROY:  // message: window being destroyed
  65.             PostQuitMessage(0);
  66.             break;
  67.  
  68.         default:          // Passes it on if unproccessed
  69.             return DefWindowProc(hwnd, uMessage, wparam, lparam);
  70.     }
  71.     return 0;
  72. }
  73.