![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Fast Track Visual C++ 6.0 Programming
Listing 14.2 RememberDoc.h and RememberDoc.cpp // RememberDoc.h : interface of the CRememberDoc class // ///////////////////////////////////////////////////////////////////////////// #if !defined(AFX_REMEMBERDOC_H__B9F6B28D_AADA_11D1_887F_D42B07C10710__INCLUDED_) #define AFX_REMEMBERDOC_H__B9F6B28D_AADA_11D1_887F_D42B07C10710__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 class CRememberDoc : public CDocument { protected: // create from serialization only CRememberDoc(); DECLARE_DYNCREATE(CRememberDoc) // Attributes public: // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CRememberDoc) public: virtual BOOL OnNewDocument(); virtual void Serialize(CArchive& ar); virtual BOOL OnSaveDocument(LPCTSTR lpszPathName); //}}AFX_VIRTUAL // Implementation public: virtual ~CRememberDoc(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: // Generated message map functions protected: //{{AFX_MSG(CRememberDoc) // NOTE - the ClassWizard will add and remove member functions here. // DO NOT EDIT what you see in these blocks of generated code ! //}}AFX_MSG DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_REMEMBERDOC_H__B9F6B28D_AADA_11D1_887F_D42B07C10710__INCLUDED_) // RememberDoc.cpp : implementation of the CRememberDoc class // #include stdafx.h #include Remember.h #include RememberDoc.h #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CRememberDoc IMPLEMENT_DYNCREATE(CRememberDoc, CDocument) BEGIN_MESSAGE_MAP(CRememberDoc, CDocument) //{{AFX_MSG_MAP(CRememberDoc) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CRememberDoc construction/destruction CRememberDoc::CRememberDoc() { // TODO: add one-time construction code here } CRememberDoc::~CRememberDoc() { } BOOL CRememberDoc::OnNewDocument() { if (!CDocument::OnNewDocument()) return FALSE; // TODO: add reinitialization code here // (SDI documents will reuse this document) return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CRememberDoc serialization void CRememberDoc::Serialize(CArchive& ar) { if (ar.IsStoring()) { // TODO: add storing code here } else { // TODO: add loading code here } } ///////////////////////////////////////////////////////////////////////////// // CRememberDoc diagnostics #ifdef _DEBUG void CRememberDoc::AssertValid() const { CDocument::AssertValid(); } void CRememberDoc::Dump(CDumpContext& dc) const { CDocument::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CRememberDoc commands BOOL CRememberDoc::OnSaveDocument(LPCTSTR lpszPathName) { // TODO: Add your specialized code here and/or call the base class AfxGetApp()->WriteProfileString(Open, FileName, lpszPathName); return CDocument::OnSaveDocument(lpszPathName); }
Now that weve taken a look at using the Registry, we continue by using the Version resource. Using the Version ResourcesThe Version resource is an important part of Visual C++ programming. This resource contains information about a programs name, creators, operating system, version, language, and more, which is accessible to the user through various utilities like the Windows Explorer. In this example, which we name About, we store version information in the Version resource, and display that information in the programs About dialog box, including the programs name, version, companywe modestly use Super Incredible, Inc for the name of our software company. We also indicate whether this is a Win32 program. --------------------------------------------- |File Edit View Window Help | |--------------------------------------------- | | | | | | ---------------------------------- | | |About About | | | | |---------------------------------- | | | |About Application version 1.1 | | | |A product of Super Incredible, Inc | | | |Designed for Win32 | | | | | | | ---------------------------------- | | | | | ---------------------------------------------
Create a new MDI project named About. Next, open the Version resource in the ResourceView by opening the Version folder and double-clicking the VS_VERSION_INFO resource. This opens the Version resource, as shown in Figure 14.3. There is a great deal of information here, including the programs type, its version number, and so on. Here, we just change the CompanyName entry to Super Incredible, Inc and close the Resource Editor. This creates the following entry in the projects resource file, About.rc: VS_VERSION_INFO VERSIONINFO FILEVERSION 1,0,0,1 PRODUCTVERSION 1,0,0,1 FILEFLAGSMASK 0×3fL #ifdef _DEBUG FILEFLAGS 0×1L #else FILEFLAGS 0×0L #endif FILEOS 0×4L FILETYPE 0×1L FILESUBTYPE 0×0L BEGIN BLOCK StringFileInfo BEGIN BLOCK 040904b0 BEGIN VALUE CompanyName, Super Incredible, Inc\0 VALUE FileDescription, About MFC Application\0 VALUE FileVersion, 1, 0, 0, 1\0 VALUE InternalName, About\0 VALUE LegalCopyright, Copyright (C) 1998\0 VALUE OriginalFilename, About.EXE\0 VALUE ProductName, About Application\0 VALUE ProductVersion, 1, 0, 0, 1\0 END END BLOCK VarFileInfo BEGIN VALUE Translation, 0×409, 1200 END END
|
![]() |
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |