home *** CD-ROM | disk | FTP | other *** search
- /////////////////////////////////////////////////////////////////////////////
- //
- // about.cpp - CAboutBox dialog
- //
- /////////////////////////////////////////////////////////////////////////////
- //
- // (C) Copyright Black Diamond Consulting, Inc 1996. All rights reserved.
- //
- // You have a royalty-free right to use, modify, reproduce and
- // distribute the Sample Files (and/or any modified version) in
- // any way you find useful, provided that you agree that Black
- // Diamond Consulting has no warranty obligations or liability
- // for any Sample Application Files which are modified.
- //
- // Revision History:
- // 6/22/95 - Initial version - DAS
- //
- /////////////////////////////////////////////////////////////////////////////
- // This general purpose About Box assumes the following:
- //
- // 1) There is a resource templage called IDD_ABOUTBOX
- // 2) There is a static control called IDC_VERSIONINFO that
- // has room for 4 lines of text
- //
- // CAboutBox reads the Version resource from the application and
- // displays it in the static text field. The only thing you need
- // to provide in your dialog resource is an OK button and an ICON.
- //
- /////////////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include <windowsx.h>
-
- #ifndef __ABOUTBOX_H__
- #include "AboutBox.h"
- #endif
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
- CAboutBox::CAboutBox() : CDialog(CAboutBox::IDD)
- {
- //{{AFX_DATA_INIT(CAboutBox)
- //}}AFX_DATA_INIT
- }
-
- BOOL CAboutBox::OnInitDialog()
- {
- CStatic *pStatic;
- CHAR szFilename[MAX_PATH];
- CHAR buffer[128];
- DWORD versionInfoSize;
- LPVOID versionInfo;
- DWORD* translation;
- UINT translationLength;
- DWORD dwTemp1, dwTemp2;
- CHAR verStringHeader[80];
- CString AboutText;
- CHAR* string;
- UINT stringLength;
-
- // Get our EXE name
- GetModuleFileName( AfxGetInstanceHandle(), szFilename, sizeof( szFilename ) - 1 );
-
- // Init about text
- AboutText.Empty();
-
- // Get the version info block
- versionInfoSize = GetFileVersionInfoSize( szFilename , 0 );
- if( versionInfoSize != 0 )
- {
- versionInfo = GlobalAllocPtr( GMEM_MOVEABLE, versionInfoSize );
- if( versionInfo != NULL )
- {
- GetFileVersionInfo( szFilename, 0, versionInfoSize, versionInfo );
-
- // Get the translation value
- VerQueryValue( versionInfo, "\\VarFileInfo\\Translation",
- (LPVOID*)&translation, &translationLength );
- dwTemp1 = *translation;
- dwTemp2 = MAKELONG( HIWORD(dwTemp1), LOWORD(dwTemp1) );
- sprintf( verStringHeader, "\\StringFileInfo\\%08LX\\", dwTemp2 );
-
- // Get the Product Name
- strcpy( buffer, verStringHeader );
- strcat( buffer, "ProductName" );
- if( VerQueryValue( versionInfo, buffer, (LPVOID*)&string, &stringLength ) )
- {
- AboutText += string;
- AboutText += "\n";
- }
-
- // Get the file version
- strcpy( buffer, verStringHeader );
- strcat( buffer, "FileVersion" );
- if( VerQueryValue( versionInfo, buffer, (LPVOID*)&string, &stringLength ) )
- {
- AboutText += "Version ";
- AboutText += string;
- AboutText += "\n";
- }
-
- // Get the Legal Copyright
- strcpy( buffer, verStringHeader );
- strcat( buffer, "LegalCopyright" );
- if( VerQueryValue( versionInfo, buffer, (LPVOID*)&string, &stringLength ) )
- {
- AboutText += string;
- AboutText += "\n";
- }
-
- // Get the Comments
- strcpy( buffer, verStringHeader );
- strcat( buffer, "Comments" );
- if( VerQueryValue( versionInfo, buffer, (LPVOID*)&string, &stringLength ) )
- {
- AboutText += string;
- }
- }
- else AboutText = "Memory allocation failed";
- }
- else AboutText = "No version information found";
-
- if( (pStatic = (CStatic *)GetDlgItem( IDC_VERSIONINFO )) != NULL )
- {
- pStatic->SetWindowText( AboutText );
- }
- CDialog::OnInitDialog();
-
- return TRUE; // return TRUE unless you set the focus to a control
- }
-
- void CAboutBox::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutBox)
- //}}AFX_DATA_MAP
- }
-
- BEGIN_MESSAGE_MAP(CAboutBox, CDialog)
- //{{AFX_MSG_MAP(CAboutBox)
- // No message handlers
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
-