Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
CrdFileDriverDoc.cpp
Package: cardfile.zip [view]
Upload User: lsj_816
Upload Date: 2007-01-01
Package Size: 37k
Code Size: 4k
Category:
Windows Develop
Development Platform:
Visual C++
- // CrdFileDriverDoc.cpp : implementation of the CCrdFileDriverDoc class
- //
- #include "stdafx.h"
- #include "CrdFileDriver.h"
- #include "CrdFileDriverDoc.h"
- #include "CardFile/CardFile.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CCrdFileDriverDoc
- IMPLEMENT_DYNCREATE(CCrdFileDriverDoc, CDocument)
- BEGIN_MESSAGE_MAP(CCrdFileDriverDoc, CDocument)
- //{{AFX_MSG_MAP(CCrdFileDriverDoc)
- // 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()
- /////////////////////////////////////////////////////////////////////////////
- // CCrdFileDriverDoc construction/destruction
- CCrdFileDriverDoc::CCrdFileDriverDoc()
- {
- // TODO: add one-time construction code here
- }
- CCrdFileDriverDoc::~CCrdFileDriverDoc()
- {
- }
- BOOL CCrdFileDriverDoc::OnNewDocument()
- {
- if (!CDocument::OnNewDocument())
- return FALSE;
- ((CEditView*)m_viewList.GetHead())->SetWindowText(NULL);
- // TODO: add reinitialization code here
- // (SDI documents will reuse this document)
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CCrdFileDriverDoc serialization
- void CCrdFileDriverDoc::Serialize(CArchive& ar)
- {
- // CEditView contains an edit control which handles all serialization
- ((CEditView*)m_viewList.GetHead())->SerializeRaw(ar);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CCrdFileDriverDoc diagnostics
- #ifdef _DEBUG
- void CCrdFileDriverDoc::AssertValid() const
- {
- CDocument::AssertValid();
- }
- void CCrdFileDriverDoc::Dump(CDumpContext& dc) const
- {
- CDocument::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CCrdFileDriverDoc commands
- BOOL CCrdFileDriverDoc::OnOpenDocument(LPCTSTR lpszPathName)
- {
- // It is not necessary to call the base clas implementation of OnOpenDocument()
- // if (!CDocument::OnOpenDocument(lpszPathName))
- // return FALSE;
- HINSTANCE hInst;
- LPCSTR lpszDllPath = "CardFile.dll";
- IMPORTCARDFILE ImportCardFile;
- FREECARDFILEPTR FreeCardFilePtr;
- LPCARDFILECARD cfc;
- DWORD dwNumCards, dwResult;
- LPCSTR lpszDivider = "========================================";
- CString strFormat;
- // Load the carfile dll, and obtain a pointer to the import function
- hInst = LoadLibrary(lpszDllPath);
- if (!hInst)
- {
- AfxMessageBox("Cannot load the cardfile DLL");
- return FALSE;
- }
- ImportCardFile = (IMPORTCARDFILE)GetProcAddress(hInst, "ImportCardFile");
- if (!ImportCardFile)
- {
- AfxMessageBox("Cannot find the "ImportCardFile" process");
- return FALSE;
- }
- // Empty the string that will be shown in the edit control of the child window
- m_strText.Empty();
- // call the function that imports the cardfile. Each car will be loaded into a separate structure
- dwResult = ImportCardFile(lpszPathName, &cfc, &dwNumCards);
- // The cards was imported successfully
- if (dwResult == CF_SUCCESS)
- {
- // For each of the cards create string and add it to the main string m_strText
- // The main string will eventually be shown in the edit window
- for (DWORD i=0 ; i<dwNumCards ; i++)
- {
- strFormat.Format("%srn%srn%srn",
- lpszDivider, cfc[i].szHeading, cfc[i].szBodyText);
- m_strText += strFormat;
- }
- }
- else
- {
- // Error - show a message
- switch (dwResult)
- {
- case CF_FILETOSMALL:
- AfxMessageBox("The file was to small.");
- break;
- case CF_NOTACARDFILE:
- AfxMessageBox("This is not a valid cardfile database.");
- break;
- default:
- AfxMessageBox("Cardfile import failed.");
- }
- return FALSE;
- }
- // Load the process that will perform clean up of the imported cards
- FreeCardFilePtr = (FREECARDFILEPTR)GetProcAddress(hInst, "FreeCardFilePtr");
- if (!FreeCardFilePtr)
- {
- AfxMessageBox("Cannot find the "FreeCardFilePtr" process");
- return FALSE;
- }
- FreeCardFilePtr(&cfc, dwNumCards);
- FreeLibrary(hInst);
- // Make sure that the contents of the string with the cardfiles are shown
- UpdateAllViews(NULL);
- return TRUE;
- }