home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / mag&info / msjv7_5.zip / WINCPP.ARJ / CPP3.ARJ / GENERIC.CPP next >
C/C++ Source or Header  |  1992-09-01  |  2KB  |  66 lines

  1. // generic.cpp RHS 4/15/92
  2.  
  3. #include"WinApp.h"
  4. #include"generic.h"        // specific to this program
  5.  
  6. class myApp : public WinApp    // derive new class from WinApp
  7.     {
  8. public:
  9.     // override virtual functions
  10.     BOOL InitInstance(void);        
  11.     BOOL InitApplication(void);        
  12.     };
  13.  
  14. myApp theApp;                       // create an instance of myApp
  15.  
  16. BOOL myApp::InitApplication(void)
  17.     {
  18.     mainWnd = new Window();
  19.  
  20.     if(!mainWnd->RegisterClass(
  21.             NULL,
  22.             MainWndProc,
  23.             "GenericMenu",
  24.             "GenericWClass"))
  25.         return FALSE;
  26.     return TRUE;
  27.     }
  28.  
  29. BOOL myApp::InitInstance(void)
  30.     {
  31.     if(!mainWnd->CreateWindow(
  32.             "GenericWClass",            // classname
  33.             "Generic Sample Application (C++ 3)", // text
  34.             WS_OVERLAPPEDWINDOW))       // style
  35.         return FALSE;
  36.  
  37.     mainWnd->ShowWindow();              // Show the window                        
  38.     mainWnd->UpdateWindow();            // Sends WM_PAINT message                 
  39.     return TRUE;                        // Returns the value from PostQuitMessage 
  40.     }
  41.  
  42. long FAR PASCAL MainWndProc(HWND hWnd, UINT message, 
  43.     WPARAM wParam, LPARAM lParam)
  44.     {
  45.     switch (message) 
  46.         {
  47.         case WM_COMMAND:       // message: command from application menu 
  48.             if(wParam == IDM_ABOUT) 
  49.                 {
  50.                 About(hWnd,"AboutBox");
  51.                 break;
  52.                 }
  53.             else                // Lets Windows process it         
  54.                 return DefWindowProc(hWnd, message, wParam, lParam);
  55.  
  56.         case WM_DESTROY:          // message: window being destroyed 
  57.             PostQuitMessage(0);
  58.             break;
  59.  
  60.         default:              // Passes it on if unproccessed    
  61.             return DefWindowProc(hWnd, message, wParam, lParam);
  62.         }
  63.     return NULL;
  64.     }
  65.  
  66.