home *** CD-ROM | disk | FTP | other *** search
/ Game Audio Programming / GameAudioProgramming.iso / Extras / Sensaura / SDK1.0 / data1.cab / Example_Files / ZoomFX / aboutbox.cpp next >
Encoding:
C/C++ Source or Header  |  2000-06-13  |  2.9 KB  |  98 lines

  1. /*
  2.     Company:            Sensaura Ltd
  3.     Copyright:          (C) 2000
  4.  
  5.     File Name:            aboutbox.cpp
  6.     File Description:    Source file for implementation of About Dialog box support
  7.     Author:                Adam Philp
  8.     Last Update:        04-JAN-00
  9.  
  10.     Target Compiler:    Microsoft Visual C++ Version 5.0
  11. */
  12.  
  13. ///////////////////////    Included files ////////////////////////////////////////////////////////////
  14.  
  15. #include <windows.h>
  16.  
  17. #include "aboutbox.h"                    // Function declarations
  18. #include "resource.h"                    // Menu item identifiers
  19. #include "debug.h"                        // Debugging support
  20.  
  21. /////////////////////// Local variables ///////////////////////////////////////////////////////////
  22.  
  23. HINSTANCE g_hAboutBoxInstance = NULL;    // Application instance handle for loading resources
  24.  
  25. /////////////////////// Local functions ///////////////////////////////////////////////////////////
  26.  
  27. /*
  28.     Function:        AboutBoxProc
  29.     Description:    Minimum dialog box procedure for modal or modeless About Box
  30.     Parameters:        hwnd - Handle of the dialog box
  31.                     uMsg - Message ID
  32.                     wParam - Message param
  33.     Return value:    FALSE if we processed the message, TRUE otherwise
  34. */
  35.  
  36. BOOL FAR PASCAL AboutBoxProc(HWND hwnd,    UINT uMsg, WPARAM wParam, LPARAM lParam)
  37. {
  38.     HWND hwndParent;
  39.     HWND hwndCtl;
  40.     char* str;
  41.  
  42.     switch(uMsg)
  43.     {
  44.     case WM_INITDIALOG:
  45.         hwndParent = GetParent(hwnd);
  46.         EnableWindow(hwndParent, FALSE);
  47.  
  48.         str = new char[255];
  49.         LoadString(g_hAboutBoxInstance, IDS_ABOUTBOXCAPTION, str, 255);
  50.         SetWindowText(hwnd, str);
  51.         LoadString(g_hAboutBoxInstance, IDS_ABOUTBOXTEXT, str, 255);
  52.         hwndCtl = GetDlgItem(hwnd, IDC_TEXT);
  53.         if(hwndCtl)
  54.             SetWindowText(hwndCtl, str);
  55.  
  56.         delete str;
  57.         return TRUE;
  58.  
  59.     case WM_COMMAND:
  60.         if(LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
  61.         {
  62.             hwndParent = GetParent(hwnd);
  63.             EnableWindow(hwndParent, TRUE);
  64.             DestroyWindow(hwnd);
  65.             g_hAboutBoxInstance = NULL;
  66.         }
  67.         return FALSE;
  68.  
  69.     default:
  70.         return FALSE;
  71.     }
  72. }
  73.  
  74. ///////////////////////    Global functions //////////////////////////////////////////////////////////
  75.  
  76. /*
  77.     Function:        AboutBox
  78.     Description:    Create and show the program's standard About Dialog box
  79.     Parameters:        hWndParent - handle of the parent window for the dialog box
  80.                     hInstance - application instance handle
  81.                     bDoModal - true to create a modal dialog box, false for a modeless one
  82.     Return value:    For a modal dialog box, the dialog box's return value.  For a modeless one, the
  83.                     value returned by ShowWindow()
  84. */
  85.  
  86. int AboutBox(HWND hWndParent, HINSTANCE hInstance, bool bDoModal)
  87. {
  88.     g_hAboutBoxInstance = hInstance;
  89.  
  90.     if(bDoModal)                        // Create and execute a modal dialog box
  91.         return DialogBox(hInstance, MAKEINTRESOURCE(IDD_ABOUT), hWndParent, 
  92.                         (DLGPROC)AboutBoxProc);
  93.     else                                // Create and display a modeless dialog box
  94.         return ShowWindow(CreateDialog(hInstance, MAKEINTRESOURCE(IDD_ABOUT), 
  95.                           hWndParent, (DLGPROC)AboutBoxProc), SW_SHOW);
  96. }
  97.  
  98.