home *** CD-ROM | disk | FTP | other *** search
- /*
- Company: Sensaura Ltd
- Copyright: (C) 2000
-
- File Name: aboutbox.cpp
- File Description: Source file for implementation of About Dialog box support
- Author: Adam Philp
- Last Update: 04-JAN-00
-
- Target Compiler: Microsoft Visual C++ Version 5.0
- */
-
- /////////////////////// Included files ////////////////////////////////////////////////////////////
-
- #include <windows.h>
-
- #include "aboutbox.h" // Function declarations
- #include "resource.h" // Menu item identifiers
- #include "debug.h" // Debugging support
-
- /////////////////////// Local variables ///////////////////////////////////////////////////////////
-
- HINSTANCE g_hAboutBoxInstance = NULL; // Application instance handle for loading resources
-
- /////////////////////// Local functions ///////////////////////////////////////////////////////////
-
- /*
- Function: AboutBoxProc
- Description: Minimum dialog box procedure for modal or modeless About Box
- Parameters: hwnd - Handle of the dialog box
- uMsg - Message ID
- wParam - Message param
- Return value: FALSE if we processed the message, TRUE otherwise
- */
-
- BOOL FAR PASCAL AboutBoxProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- HWND hwndParent;
- HWND hwndCtl;
- char* str;
-
- switch(uMsg)
- {
- case WM_INITDIALOG:
- hwndParent = GetParent(hwnd);
- EnableWindow(hwndParent, FALSE);
-
- str = new char[255];
- LoadString(g_hAboutBoxInstance, IDS_ABOUTBOXCAPTION, str, 255);
- SetWindowText(hwnd, str);
- LoadString(g_hAboutBoxInstance, IDS_ABOUTBOXTEXT, str, 255);
- hwndCtl = GetDlgItem(hwnd, IDC_TEXT);
- if(hwndCtl)
- SetWindowText(hwndCtl, str);
-
- delete str;
- return TRUE;
-
- case WM_COMMAND:
- if(LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
- {
- hwndParent = GetParent(hwnd);
- EnableWindow(hwndParent, TRUE);
- DestroyWindow(hwnd);
- g_hAboutBoxInstance = NULL;
- }
- return FALSE;
-
- default:
- return FALSE;
- }
- }
-
- /////////////////////// Global functions //////////////////////////////////////////////////////////
-
- /*
- Function: AboutBox
- Description: Create and show the program's standard About Dialog box
- Parameters: hWndParent - handle of the parent window for the dialog box
- hInstance - application instance handle
- bDoModal - true to create a modal dialog box, false for a modeless one
- Return value: For a modal dialog box, the dialog box's return value. For a modeless one, the
- value returned by ShowWindow()
- */
-
- int AboutBox(HWND hWndParent, HINSTANCE hInstance, bool bDoModal)
- {
- g_hAboutBoxInstance = hInstance;
-
- if(bDoModal) // Create and execute a modal dialog box
- return DialogBox(hInstance, MAKEINTRESOURCE(IDD_ABOUT), hWndParent,
- (DLGPROC)AboutBoxProc);
- else // Create and display a modeless dialog box
- return ShowWindow(CreateDialog(hInstance, MAKEINTRESOURCE(IDD_ABOUT),
- hWndParent, (DLGPROC)AboutBoxProc), SW_SHOW);
- }
-
-