new
This commit is contained in:
commit
fb064541d6
29
UltimateToolbox93_docs/Problems.txt
Normal file
29
UltimateToolbox93_docs/Problems.txt
Normal file
@ -0,0 +1,29 @@
|
||||
The help files for Ultimate Toolbox, Ultimate Grid, and Ultimate TCP/IP are now distributed in a compiled htm format - this avoids some IE7 problems encountered with the previous WebHelp offering, allows for a simpler download, and better index and search capabilities.
|
||||
|
||||
Since the downloads first became available, several users have discovered some problems on first usage, and this text is intended as a troubleshooting guide.
|
||||
|
||||
EXPLORER:
|
||||
|
||||
When you first open the .chm file, you may see a message such as:
|
||||
|
||||
"Internet Explorer was unable to link to the Web page you requested. The page might be temporarily unavailable." or "This program cannot display the webpage", etc.
|
||||
|
||||
Later versions of windows will associate zone information with files downloaded from the internet - and this zone info may be applied to the files contained within the .zip when extracted. This may block Explorer's navigation to the html topics.
|
||||
|
||||
To solve this problem, right click on the .chm file, select Properties, and Unblock.
|
||||
|
||||
PATH:
|
||||
|
||||
You may also receive this message if the path to the .chm file contains a '#' character - this will require either the renaming of a directory or moving the files - the '#' sign is being interpreted by the viewer as a bookmark indicator.
|
||||
|
||||
Lastly, a '%' sign in the path will prevent the main window from appearing, with the contents pane displaying, e.g., 'Cannot locate "mk:MSITStore:D:\This% is a test\UTCP_IP42.chm::/TCP_IP.hhc". Again, renaming or moving the file should help.
|
||||
|
||||
INDEX:
|
||||
|
||||
There are chm compilations distributed with each of the Ultimate Toolbox, Ultimate Grid, and Ultimate TCP/IP libraries. Of these, the Ultimate Grid (UGrid72.chm) and Ultimate TCP/IP (UTCP_IP42.chm) use external index (chi) files. If these are not available in the path along with the .chm files, you should see a message box stating 'The window name "NewWindow" passed to HH_GET_WIN_TYPE has not been specified.' To resolve, make sure the associated .chi file is available.
|
||||
|
||||
Thanks for your interest in The Ultimate Toolbox. If you encounter any problems with these help compilations not addressed by this text, please post a message at http://www.codeproject.com/MFC/UltimateToolbox.asp.
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
UltimateToolbox93_docs/UTBX93.chm
Normal file
BIN
UltimateToolbox93_docs/UTBX93.chm
Normal file
Binary file not shown.
@ -0,0 +1,276 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXBinDiffCalculator
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : bdifcalc.h
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from CObject
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// NO Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// This class can be used to compute the binary differnce between two files
|
||||
// (the original and the updated file)
|
||||
// A third file that contains the difference is generated then.
|
||||
// difference = updated - original
|
||||
// Using the difference file and the original one, the updated file can be
|
||||
// computed
|
||||
// updated = original + difference
|
||||
// This class can be used by supplying the names of the files directly
|
||||
// An alternative use is that three CFile-derived objects are created and
|
||||
// opened and than passed as parameter. This permits other media besides
|
||||
// disk access (e.g. CMemFile for in-memory computation)
|
||||
|
||||
// Remark:
|
||||
// The progress of the computation is routed to an object of a COXDiffProgress
|
||||
// derived object. The default implementation writes to the console
|
||||
// using cprintf. You can derive a class from COXDiffProgress and override
|
||||
// the virtual functions Init(), Adjust(), Abort() and Close().
|
||||
// The new progreesbar will be used after a call to ReplaceProgressBar()
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
// ***
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __BDIFCALC_H__
|
||||
#define __BDIFCALC_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
// By #defining BDEXTR as 1, a reduced, decode-only version is created
|
||||
// If BDEXTR is not defined or 0, a complete version is created.
|
||||
#ifndef BDEXTR
|
||||
#define BDEXTR 0
|
||||
#endif
|
||||
|
||||
class COXDiffProgress;
|
||||
class COXDiffFileHeader;
|
||||
|
||||
class OX_CLASS_DECL COXBinDiffCalculator : public CObject
|
||||
{
|
||||
DECLARE_DYNAMIC(COXBinDiffCalculator)
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
static const double m_cMinMeanChunkLen;
|
||||
static const double m_cMaxMeanChunkLen;
|
||||
static const double m_cBigChunkLen;
|
||||
static const TCHAR* m_cFileHeader;
|
||||
static const BOOL m_cDropEOL;
|
||||
static const DWORD m_cBufSiz;
|
||||
static const WORD m_cMinMatchLen;
|
||||
static const WORD m_cMinEqualRunLen;
|
||||
|
||||
static const BYTE m_cTagSmallDiff;
|
||||
static const BYTE m_cTagMediumDiff;
|
||||
static const BYTE m_cTagLargeDiff;
|
||||
static const BYTE m_cTagSmallNearCopy;
|
||||
static const BYTE m_cTagMediumNearCopy;
|
||||
static const BYTE m_cTagLargeNearCopy;
|
||||
static const BYTE m_cTagSmallDistantCopy;
|
||||
static const BYTE m_cTagMediumDistantCopy;
|
||||
static const BYTE m_cTagLargeDistantCopy;
|
||||
static const BYTE m_cTagSmallFarCopy;
|
||||
static const BYTE m_cTagMediumFarCopy;
|
||||
static const BYTE m_cTagLargeFarCopy;
|
||||
static const BYTE m_cTagEOF;
|
||||
|
||||
static const DWORD m_cSmallSize;
|
||||
static const DWORD m_cMediumSize;
|
||||
static const DWORD m_cLargeSize;
|
||||
static const DWORD m_cNearDistance;
|
||||
static const DWORD m_cDistantDistance;
|
||||
static const DWORD m_cMaxStrLen;
|
||||
|
||||
protected:
|
||||
#if ! BDEXTR
|
||||
// The following structures are not needed in extraction program */
|
||||
|
||||
// Tree node: has 3 pointers: a pointer to lesser, and greater or equal nodes
|
||||
// The third pointer is a linked list pointer: the root node of the tree is also
|
||||
// the head of the linked list. The linked list is not built in a special order:
|
||||
// nodes are added to it in order of occurence. The tree is a binary tree.
|
||||
|
||||
struct COXTreeNode
|
||||
{
|
||||
LONG filPos;
|
||||
BYTE* bytes;
|
||||
COXTreeNode* pGE; /* Greater or equal */
|
||||
COXTreeNode* pLT; /* Less than */
|
||||
COXTreeNode() { bytes = new BYTE[m_cMinMatchLen]; }
|
||||
~COXTreeNode() { delete[] bytes; }
|
||||
};
|
||||
|
||||
// Match block structure: for each match found between the two files, we
|
||||
// encode the positions in the two files and the length of the match.
|
||||
|
||||
struct COXMatchBlock
|
||||
{
|
||||
LONG len;
|
||||
LONG orgFilPos;
|
||||
LONG derivedFilPos;
|
||||
LONG distance; /* = orgFilPos - derivedFilPos */
|
||||
COXMatchBlock* pNxt;
|
||||
};
|
||||
|
||||
struct COXByteAttribs
|
||||
{
|
||||
DWORD sum;
|
||||
double sumSquares;
|
||||
double mean;
|
||||
double stdDev;
|
||||
|
||||
// ... Last file position where a byte was encountered, for all bytes.
|
||||
// Initialized to -1 ('before' the first FILE position).
|
||||
LONG lastPos;
|
||||
|
||||
// ... Count of occurences
|
||||
LONG cnt;
|
||||
};
|
||||
|
||||
COXTreeNode* m_LstFreeTreeNode;
|
||||
COXMatchBlock* m_LstFreeMatchBlock;
|
||||
|
||||
#endif /* ! BDEXTR */
|
||||
|
||||
COXDiffProgress* m_pProgressBar;
|
||||
|
||||
private:
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
COXBinDiffCalculator();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Contructor of object
|
||||
// It will initialize the internal state
|
||||
|
||||
#if ! BDEXTR
|
||||
void SubtractFiles(LPCTSTR orgFilNam, LPCTSTR derivedFilNam, LPCTSTR diffFilNam,
|
||||
COXDiffFileHeader* pHeader = NULL);
|
||||
// --- In : orgFilNam : Full path of the original file
|
||||
// derivedFilNam : Full path of the updated file
|
||||
// diffFilNam : Full path of the difference file
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Calculates the binary differences between the
|
||||
// original and updated file and writes it
|
||||
// in the difference file
|
||||
#endif // ! BDEXTR
|
||||
|
||||
void AddFiles(LPCTSTR orgFilNam, LPCTSTR derivedFilNam, LPCTSTR diffFilNam,
|
||||
COXDiffFileHeader* pHeader = NULL);
|
||||
// --- In : orgFilNam : Full path of the original file
|
||||
// derivedFilNam : Full path of the updated file
|
||||
// diffFilNam : Full path of the difference file
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Applies the binary difference to the original file
|
||||
// writes the updated file
|
||||
|
||||
#if ! BDEXTR
|
||||
virtual void SubtractFiles(CFile* pOrgFil, CFile* pDerivedFil, CFile* pDiffFil,
|
||||
COXDiffFileHeader* pHeader = NULL);
|
||||
// --- In : orgFilNam : Pointer to OPENED file (Read)
|
||||
// derivedFilNam : Pointer to OPENED file (Read)
|
||||
// diffFilNam : Pointer to OPENED file (Create/Read/Write)
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Calculates the binary differences between the
|
||||
// original and updated file and writes it
|
||||
// in the difference file
|
||||
#endif // ! BDEXTR
|
||||
|
||||
virtual void AddFiles(CFile* pOrgFil, CFile* pDerivedFil, CFile* pDiffFil,
|
||||
COXDiffFileHeader* pHeader = NULL);
|
||||
// --- In : orgFilNam : Pointer to OPENED file (Read)
|
||||
// derivedFilNam : Pointer to OPENED file (Create/Read/Write)
|
||||
// diffFilNam : Pointer to OPENED file (Read)
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Applies the binary difference to the original file
|
||||
// writes the updated file
|
||||
|
||||
void ReplaceProgressBar(COXDiffProgress* pProgressBar);
|
||||
// --- In : pProgressBar : The new progress bar to use
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Replaces the standard progress bar by
|
||||
// another (COXDiffProgress derived)
|
||||
// This will be automatically deleted when
|
||||
// this COXBinDiffCalculator is destructed
|
||||
|
||||
#ifdef _DEBUG
|
||||
virtual void Dump(CDumpContext&) const;
|
||||
virtual void AssertValid() const;
|
||||
#endif //_DEBUG
|
||||
|
||||
virtual ~COXBinDiffCalculator();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of object
|
||||
|
||||
protected:
|
||||
void CopyFileChars(LONG count, CFile* pInFile, CFile* pOutFile, LONG& sum);
|
||||
LONG ReadLongNBytes(CFile* pFile,int n);
|
||||
#if ! BDEXTR
|
||||
void WriteLongNBytes(LONG x, CFile* pFile,int n);
|
||||
void ScanFile(CFile* pFile, COXByteAttribs* byteTable);
|
||||
int FindDelimiter(CFile* pFile, double minMeanChunkLen, double maxMeanChunkLen);
|
||||
void DeleteTreeNode(COXTreeNode* pTreeNode);
|
||||
COXTreeNode* NewTreeNode();
|
||||
void FreeTreeNode(COXTreeNode* pTreeNode);
|
||||
int CmpNode(COXTreeNode* pNode1, CFile* pFil1, COXTreeNode* pNode2,
|
||||
CFile* pFil2, int delim, LONG* pEqualLen);
|
||||
void FindBestMatch(COXTreeNode* pOrgTreeRoot,
|
||||
COXTreeNode** ppOrgTreeNode, CFile* pOrgFil, COXTreeNode* pDerivedTreeNode,
|
||||
CFile* pDerivedFil, int delim, LONG* pMatchLen);
|
||||
void AddTreeNode(COXTreeNode** ppTreeRoot, CFile* pFile,
|
||||
int delim, COXTreeNode* pNewNode);
|
||||
COXTreeNode* BuildTree(CFile* pFile, int delim, LONG& OrgSum);
|
||||
void ExtendMatch(LONG& OrgFilPos, CFile* pOrgFil,
|
||||
LONG& DerivedFilPos, CFile* pDerivedFil, LONG& MatchLen);
|
||||
void DeleteMatchBlocks(COXMatchBlock* pBlock);
|
||||
COXMatchBlock* NewMatchBlock(void);
|
||||
void FreeMatchBlock(COXBinDiffCalculator::COXMatchBlock* pMatchBlock);
|
||||
void AddMatch(COXTreeNode* pOrgTreeNode,
|
||||
CFile* pOrgFil, COXTreeNode* pDerivedTreeNode,
|
||||
CFile* pDerivedFil, LONG matchLen, COXMatchBlock** ppMatchLst);
|
||||
void ShrinkMatchList(COXMatchBlock** ppMatchLst);
|
||||
COXMatchBlock* MatchFiles(COXTreeNode* pOrgTreeRoot,CFile* pOrgFil,
|
||||
CFile* pDerivedFil, int delim, LONG& DerivedSum);
|
||||
void DumpDiff(COXMatchBlock* pMatchLst, CFile* pDerivedFil, CFile* pDiffFil);
|
||||
|
||||
#endif // ! BDEXTR
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif // __BDIFCALC_H__
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,115 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXBlob
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXBlob.h
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from CByteArray
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// NO Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// This class is an extension of CByteArray and it can by used
|
||||
// to contain a Binary Large Object
|
||||
|
||||
// Remark:
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __OXBLOB_H__
|
||||
#define __OXBLOB_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
#include "OXVariant.h"
|
||||
|
||||
|
||||
class OX_CLASS_DECL COXBlob : public CByteArray
|
||||
{
|
||||
DECLARE_DYNAMIC(COXBlob);
|
||||
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
COXBlob();
|
||||
COXBlob(const COXBlob& blobSrc);
|
||||
COXBlob(const CByteArray& arrSrc);
|
||||
COXBlob(const CLongBinary& lbSrc);
|
||||
|
||||
COXBlob(const VARIANT& varSrc);
|
||||
COXBlob(LPCVARIANT pSrc);
|
||||
COXBlob(const COleVariant& varSrc);
|
||||
COXBlob(const COXVariant& varSrc);
|
||||
|
||||
// Assignemnt operators
|
||||
COXBlob& operator=(const COXBlob& blobSrc);
|
||||
COXBlob& operator=(const CByteArray& arrSrc);
|
||||
COXBlob& operator=(const CLongBinary& lbSrc);
|
||||
|
||||
COXBlob& operator=(const VARIANT& varSrc);
|
||||
COXBlob& operator=(LPCVARIANT pSrc);
|
||||
COXBlob& operator=(const COleVariant& varSrc);
|
||||
COXBlob& operator=(const COXVariant& varSrc);
|
||||
|
||||
BOOL ReadRaw(LPCTSTR pszPath);
|
||||
// --- In : pszPath : The full path specification
|
||||
// --- Out :
|
||||
// --- Returns : Whether it succeeded or not
|
||||
// --- Effect : Reads data from the specified file into this object
|
||||
|
||||
BOOL WriteRaw(LPCTSTR pszPath);
|
||||
// --- In : pszPath : The full path specification
|
||||
// --- Out :
|
||||
// --- Returns : Whether it succeeded or not
|
||||
// --- Effect : Writes the data of this object to the specified file
|
||||
|
||||
// Destructor
|
||||
virtual ~COXBlob();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of the object
|
||||
|
||||
protected:
|
||||
BOOL CopyVariant(LPCVARIANT pSrc);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#include "OXBlob.inl"
|
||||
|
||||
#endif // __OXBLOB_H__
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,97 @@
|
||||
// ==========================================================================
|
||||
// Inline Implementation : COXBlob
|
||||
// ==========================================================================
|
||||
|
||||
// Source file : OXBlob.inl
|
||||
|
||||
// Source : R.Mortelmans
|
||||
// Creation Date : 7th March 1996
|
||||
// Last Modification : 7th March 1996
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Definition of static members
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
// public:
|
||||
inline COXBlob::COXBlob()
|
||||
{
|
||||
}
|
||||
|
||||
inline COXBlob::COXBlob(const COXBlob& blobSrc)
|
||||
{
|
||||
Copy(blobSrc);
|
||||
}
|
||||
|
||||
inline COXBlob::COXBlob(const CByteArray& arrSrc)
|
||||
{
|
||||
Copy(arrSrc);
|
||||
}
|
||||
|
||||
inline COXBlob::COXBlob(const VARIANT& varSrc)
|
||||
{
|
||||
CopyVariant(&varSrc);
|
||||
}
|
||||
|
||||
inline COXBlob::COXBlob(LPCVARIANT pSrc)
|
||||
{
|
||||
CopyVariant(pSrc);
|
||||
}
|
||||
|
||||
inline COXBlob::COXBlob(const COleVariant& varSrc)
|
||||
{
|
||||
CopyVariant(&varSrc);
|
||||
}
|
||||
|
||||
inline COXBlob::COXBlob(const COXVariant& varSrc)
|
||||
{
|
||||
CopyVariant(&varSrc);
|
||||
}
|
||||
|
||||
inline COXBlob& COXBlob::operator=(const COXBlob& blobSrc)
|
||||
{
|
||||
if(this==&blobSrc)
|
||||
return *this;
|
||||
Copy(blobSrc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline COXBlob& COXBlob::operator=(const CByteArray& arrSrc)
|
||||
{
|
||||
Copy(arrSrc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline COXBlob& COXBlob::operator=(const VARIANT& varSrc)
|
||||
{
|
||||
CopyVariant(&varSrc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline COXBlob& COXBlob::operator=(LPCVARIANT pSrc)
|
||||
{
|
||||
CopyVariant(pSrc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline COXBlob& COXBlob::operator=(const COleVariant& varSrc)
|
||||
{
|
||||
CopyVariant(&varSrc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline COXBlob& COXBlob::operator=(const COXVariant& varSrc)
|
||||
{
|
||||
CopyVariant(&varSrc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline COXBlob::~COXBlob()
|
||||
{
|
||||
}
|
||||
|
||||
// protected:
|
||||
// private:
|
||||
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,100 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXBmpFileDialog
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : oxbmpprv.h
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from COXPreviewDialog
|
||||
|
||||
// YES Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// YES Has a message map
|
||||
// YES Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// YES Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// This class implements the two virtual function of COXPreviewDialog, to display
|
||||
// BMP/DIB format.
|
||||
|
||||
// Remark:
|
||||
//
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef __BMP_PREVDLG_H__
|
||||
#define __BMP_PREVDLG_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
#include "OXPrvDlg.h"
|
||||
#include "oxdib.h"
|
||||
|
||||
|
||||
class OX_CLASS_DECL COXBmpFileDialog : public COXPreviewDialog
|
||||
{
|
||||
DECLARE_DYNAMIC(COXBmpFileDialog)
|
||||
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
|
||||
protected:
|
||||
COXDIB m_dib;
|
||||
|
||||
private:
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
COXBmpFileDialog(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs
|
||||
LPCTSTR lpszDefExt = NULL,
|
||||
LPCTSTR lpszFileName = NULL,
|
||||
DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
||||
LPCTSTR lpszFilter = NULL,
|
||||
CWnd* pParentWnd = NULL);
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Contructor of object
|
||||
|
||||
virtual ~COXBmpFileDialog();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of object
|
||||
|
||||
#ifndef WIN32
|
||||
int DoModal();
|
||||
#endif
|
||||
|
||||
|
||||
protected:
|
||||
virtual void OnNewFileSelect(const CString& sFilename);
|
||||
virtual void OnPaintPreview(CDC* pDC, const CRect& paintRect);
|
||||
virtual void OnDoRealizePalette(CWnd* pFocusWnd);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -0,0 +1,129 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXCommandLine
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : oxcmdlne.h
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from CObject
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// Yes Uses exceptions (same as CFile)
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// Tokenizes the commandline string and serves them up one by one for
|
||||
// COXCommandOptions::ParseCommandLine(). Constructor has two forms, one which
|
||||
// takes a CStdioFile pointer to support response files to get arround cmd line
|
||||
// limitations, the other takes a Character pointer.
|
||||
|
||||
// Remark:
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
// ***
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __CMDLINE_H__
|
||||
#define __CMDLINE_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
|
||||
class OX_CLASS_DECL COXCommandLine : public CObject
|
||||
{
|
||||
DECLARE_DYNAMIC(COXCommandLine)
|
||||
// Expands any meta chars (*, ?, etc) (well, one day it will :-)
|
||||
// for files in the current working directory...
|
||||
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
|
||||
protected:
|
||||
CStringArray m_Tokens;
|
||||
int m_NumTokens;
|
||||
|
||||
private:
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
COXCommandLine(LPCSTR pszCmdLine);
|
||||
// --- In : pszCmdLine : the ANSI command line to be tokenized
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Contructor of object
|
||||
// It will initialize the internal state
|
||||
|
||||
#ifdef WIN32
|
||||
COXCommandLine(LPCWSTR pszCmdLine);
|
||||
// --- In : pszCmdLine : the UNICODE command line to be tokenized
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Contructor of object
|
||||
// It will initialize the internal state
|
||||
#endif
|
||||
|
||||
COXCommandLine(CStdioFile* pInfile);
|
||||
// --- In : pInfile : The file containing a command line
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Contructor of object
|
||||
// It will initialize the internal state
|
||||
|
||||
inline int GetNumArgs() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The number of separate command line options in this command line
|
||||
// --- Effect :
|
||||
|
||||
inline CString operator[] (const int iElem) const;
|
||||
// --- In : iElem : index of a Command line option
|
||||
// --- Out :
|
||||
// --- Returns : a command line option
|
||||
// --- Effect :
|
||||
|
||||
virtual ~COXCommandLine();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of object
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
void Tokenize(LPTSTR pszCmdLine);
|
||||
};
|
||||
|
||||
inline int COXCommandLine::GetNumArgs() const
|
||||
{
|
||||
return m_NumTokens;
|
||||
}
|
||||
|
||||
inline CString COXCommandLine::operator[] (const int iElem) const
|
||||
{
|
||||
ASSERT((iElem >= 0) && (iElem <= m_NumTokens));
|
||||
return m_Tokens[iElem];
|
||||
}
|
||||
|
||||
#endif
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,262 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXCommandOptionDesc
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : oxcmdopd.h
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from CObject
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// Yes Uses exceptions (same as CFile)
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// Contains information about a command option, its full name, abbreviations,
|
||||
// description, etc.
|
||||
// For detailed explanation, see constructor with parameters.
|
||||
|
||||
// Remark:
|
||||
// The option descriptor class, each instance of
|
||||
// this class represents a valid option to the
|
||||
// program and some properties about that option.
|
||||
// Can be used by CmdOptions to produce a
|
||||
// usage message as well as to parse valid options.
|
||||
// Example:
|
||||
// void CMyApp::CreateValidOptions()
|
||||
// {
|
||||
// COXCommandOptionDesc codHelp (_T("HELP"), NULL, _T("Prints a help message"));
|
||||
// COXCommandOptionDesc codRun (_T("RUN"), NULL, _T("Automatically execute a testcase"));
|
||||
// COXCommandOptionDesc codEmf (_T("EMF"), COD_LASTARG, _T("MetaFile which specified GDI calls to make"));
|
||||
// COXCommandOptionDesc codVerify(_T("VERIFY"), COD_ARGOK, _T("Verification option"));
|
||||
// COXCommandOptionDesc codDiff (_T("DIFFERENCE"),COD_FIRSTARG,_T("File to write screen differences to"));
|
||||
// COXCommandOptionDesc codCmpScr(_T("CMPSCR"), COD_FIRSTARG,_T("File to compare screen to"));
|
||||
// COXCommandOptionDesc codOutScr(_T("OUTSCR"), COD_FIRSTARG,_T("File to write actual screen to"));
|
||||
// COXCommandOptionDesc codMask (_T("MASK"), COD_FIRSTARG,_T("File to mask screen differences with"));
|
||||
// COXCommandOptionDesc codCrc (_T("CRC"), COD_FIRSTARG,_T("File to read/write CRC code from/to"));
|
||||
// COXCommandOptionDesc codGen (_T("GENERATE"), NULL, _T("Interactive session for generating EMF file"));
|
||||
// COXCommandOptionDesc codRes (_T("RES"), COD_ARRAY, _T("Resources available"));
|
||||
// COXCommandOptionDesc codXList (_T("X"), COD_ASSOCARRAY,_T("Variable/Value pairs"));
|
||||
// }
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
// ***
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __CMDOPTD_H__
|
||||
#define __CMDOPTD_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
|
||||
const int COD_ARGOK = 0x1; // Does option take argument?
|
||||
const int COD_REPEATOK = 0x2; // Is option valid more than once?
|
||||
const int COD_REP_FIRST = 0x4; // Use first if option is repeated
|
||||
const int COD_REP_LAST = 0x8; // Use last if option is repeated
|
||||
const int COD_REP_ARRAY = 0x10; // Build array if option is repeated
|
||||
const int COD_ASSOCIATIVE = 0x20; // Takes two arguments i.e. /X=variable=value
|
||||
const int COD_FIRSTARG = COD_ARGOK | COD_REPEATOK | COD_REP_FIRST;
|
||||
const int COD_LASTARG = COD_ARGOK | COD_REPEATOK | COD_REP_LAST;
|
||||
const int COD_ARRAY = COD_ARGOK | COD_REPEATOK | COD_REP_ARRAY;
|
||||
const int COD_ASSOCARRAY = COD_ARGOK | COD_REPEATOK | COD_ASSOCIATIVE;
|
||||
|
||||
// Currently allows for COD_REP_FIRST && COD_REP_LAST, and other nonsense combinations.
|
||||
// This is not correct so pay attention to which flags you are combining !!!!!
|
||||
|
||||
class OX_CLASS_DECL COXCommandOptionDesc : public CObject
|
||||
{
|
||||
DECLARE_DYNAMIC(COXCommandOptionDesc)
|
||||
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
|
||||
protected:
|
||||
CString m_sOptionName;
|
||||
int m_nFlags;
|
||||
CString m_sDescription;
|
||||
CString m_sAbbr;
|
||||
|
||||
private:
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
COXCommandOptionDesc();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Contructor of object
|
||||
// It will initialize the internal state
|
||||
|
||||
COXCommandOptionDesc(LPCTSTR psczOptionName, int iFlags,
|
||||
LPCTSTR psczDescription, LPCTSTR psczAbbr = _T(""));
|
||||
// --- In : psczOptionName : the name of the option, CASE-INSENSITIVE
|
||||
// iFlags : the flags of the option
|
||||
// COD_ARGOK Does option take an argument
|
||||
// COD_REPEATOK Is option valid morethan once?
|
||||
// COD_REP_FIRST Use first if option is repeated
|
||||
// COD_REP_LAST Use last if option is repeated (i.e. /l dir1 /l dir2)
|
||||
// COD_REP_ARRAY Build array if option is repeated
|
||||
// COD_ASSOCIATIVE Takes two arguments i.e. /D variable=value or /D variable value
|
||||
// COD_FIRSTARG Takes an argument, is repeatable, and repeats are ignored
|
||||
// COD_LASTARG Takes an argument, is repeatable, and repeats are ignored
|
||||
// COD_ARRAY Takes an argument, is repeatable, builds an array
|
||||
// (i.e. The INCLUDE option would use this)
|
||||
// COD_ASSOCARRAY Takes two arguments, is repeatable, builds associative array
|
||||
//
|
||||
// psczDescription : the description of the option, for usage messages
|
||||
// psczAbbr : the abbreviation of the option.
|
||||
// A DEFINITE abbreviation of the argument, this abbreviation will
|
||||
// be used unless it conflicts with another option's DEFINITE abbreviation.
|
||||
// This can be used to have an abbreviation of I for the INCLUDE option, even
|
||||
// if there is another option which begins with I.
|
||||
// For all options, any UNIQUE shortening of the option name is acceptable.
|
||||
// For example, with an option name of INCLUDE, possible abbreviations would
|
||||
// be I, IN, INC, INCL, INCLU, INCLUD. Which of these possibilities are
|
||||
// valid, depends on which ones are are unique for a given option set.
|
||||
// The DEFINITE abbreviation need not be a true abbreviation of the option name.
|
||||
// For example, an option name EXPORT, could have a DEFINITE abbreviation
|
||||
// of X even though that is not strictly an abbreviation of the name.
|
||||
//
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Contructor of object
|
||||
// It will initialize the internal state
|
||||
|
||||
COXCommandOptionDesc(const COXCommandOptionDesc& OptDescSrc);
|
||||
// --- In : OptDescSrc : COXCommandOptionDesc object which will be copied
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Copy contruction.
|
||||
|
||||
COXCommandOptionDesc& operator=(const COXCommandOptionDesc& OptDescSrc);
|
||||
// --- In : OptDescSrc : COXCommandOptionDesc object which will be assign to 'this' COXCommandOptionDesc object
|
||||
// --- Out:
|
||||
// --- Returns:
|
||||
// --- Effect : Assignment operator
|
||||
|
||||
int TakesArg() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : does this option takes arguments or not
|
||||
// --- Effect :
|
||||
|
||||
int IsRepeatable() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : can this option appear more than once on a command line
|
||||
// --- Effect :
|
||||
|
||||
int ReturnsFirstRep() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : will only the first occurrence of this option be recorded or not
|
||||
// --- Effect :
|
||||
|
||||
int ReturnsLastRep() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : will only the last occurrence of this option be recorded or not
|
||||
// --- Effect :
|
||||
|
||||
int ReturnsArray() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : will the occurrences of this option build an array or not
|
||||
// --- Effect :
|
||||
|
||||
int ReturnsAssociative() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : will the occurrences of this option build an associative array or not
|
||||
// --- Effect :
|
||||
|
||||
LPCTSTR GetDescription() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : the description of this option
|
||||
// --- Effect :
|
||||
|
||||
CString GetOptName() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : the name of this option
|
||||
// --- Effect :
|
||||
|
||||
CString GetOptAbbr() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : the DEFINITE abbreviation of this option
|
||||
// --- Effect :
|
||||
|
||||
virtual ~COXCommandOptionDesc();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of object
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
inline int COXCommandOptionDesc::TakesArg() const
|
||||
{
|
||||
return m_nFlags & COD_ARGOK;
|
||||
}
|
||||
|
||||
inline int COXCommandOptionDesc::IsRepeatable() const
|
||||
{
|
||||
return m_nFlags & COD_REPEATOK;
|
||||
}
|
||||
inline int COXCommandOptionDesc::ReturnsFirstRep() const
|
||||
{
|
||||
return m_nFlags & COD_REP_FIRST;
|
||||
}
|
||||
inline int COXCommandOptionDesc::ReturnsLastRep() const
|
||||
{
|
||||
return m_nFlags & COD_REP_LAST;
|
||||
}
|
||||
inline int COXCommandOptionDesc::ReturnsArray() const
|
||||
{
|
||||
return m_nFlags & COD_REP_ARRAY;
|
||||
}
|
||||
inline int COXCommandOptionDesc::ReturnsAssociative() const
|
||||
{
|
||||
return m_nFlags & COD_ASSOCIATIVE;
|
||||
}
|
||||
inline LPCTSTR COXCommandOptionDesc::GetDescription() const
|
||||
{
|
||||
return m_sDescription;
|
||||
}
|
||||
|
||||
inline CString COXCommandOptionDesc::GetOptName() const
|
||||
{
|
||||
return m_sOptionName;
|
||||
}
|
||||
|
||||
inline CString COXCommandOptionDesc::GetOptAbbr() const
|
||||
{
|
||||
return m_sAbbr;
|
||||
}
|
||||
|
||||
#endif
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,200 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXCommandOptions
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : oxcmdopt.h
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from CObject
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// Yes Uses exceptions (same as CFile)
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// Parses the command line options and
|
||||
// answers questions about what was requested.
|
||||
// This is the 'workhorse' of the whole thing, contains the list of valid options, the map of
|
||||
// abbreviations to options, and the values of arguments to the options.
|
||||
|
||||
// Remark:
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
// ***
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __CMDOPT_H__
|
||||
#define __CMDOPT_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
#include "OXCmdOpD.h"
|
||||
#include "OXCmdLne.h"
|
||||
|
||||
|
||||
class OX_CLASS_DECL COXCommandOptions : public CObject
|
||||
{
|
||||
DECLARE_DYNAMIC(COXCommandOptions)
|
||||
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
|
||||
protected:
|
||||
CObArray m_CmdOptDescList; // Descriptions of possible command line switches
|
||||
|
||||
CMapStringToOb m_AbbrMap; // Points abbreviations to objects
|
||||
|
||||
CMapStringToOb m_Values; // Points to actual values from user
|
||||
// -RUN is stored as Values[RUN] = 1
|
||||
// -EMF=foobar is stored as Values[EMF] = foobar.emf
|
||||
// -RES=disk -RES=tape is stored as Values[RES] = "disk\ntape"
|
||||
// -x a=b is stored as Values[x] = "a=b"
|
||||
|
||||
private:
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
COXCommandOptions();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Contructor of object
|
||||
// It will initialize the internal state
|
||||
|
||||
void Add(COXCommandOptionDesc* pOptionDesc);
|
||||
// --- In : OptionDesc : An Option Description
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Add the Option Description to the array
|
||||
// You need not to worry about Option descriptions
|
||||
// going out of scope because they are copied internally
|
||||
// before being added to an option description array.
|
||||
|
||||
void Add(LPCTSTR psczOptionName, int iFlags,
|
||||
LPCTSTR psczDescription, LPCTSTR psczsAbbr = _T(""));
|
||||
// --- In : psczOptionName : the name of the option, CASE-INSENSITIVE
|
||||
// iFlags : the flags of the option
|
||||
// COD_ARGOK Does option take an argument
|
||||
// COD_REPEATOK Is option valid morethan once?
|
||||
// COD_REP_FIRST Use first if option is repeated
|
||||
// COD_REP_LAST Use last if option is repeated (i.e. /l dir1 /l dir2)
|
||||
// COD_REP_ARRAY Build array if option is repeated
|
||||
// COD_ASSOCIATIVE Takes two arguments i.e. /D variable=value or /D variable value
|
||||
// COD_FIRSTARG Takes an argument, is repeatable, and repeats are ignored
|
||||
// COD_LASTARG Takes an argument, is repeatable, and repeats are ignored
|
||||
// COD_ARRAY Takes an argument, is repeatable, builds an array
|
||||
// (i.e. The INCLUDE option would use this)
|
||||
// COD_ASSOCARRAY Takes two arguments, is repeatable, builds associative array
|
||||
//
|
||||
// psczDescription : the description of the option, for usage messages
|
||||
// psczAbbr : the abbreviation of the option.
|
||||
// A DEFINITE abbreviation of the argument, this abbreviation will
|
||||
// be used unless it conflicts with another option's DEFINITE abbreviation.
|
||||
// This can be used to have an abbreviation of I for the INCLUDE option, even
|
||||
// if there is another option which begins with I.
|
||||
// For all options, any UNIQUE shortening of the option name is acceptable.
|
||||
// For example, with an option name of INCLUDE, possible abbreviations would
|
||||
// be I, IN, INC, INCL, INCLU, INCLUD. Which of these possibilities are
|
||||
// valid, depends on which ones are are unique for a given option set.
|
||||
// The DEFINITE abbreviation need not be a true abbreviation of the option name.
|
||||
// For example, an option name EXPORT, could have a DEFINITE abbreviation
|
||||
// of X even though that is not strictly an abbreviation of the name.
|
||||
//
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Add the Option Description to the array
|
||||
|
||||
BOOL Remove(LPCTSTR pszcOption);
|
||||
// --- In : pszcOption : the option to delete
|
||||
// --- Out :
|
||||
// --- Returns : succeeded or not
|
||||
// --- Effect : Removes this option from all internal lists
|
||||
|
||||
CString ParseCmdLine(COXCommandLine& cl, CStringList* pRestList = NULL);
|
||||
// --- In : cl : the Command line object to parse
|
||||
// pRestList : when provided will contain the strings on the command line
|
||||
// that aren't flags. Is actually the same as the return string
|
||||
// except that the separate parts are stored in a Stringlist.
|
||||
// --- Out :
|
||||
// --- Returns : Anything left over on the command line after parsing the valid options
|
||||
// --- Effect : Construct array of actual parameters based on command line object
|
||||
// Can throw an COXCommandLineException
|
||||
|
||||
const COXCommandOptionDesc* GetOptionObject(LPCTSTR psczOption) const;
|
||||
// --- In : psczOption : the name of the option
|
||||
// --- Out :
|
||||
// --- Returns : the option object with pszcOption as NAME. NULL if not found.
|
||||
// --- Effect :
|
||||
|
||||
BOOL IsEnabled(LPCTSTR psczOption) const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : Did the option appeared on the command line or not
|
||||
// --- Effect : It works for any of the argument forms
|
||||
|
||||
CString GetValue(LPCTSTR psczOption) const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The argument associated with the option
|
||||
// --- Effect : It is used with single-occurrence, single-argument options
|
||||
|
||||
const CStringList* GetValues(LPCTSTR psczOption) const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The list of arguments associated with the option
|
||||
// --- Effect : It is used with single-argument, multiple-occurrence options
|
||||
|
||||
const CMapStringToString* GetAssocPairs(LPCTSTR psczOption) const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The list of combined arguments associated with the option
|
||||
// --- Effect : It is used with options that take two arguments, the first being
|
||||
// a key name, the second the value of of the key. This is useful
|
||||
// for options that set variables like -Dfoo=bar in a compiler
|
||||
|
||||
CString Usage(LPCTSTR psczMsg) const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : prints usage message if StdHandles are available
|
||||
|
||||
virtual ~COXCommandOptions();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of object
|
||||
|
||||
protected:
|
||||
// Construct abbreviation map from given OptionDesc's
|
||||
void BuildAbbrTable();
|
||||
|
||||
// Reset contents of all maps and lists. Called by destructor
|
||||
void ResetMaps();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,96 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXCommandLineException
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : oxcmdlex.h
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from CException
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// NO Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// This class encapsulates a new exception for Command line parsing
|
||||
|
||||
// Remark:
|
||||
//
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef __CMDLEXCEPTION_H__
|
||||
#define __CMDLEXCEPTION_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
|
||||
class COXCommandOptions;
|
||||
|
||||
class OX_CLASS_DECL COXCommandLineException : public CException
|
||||
{
|
||||
DECLARE_DYNAMIC(COXCommandLineException)
|
||||
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
|
||||
protected:
|
||||
CString m_sErrMsg;
|
||||
|
||||
private:
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
COXCommandLineException(LPCTSTR pszcError, COXCommandOptions* pCmdOpt = NULL);
|
||||
// --- In : pszcError : the actual Errormessage
|
||||
// pCmdOpt : the command option object that parses the command line.
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Contructor of object
|
||||
// It will initialize the internal state
|
||||
// This constructor will expand the error message with some
|
||||
// extra information concerning the command line being parsed
|
||||
|
||||
virtual BOOL GetErrorMessage(LPTSTR lpszError, UINT nMaxError, UINT* pnHelpContext = NULL );
|
||||
// --- In : see CException::GetErrorMessage()
|
||||
// --- Out :
|
||||
// --- Returns : TRUE if string available, otherwise FALSE
|
||||
// --- Effect : retrieves the error string if available
|
||||
|
||||
BOOL WriteToStdErr();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : TRUE if write was successful, otherwise FALSE
|
||||
// --- Effect : Writes the error message to the STDERR (for use in CONSOLE programs)
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,142 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXCommMsg
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXCommMSg.h
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from CArray
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// NO Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// This class encapsulates strict typed data
|
||||
// It is an array of OLE variants.
|
||||
// It can be used to communicate data together with the type
|
||||
|
||||
// Remark:
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __OXCOMMMSG_H__
|
||||
#define __OXCOMMMSG_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
#include <afxtempl.h>
|
||||
#include "OXVariant.h"
|
||||
|
||||
|
||||
class OX_CLASS_DECL COXCommMsg : public CArray<COXVariant, COXVariant>
|
||||
{
|
||||
DECLARE_DYNAMIC(COXCommMsg)
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
// Possible types
|
||||
enum EOXArgumentTypes // ID bytes C-type member name
|
||||
{
|
||||
ATEmpty = VT_EMPTY, // (0) 0 - -
|
||||
ATNull = VT_NULL, // (1) 0 - -
|
||||
ATBool = VT_BOOL, // (11) 2 VARIANT_BOOL bool
|
||||
ATUI1 = VT_UI1, // (17) 1 unsigned char bVal
|
||||
ATI2 = VT_I2, // (2) 2 short iVal
|
||||
ATI4 = VT_I4, // (3) 4 long lVal
|
||||
ATCy = VT_CY, // (6) 8 CY cyVal
|
||||
ATR4 = VT_R4, // (4) 4 float fltVal
|
||||
ATR8 = VT_R8, // (5) 8 double dblVal
|
||||
ATStr = VT_BSTR, // (8) 4+len BSTR bstrVal
|
||||
ATDate = VT_DATE, // (7) 8 DATE date
|
||||
ATError = VT_ERROR, // (10) 4 SCODE scode
|
||||
ATBlob = VT_UI1 | VT_ARRAY
|
||||
// (8209)4+len - -
|
||||
};
|
||||
|
||||
// Total number of types
|
||||
enum
|
||||
{
|
||||
m_nArgumentTypesCount = 13
|
||||
};
|
||||
// Array containing all the types
|
||||
static EOXArgumentTypes m_types[m_nArgumentTypesCount];
|
||||
static LPCTSTR m_typeNames[m_nArgumentTypesCount];
|
||||
|
||||
protected:
|
||||
static WORD m_nMagicNumber;
|
||||
static WORD m_nVariantType;
|
||||
|
||||
private:
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
|
||||
COXCommMsg();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Constructs the object
|
||||
|
||||
virtual void Serialize(CArchive& ar);
|
||||
// --- In : ar : Archive used in serialization
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Serializes the object
|
||||
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : AssertValid performs a validity check on this object
|
||||
// by checking its internal state.
|
||||
// In the Debug version of the library, AssertValid may assert and
|
||||
// thus terminate the program.
|
||||
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
// --- In : dc : The diagnostic dump context for dumping, usually afxDump.
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Dumps the contents of the object to a CDumpContext object.
|
||||
// It provides diagnostic services for yourself and
|
||||
// other users of your class.
|
||||
// Note The Dump function does not print a newline character
|
||||
// at the end of its output.
|
||||
#endif
|
||||
|
||||
virtual ~COXCommMsg();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of the object
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif // __OXCOMMMSG_H__
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,31 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by OXCommon.rc
|
||||
//
|
||||
#define psh14 0x040d
|
||||
#define chx1 0x0410
|
||||
#define stc1 0x0440
|
||||
#define stc2 0x0441
|
||||
#define stc3 0x0442
|
||||
#define stc4 0x0443
|
||||
#define stc32 0x045f
|
||||
#define lst1 0x0460
|
||||
#define lst2 0x0461
|
||||
#define cmb1 0x0470
|
||||
#define cmb2 0x0471
|
||||
#define edt1 0x0480
|
||||
#define IDC_PREVIEW_WND 23080
|
||||
#define IDC_PREVIEW_FRAME 23081
|
||||
#define IDC_PREVIEW 23082
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_3D_CONTROLS 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 23083
|
||||
#define _APS_NEXT_COMMAND_VALUE 53080
|
||||
#define _APS_NEXT_CONTROL_VALUE 23080
|
||||
#define _APS_NEXT_SYMED_VALUE 23080
|
||||
#endif
|
||||
#endif
|
||||
@ -0,0 +1,118 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "OXCommon.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"OXCommon.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
PREVIEWFILEOPEN DIALOG DISCARDABLE 36, 24, 279, 132
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Open"
|
||||
FONT 8, "Helv"
|
||||
BEGIN
|
||||
LTEXT "File &Name:",stc3,6,6,76,10
|
||||
EDITTEXT edt1,6,16,90,12,ES_LOWERCASE | ES_AUTOHSCROLL |
|
||||
ES_OEMCONVERT
|
||||
LISTBOX lst1,6,32,90,68,LBS_SORT | LBS_OWNERDRAWFIXED |
|
||||
LBS_HASSTRINGS | LBS_EXTENDEDSEL | LBS_DISABLENOSCROLL |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "&Directories:",IDC_STATIC,110,6,92,9
|
||||
LTEXT "",stc1,110,16,92,9,SS_NOPREFIX
|
||||
LISTBOX lst2,110,32,92,68,LBS_SORT | LBS_OWNERDRAWFIXED |
|
||||
LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_VSCROLL |
|
||||
WS_TABSTOP
|
||||
LTEXT "List Files of &Type:",stc2,6,102,90,9
|
||||
COMBOBOX cmb1,6,112,90,36,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL |
|
||||
WS_BORDER | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Dri&ves:",stc4,110,102,92,9
|
||||
COMBOBOX cmb2,110,112,92,68,CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED |
|
||||
CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
DEFPUSHBUTTON "OK",IDOK,213,2,50,13,WS_GROUP
|
||||
PUSHBUTTON "Cancel",IDCANCEL,213,16,50,13,WS_GROUP
|
||||
PUSHBUTTON "&Help",1038,159,95,6,6,WS_GROUP
|
||||
PUSHBUTTON "Net&work...",psh14,213,112,50,13,WS_GROUP
|
||||
CONTROL "&Read Only",chx1,"Button",BS_AUTOCHECKBOX | WS_GROUP |
|
||||
WS_TABSTOP,176,94,8,8
|
||||
CONTROL "&Preview",IDC_PREVIEW,"Button",BS_AUTOCHECKBOX |
|
||||
WS_GROUP | WS_TABSTOP,213,101,50,11
|
||||
GROUPBOX "",IDC_PREVIEW_FRAME,212,28,59,68
|
||||
CONTROL "",IDC_PREVIEW_WND,"Button",BS_OWNERDRAW | WS_TABSTOP,
|
||||
213,34,56,61
|
||||
END
|
||||
|
||||
PREVIEWFILEOPEN95 DIALOG DISCARDABLE 36, 24, 353, 152
|
||||
STYLE DS_MODALFRAME | DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_VISIBLE |
|
||||
WS_CLIPSIBLINGS
|
||||
FONT 8, "Helv"
|
||||
BEGIN
|
||||
LTEXT "",stc32,5,9,266,123
|
||||
CONTROL "&Preview",IDC_PREVIEW,"Button",BS_AUTOCHECKBOX |
|
||||
WS_GROUP | WS_TABSTOP,283,98,50,11
|
||||
GROUPBOX "",IDC_PREVIEW_FRAME,281,25,60,68
|
||||
CONTROL "",IDC_PREVIEW_WND,"Button",BS_OWNERDRAW | WS_TABSTOP,
|
||||
283,31,56,61
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@ -0,0 +1,328 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXCommunicator
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXCommunicator.h
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from CSocket
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// NO Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// This class can be used to create a client server communication
|
||||
// using WinSockets.
|
||||
// This class can be used as a client that will connect to a server
|
||||
// This is much like the base class CSocket
|
||||
// * Initialize(nTimeOut, pCancelWnd)
|
||||
// * Create()
|
||||
// * Connect(sRemoteAddress, nRemotePort)
|
||||
// When you use this class as a server that listens to multiple clients
|
||||
// a socket for each client connection will be created.
|
||||
// * Initialize(nTimeOut, pCancelWnd)
|
||||
// * Create(nServerPort)
|
||||
// * Listen()
|
||||
// Yo end a communication, just call
|
||||
// * Close()
|
||||
// To simplify the communications two archives are available,
|
||||
// one for reading and one for writing
|
||||
// * GetInStream()
|
||||
// * GetOutStream()
|
||||
|
||||
// All client connections are also COXCommunicator objects
|
||||
// They will be created automatically when a server gets a request
|
||||
// from a new client. They can be address by a handle HCLIENT_COMMUNICATOR
|
||||
|
||||
// All callbacks are virtual functions of this class
|
||||
|
||||
|
||||
// Remark:
|
||||
// This type of communication will block like a socket
|
||||
// This means that during Send() and Receive() the entire thread will block
|
||||
// until the function completes
|
||||
// There are three exceptions to this rule :
|
||||
// 1) A timer can be specified. When the time out is reached
|
||||
// the blocking operation will be cancelled
|
||||
// 2) Tou can specify a cancel window. All the messages for this
|
||||
// window and its children will still be dispatched
|
||||
// 3) WM_PAINT messages will still be dispatched
|
||||
|
||||
// While a communicator is blocking, it may not start a new operation
|
||||
// Such a recursive call could occur when the cancel window would
|
||||
// initiate a new operation. So be sure to avoid this situation
|
||||
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __OXCOMMUNICATOR_H__
|
||||
#define __OXCOMMUNICATOR_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
#include <afxtempl.h>
|
||||
|
||||
#define HCLIENT_COMMUNICATOR long
|
||||
|
||||
|
||||
class OX_CLASS_DECL COXCommunicator : public CSocket
|
||||
{
|
||||
DECLARE_DYNAMIC(COXCommunicator)
|
||||
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
|
||||
protected:
|
||||
COXCommunicator* m_pMasterCommunicator;
|
||||
CMap<COXCommunicator*, COXCommunicator*, HCLIENT_COMMUNICATOR, HCLIENT_COMMUNICATOR> m_connections;
|
||||
CSocketFile* m_pFile;
|
||||
CArchive* m_pInStream;
|
||||
CArchive* m_pOutStream;
|
||||
HWND m_hCancelWindow;
|
||||
UINT m_nTimeOut;
|
||||
UINT m_nTimerID;
|
||||
UINT m_nStreamBufferSize;
|
||||
|
||||
static HCLIENT_COMMUNICATOR m_nLastUsedHandle;
|
||||
static CMap<UINT, UINT, COXCommunicator*, COXCommunicator*> m_TimerToCommunicator;
|
||||
|
||||
private:
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
|
||||
COXCommunicator(UINT nStreamBufferSize = 4096, COXCommunicator* pMasterCommunicator = NULL);
|
||||
// --- In : nStreamBufferSize : The size of the buffer used for the input and output stream
|
||||
// If you intend to use very large objects, increase the buffer size
|
||||
// pMasterCommunicator : The master communicator to notify
|
||||
// This parameter is only used for client connections
|
||||
// and should always by NULL
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Constructs the object
|
||||
|
||||
HCLIENT_COMMUNICATOR GetClientHandle(COXCommunicator* pClientCommunicator);
|
||||
// --- In : pClientCommunicator : The client communicator which handle is requested
|
||||
// --- Out :
|
||||
// --- Returns : The handle of the specified communicator (or NULL when not found)
|
||||
// --- Effect :
|
||||
|
||||
COXCommunicator* GetClientCommunicator(HCLIENT_COMMUNICATOR hClient);
|
||||
// --- In : hClient : The client communicator handle which object is requested
|
||||
// --- Out :
|
||||
// --- Returns : A pointer to the specified communicator (or NULL when not found)
|
||||
// --- Effect :
|
||||
|
||||
void Initialize(UINT uTimeOut = 10000, CWnd* pCancelWnd = NULL);
|
||||
// --- In : uTimeOut : Time out value in milli seconds
|
||||
// pCancelWnd : Pointer to the cancel window
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Initializes the communicator
|
||||
|
||||
void SetCancelWindow(CWnd* pCancelWnd);
|
||||
// --- In : pCancelWnd : Pointer to the cancel window
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Sets a new cancel window
|
||||
|
||||
void SetTimeOut(UINT uTimeOut);
|
||||
// --- In : uTimeOut : Time out value in milli seconds
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Sets a new timeout value
|
||||
|
||||
BOOL IsOpen();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : Whether a valid socket is associated with this communicator
|
||||
// --- Effect :
|
||||
|
||||
BOOL IsListening();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : Whether this communicator is listening
|
||||
// --- Effect :
|
||||
|
||||
BOOL IsBlocking();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : Whether this communicator is blocking on an operation
|
||||
// --- Effect :
|
||||
|
||||
BOOL AreAnyBlocking();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : Whether this communicator or any client communicators
|
||||
// are blocking on an operation
|
||||
// --- Effect :
|
||||
|
||||
void CancelAllBlockingCalls();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Cancels the blocking call of this communicator and all the
|
||||
// client communicators
|
||||
|
||||
DWORD GetMaxReadable();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : Determine the maximum number of bytes that can be read with
|
||||
// one Receive() call.
|
||||
// This is normally the same as the total amount of data queued
|
||||
// --- Effect :
|
||||
|
||||
CArchive* GetInStream();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The input stream of which may be read
|
||||
// --- Effect : The communicator must be open
|
||||
// Use IsBufferEmpty() to see whether data is still waiting
|
||||
|
||||
CArchive* GetOutStream();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The output stream to which may be written
|
||||
// --- Effect : The communicator must be open
|
||||
|
||||
// Notifications of a client communicator
|
||||
virtual void OnClientCreate(HCLIENT_COMMUNICATOR hClient, COXCommunicator* pClientCommunicator);
|
||||
// --- In : hClient : The handle of the client communicator
|
||||
// pClientCommunicator : A pointer to the client communicator
|
||||
// nErrorCode : The most recent error code of the communicator
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Notifies that a new client communicator has been created
|
||||
|
||||
virtual void OnClientReceive(HCLIENT_COMMUNICATOR hClient, COXCommunicator* pClientCommunicator, DWORD nSize, int nErrorCode);
|
||||
// --- In : hClient : The handle of the client communicator
|
||||
// pClientCommunicator : A pointer to the client communicator
|
||||
// nSize : The number of bytes that can be read in one Receive()
|
||||
// nErrorCode : The most recent error code of the communicator
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Notifies that the specified client communicator has received data
|
||||
// which can be read using the input stream of the communicator
|
||||
|
||||
virtual void OnClientClose(HCLIENT_COMMUNICATOR hClient, COXCommunicator* pClientCommunicator, int nErrorCode);
|
||||
// --- In : hClient : The handle of the client communicator
|
||||
// pClientCommunicator : A pointer to the client communicator
|
||||
// nErrorCode : The most recent error code of the communicator
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Notifies that the specified client communicator has closed
|
||||
|
||||
virtual void OnClientDestroy(HCLIENT_COMMUNICATOR hClient, COXCommunicator* pClientCommunicator);
|
||||
// --- In : hClient : The handle of the client communicator
|
||||
// pClientCommunicator : A pointer to the client communicator
|
||||
// nErrorCode : The most recent error code of the communicator
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Notifies that an existent client communicator will be destroyed
|
||||
|
||||
// Notifications of this communicator
|
||||
virtual void OnServerReceive(DWORD nSize, int nErrorCode);
|
||||
// --- In : nSize : The number of bytes that can be read in one Receive()
|
||||
// nErrorCode : The most recent error code of the communicator
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Notifies that this communicator has received data
|
||||
// which can be read using the input stream
|
||||
|
||||
virtual void OnServerClose(int nErrorCode);
|
||||
// --- In : nErrorCode : The most recent error code of the communicator
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Notifies that this communicator has closed
|
||||
|
||||
// The following functions have the save effect as those of the base class CSocket
|
||||
// with the additional features of a timeout value and a cancel window
|
||||
virtual BOOL Accept(CAsyncSocket& rConnectedSocket,
|
||||
SOCKADDR* lpSockAddr = NULL, int* lpSockAddrLen = NULL);
|
||||
virtual int Receive(void* lpBuf, int nBufLen, int nFlags = 0);
|
||||
virtual int Send(const void* lpBuf, int nBufLen, int nFlags = 0);
|
||||
virtual void Close();
|
||||
|
||||
virtual BOOL OnMessagePending();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Overrides the base class implementation to add additional features
|
||||
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : AssertValid performs a validity check on this object
|
||||
// by checking its internal state.
|
||||
// In the Debug version of the library, AssertValid may assert and
|
||||
// thus terminate the program.
|
||||
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
// --- In : dc : The diagnostic dump context for dumping, usually afxDump.
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Dumps the contents of the object to a CDumpContext object.
|
||||
// It provides diagnostic services for yourself and
|
||||
// other users of your class.
|
||||
// Note The Dump function does not print a newline character
|
||||
// at the end of its output.
|
||||
#endif
|
||||
|
||||
virtual ~COXCommunicator();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of the object
|
||||
|
||||
protected:
|
||||
virtual void OnAccept(int nErrorCode);
|
||||
virtual void OnReceive(int nErrorCode);
|
||||
virtual void OnClose(int nErrorCode);
|
||||
|
||||
void OnNotifyReceive(COXCommunicator* pClientCommunicator, DWORD nSize, int nErrorCode);
|
||||
void OnNotifyClose(COXCommunicator* pClientCommunicator, int nErrorCode);
|
||||
void OnNotifyKill(COXCommunicator* pClientCommunicator, int nErrorCode);
|
||||
|
||||
void CreateTimer();
|
||||
void CloseTimer();
|
||||
static UINT StartTimer(COXCommunicator* pCommunicator, UINT nTimeOut);
|
||||
static void StopTimer(UINT nTimerID);
|
||||
static void CALLBACK TimerProc(HWND hWnd, UINT nMsg, UINT nTimerID, DWORD dwTime);
|
||||
|
||||
virtual BOOL ConnectHelper(const SOCKADDR* lpSockAddr, int nSockAddrLen);
|
||||
virtual int ReceiveFromHelper(void* lpBuf, int nBufLen,
|
||||
SOCKADDR* lpSockAddr, int* lpSockAddrLen, int nFlags);
|
||||
virtual int SendToHelper(const void* lpBuf, int nBufLen,
|
||||
const SOCKADDR* lpSockAddr, int nSockAddrLen, int nFlags);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif // __OXCOMMUNICATOR_H__
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,135 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXDiffFileHeader
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXDFlHdr.h
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from CObject
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// YES Persistent objects (saveable on disk)
|
||||
// YES Uses exceptions
|
||||
// Throws CArchiveException::badSchema : Incorrect file type
|
||||
// Verion incorrect
|
||||
// CArchiveException::badClass : Value of object out of range
|
||||
// Passes through CArchiveException
|
||||
// CFileException
|
||||
// CMemoryException
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// This class encapsulates the header of a binary difference file
|
||||
|
||||
// Remark:
|
||||
//
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef __DIFF_HEADER_H__
|
||||
#define __DIFF_HEADER_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
|
||||
class OX_CLASS_DECL COXDiffFileHeader : public CObject
|
||||
{
|
||||
DECLARE_DYNAMIC(COXDiffFileHeader)
|
||||
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
|
||||
protected:
|
||||
CString m_sSignText;
|
||||
|
||||
private:
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
COXDiffFileHeader(CString sSignature);
|
||||
// --- In : sSignature : Signature of object
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Contructor of object
|
||||
// It will initialize the internal state
|
||||
|
||||
CString GetSignature() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : the signature of the file that was read from disk
|
||||
// Identifies a file as one of this category
|
||||
// --- Effect :
|
||||
|
||||
virtual void ReadHeader(CFile* pFile);
|
||||
// --- In : pFile : pointer to file
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Reads the object (header) from the file
|
||||
|
||||
virtual void WriteHeader(CFile* pFile);
|
||||
// --- In : pFile : pointer to file
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Writes the object (header) to the file
|
||||
|
||||
virtual void Serialize(CArchive& ar);
|
||||
// --- In : ar : archive
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Reads or writes the object (header and/or data) to the archive
|
||||
|
||||
COXDiffFileHeader(const COXDiffFileHeader& HdrSrc);
|
||||
// --- In : HdrSrc : Header object which will be copied
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Copy contruction.
|
||||
// Notice that global memory will be copied
|
||||
|
||||
COXDiffFileHeader& operator=(const COXDiffFileHeader& HdrSrc);
|
||||
// --- In : HdrSrc : Header object which will be assign to 'this' Header object
|
||||
// --- Out:
|
||||
// --- Returns:
|
||||
// --- Effect : Assignment operator
|
||||
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
virtual ~COXDiffFileHeader();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of object
|
||||
|
||||
protected:
|
||||
virtual void Read(CArchive& ar, BOOL bReportLogicalErrors = TRUE);
|
||||
virtual void Write(CArchive& ar);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,104 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXDispatchMarshaller
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXDispatchMarshaller.h
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// YES Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Description :
|
||||
// Encapsulation of a IStream object used for marshalling between thread.
|
||||
//
|
||||
|
||||
// Remark:
|
||||
//
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __OXDISPATCHMARSHALLER_H__
|
||||
#define __OXDISPATCHMARSHALLER_H__
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COXDispatchMarshaller definition
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
|
||||
class OX_CLASS_DECL COXDispatchMarshaller
|
||||
{
|
||||
// Data Members
|
||||
public:
|
||||
|
||||
protected:
|
||||
LPSTREAM m_pStream; // A IStream object used for marshalling between thread (appartements)
|
||||
HANDLE m_hMutexEvent; // Mutex for synchronisation of Marshall and Unmarshall.
|
||||
|
||||
private:
|
||||
|
||||
// Member Functions
|
||||
public:
|
||||
COXDispatchMarshaller();
|
||||
// --- In : none
|
||||
// --- Out : none
|
||||
// --- Returns :
|
||||
// --- Effect : constructs the object ans allocates memory for the Stream
|
||||
|
||||
virtual ~COXDispatchMarshaller();
|
||||
// --- In : none
|
||||
// --- Out : none
|
||||
// --- Returns :
|
||||
// --- Effect : destructs the object ans releases the Stream
|
||||
|
||||
HRESULT Marshal(IDispatch* pDisp);
|
||||
// --- In : pDisp: the dispatch object that needs to be marshalled between to threads
|
||||
// --- Out : none
|
||||
// --- Returns : the result of the marshalling
|
||||
// --- Effect : calls internally CoMarshalInterface (see DSK Ref. for return values)
|
||||
|
||||
HRESULT Unmarshal(void** pDisp);
|
||||
// --- In : none
|
||||
// --- Out : none
|
||||
// --- Returns : the result of the Unmarshalling
|
||||
// --- Effect : calls internally CoUnmarshalInterface (see DSK Ref. for return values)
|
||||
|
||||
BOOL CheckStream();
|
||||
// --- In : none
|
||||
// --- Out : none
|
||||
// --- Returns : If the internal stream pointer is created successfully
|
||||
// --- Effect :
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif //__OXDISPATCHMARSHALLER_H__
|
||||
@ -0,0 +1,102 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXFinalReleaseWnd
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXFinalReleaseWnd.h
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
|
||||
// YES Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// YES Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Description :
|
||||
// This object serves as a message sink for the COXOwnThread object
|
||||
// It's important that the COXOwnThread object is deleted by the same
|
||||
// thread that instantiation ed the object (the Owner thread).
|
||||
// The OnFinalRelease function of COXOwnThread will check which thread
|
||||
// (Owner or Own thread) tries to delete the object. If it is the Own
|
||||
// thread, a message is send to this object (which is a data member of
|
||||
// the COWOwnThread object). Because this object is a window created by
|
||||
// the Owner thread, the message will be handled by the Owner thread and
|
||||
// consequently the COXOwnThread object can be safely destroyed from here.
|
||||
|
||||
// Remark:
|
||||
//
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __OXFINALERELEASEWND_H__
|
||||
#define __OXFINALERELEASEWND_H__
|
||||
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
#define WMOX_FINAL_RELEASE WM_USER+1
|
||||
|
||||
|
||||
class COXOwnThread;
|
||||
|
||||
class OX_CLASS_DECL COXFinalReleaseWnd : public CWnd
|
||||
{
|
||||
// Data Members
|
||||
public:
|
||||
|
||||
protected:
|
||||
static CString m_sClassName; // the class name used for registration
|
||||
COXOwnThread* m_pOwnThread; // a pointer to the parent object
|
||||
// initialized by constructor
|
||||
|
||||
private:
|
||||
|
||||
// Member Functions
|
||||
public:
|
||||
COXFinalReleaseWnd(COXOwnThread* pOwnThread);
|
||||
// --- In : pOwnThread: a pointer to the parent object COXOwnThread
|
||||
// so that we can delete the parent from within this object
|
||||
// --- Out : none
|
||||
// --- Returns :
|
||||
// --- Effect : Constructs the object
|
||||
|
||||
virtual ~COXFinalReleaseWnd();
|
||||
// --- In : none
|
||||
// --- Out : none
|
||||
// --- Returns :
|
||||
// --- Effect : Destructs the object
|
||||
|
||||
protected:
|
||||
afx_msg LONG OnObjectFinalRelease(UINT, LONG);
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif //__OXFINALERELEASEWND_H__
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@ -0,0 +1,72 @@
|
||||
#if !defined(_OXMETAFILEVIEWER_H__)
|
||||
#define _OXMETAFILEVIEWER_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
// OXMetafileViewer.h : header file
|
||||
//
|
||||
|
||||
#include "OXMetaFile.h"
|
||||
#include "OXScrollWnd.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COXMetafileViewer window
|
||||
|
||||
class OX_CLASS_DECL COXMetafileViewer : public COXScrollWnd
|
||||
{
|
||||
DECLARE_DYNAMIC(COXMetafileViewer)
|
||||
// Construction
|
||||
public:
|
||||
COXMetafileViewer();
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
protected:
|
||||
// metafile image
|
||||
COXMetaFile m_MetaFile;
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
BOOL LoadFile(LPCTSTR lpszPathName);
|
||||
inline BOOL LoadResource(UINT nIDResource, CString strResType=_T("METAFILE"));
|
||||
|
||||
inline COXMetaFile* GetImage() { return &m_MetaFile; }
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(COXMetafileViewer)
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~COXMetafileViewer();
|
||||
|
||||
protected:
|
||||
CSize GetMetafileSize();
|
||||
|
||||
virtual BOOL InitializeImage(const CSize& sizePage=CSize(100,100),
|
||||
const CSize& sizeLine=CSize(10,10));
|
||||
|
||||
BOOL DrawMetafile(CDC* pDC, const CRect& rectSrc);
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(COXMetafileViewer)
|
||||
afx_msg void OnPaint();
|
||||
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(_OXMETAFILEVIEWER_H__)
|
||||
@ -0,0 +1,172 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXOwnThread
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXOwnThread.h
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// YES Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Description :
|
||||
// The purpose of this class is to serve as a base class for COXOwnThreadCmdTarget,
|
||||
// COXOwnThreadDocument or user derived classes from CCmdTarget (Encapsulation around
|
||||
// a IDispatch OLE object).
|
||||
// The class mainly encapsulates the marshalling of IDispatch object between the
|
||||
// Owner thread (the thread that created the object) and the Own thread (a own
|
||||
// message loop).
|
||||
// By marshalling the IDispatch object, the OLE calls to the object will be
|
||||
// re-routed to the Own thread.
|
||||
// The derived class needs to derive from CCmdTarget (or other derived class from
|
||||
// CCmdTarget) and from this class, in order to re-route the OLE calls complete
|
||||
// transparently. COXOwnThreadCmdTarget and COXOwnThreadDocument are 2 (ready to use)
|
||||
// examples of how to use this COwnThread engine class.
|
||||
|
||||
// Remark:
|
||||
//
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __OXOWNTHREAD_H__
|
||||
#define __OXOWNTHREAD_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
|
||||
#include "OXDispatchMarshaller.h"
|
||||
#include "OXFinalReleaseWnd.h"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COwnThread engine
|
||||
|
||||
class OX_CLASS_DECL COXOwnThread
|
||||
{
|
||||
// Data Members
|
||||
public:
|
||||
|
||||
protected:
|
||||
BOOL m_bHasOwnThread;
|
||||
HANDLE m_hCreatedEvent;
|
||||
HANDLE m_hThreadEvent;
|
||||
HANDLE m_hEndEvent;
|
||||
HRESULT m_hCreateResult;
|
||||
LPUNKNOWN m_pMarshalledPunk;
|
||||
BOOL m_bEndThread;
|
||||
DWORD m_nOwnerThreadID;
|
||||
DWORD m_nOwnThreadID;
|
||||
COXDispatchMarshaller
|
||||
m_dispatchMarshaller;
|
||||
COXFinalReleaseWnd
|
||||
m_finalReleaseWnd;
|
||||
|
||||
friend COXFinalReleaseWnd;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
// Member Functions
|
||||
public:
|
||||
COXOwnThread();
|
||||
// --- In : none
|
||||
// --- Out : none
|
||||
// --- Returns : nothing
|
||||
// --- Effect : constructs the object
|
||||
|
||||
virtual ~COXOwnThread();
|
||||
// --- In : none
|
||||
// --- Out : none
|
||||
// --- Returns : nothing
|
||||
// --- Effect : constructs the object
|
||||
|
||||
BOOL EnableOwnThread();
|
||||
// --- In : none
|
||||
// --- Out : none
|
||||
// --- Returns : If the own thread is started successful or not
|
||||
// This function should always succeed unless
|
||||
// the operating systems is extremely low on resources
|
||||
// --- Effect : All the OLE Calls to this object will be re-routed
|
||||
// by the own thread.
|
||||
// Different objects can be served simultaneous.
|
||||
|
||||
BOOL HasOwnThread();
|
||||
// --- In : none
|
||||
// --- Out : none
|
||||
// --- Returns : if the CmdTarget has a own thread started.
|
||||
// --- Effect :
|
||||
|
||||
BOOL FinalReleaseRouter();
|
||||
// --- In : none
|
||||
// --- Out : none
|
||||
// --- Returns : if the call is re-routed or not
|
||||
// --- Effect : If you override the virtual member function 'OnFinalRelease' of CCmdTarget,
|
||||
// you have to call this function before you do anything else.
|
||||
// If the call returns TRUE, you have to return immediately.
|
||||
// Example with CMyCmdTarget derived from COXOwnThreadCmdTarget
|
||||
// void CMyCmdTarget::OnFinalRelease()
|
||||
// {
|
||||
// if (FinalReleaseRouter())
|
||||
// return;
|
||||
//
|
||||
// // TODO: Add your specialised code here and/or call the base class
|
||||
//
|
||||
// CCmdTarget::OnFinalRelease();
|
||||
// }
|
||||
|
||||
void SetThreadEvent();
|
||||
// --- In : none
|
||||
// --- Out : none
|
||||
// --- Returns : nothing
|
||||
// --- Effect : Fires an event to the own thread, which will call the overridable
|
||||
// function 'OnThreadEvent'.
|
||||
|
||||
virtual LPDISPATCH GetIDispatch(BOOL bAddRef) = 0;
|
||||
// --- In : bAddRef: Specifies whether to increment the reference count for the object.
|
||||
// --- Out : none
|
||||
// --- Returns : The IDispatch pointer associated with the object
|
||||
// --- Effect : This is a pure virtual function, so the implementation of the derived class is used.
|
||||
// This declaration is needed to give access to the real CCmdTarget implementation of this function
|
||||
|
||||
protected:
|
||||
LPUNKNOWN GetInterfaceHook(const void*);
|
||||
virtual void OnFinalRelease() = 0;
|
||||
void Run();
|
||||
static UINT __cdecl StartThread(LPVOID pOwnThread);
|
||||
void EndThread();
|
||||
virtual void OnThreadEvent();
|
||||
virtual void OnThreadDestroy();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif //__OXOWNTHREAD_H__
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@ -0,0 +1,162 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXOwnThreadCmdTarget
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXOwnThreadCmdTarget.h
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// YES Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Description :
|
||||
// This class is an alternative for CCmdTarget. It offers multi-threading
|
||||
// functionality to your automation server.
|
||||
// By deriving from this class instead of CCmdTarget, all your OLE calls
|
||||
// are handled by a separate Own thread. In that way more concurrently
|
||||
// calls can be handled simultaneously.
|
||||
// The main part of the implementation is done in the COXOwnThread class, so
|
||||
// the code can be shared by other derivation of CCmdTarget (see COXOwnThreadDocument).
|
||||
|
||||
// HOW TO USE -> it is as easy as this:
|
||||
// As said above, you need to derive from this class instead of CCmdTarget.
|
||||
// Further more you need to call the 'EnableOwnthread' function from within
|
||||
// the constructor of your derived class.
|
||||
// If you are overriding the 'OnFinalRelease' function of CCmdTarget
|
||||
// you need also to call 'FinalReleaseRouter()' (see 'FinalReleaseRouter' further on)
|
||||
|
||||
// For derivation of CDocument you have to use COXOwnThreadDocument.
|
||||
// For other derivation you can build your own class analogue to COXOwnThreadCmdTarget
|
||||
// and COXOwnThreadDocument.
|
||||
|
||||
// Remark:
|
||||
//
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __OXOWNTHREADCMDTARGET_H__
|
||||
#define __OXOWNTHREADCMDTARGET_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COwnThreadCmdTarget command target
|
||||
|
||||
#include "OXOwnThread.h"
|
||||
|
||||
|
||||
class OX_CLASS_DECL COXOwnThreadCmdTarget : public CCmdTarget, public COXOwnThread
|
||||
{
|
||||
DECLARE_DYNCREATE(COXOwnThreadCmdTarget)
|
||||
|
||||
// Data Members
|
||||
public:
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
// Member Functions
|
||||
public:
|
||||
|
||||
// The public interface of this class contains 3 easy functions.
|
||||
// They are defined in COXOwnThread where this class is derived from:
|
||||
|
||||
// BOOL EnableOwnThread();
|
||||
// --- In : none
|
||||
// --- Out : none
|
||||
// --- Returns : If the own thread is started successful or not
|
||||
// This function should always succeed unless
|
||||
// the operating systems is extremely low on resources
|
||||
// --- Effect : All the OLE Calls to this object will be re-routed
|
||||
// by the own thread.
|
||||
// Different objects can be served simultaneous.
|
||||
|
||||
// BOOL HasOwnThread();
|
||||
// --- In : none
|
||||
// --- Out : none
|
||||
// --- Returns : if the CmdTarget has a own thread started.
|
||||
// --- Effect :
|
||||
|
||||
// BOOL FinalReleaseRouter();
|
||||
// --- In : none
|
||||
// --- Out : none
|
||||
// --- Returns : if the call is re-routed or not
|
||||
// --- Effect : If you override the virtual member function 'OnFinalRelease' of CCmdTarget,
|
||||
// you have to call this function before you do anything else.
|
||||
// If the call returns TRUE, you have to return immediately.
|
||||
// Example:
|
||||
// void CMyCmdTarget::OnFinalRelease()
|
||||
// {
|
||||
// if (FinalReleaseRouter())
|
||||
// return;
|
||||
//
|
||||
// // TODO: Add your specialised code here and/or call the base class
|
||||
//
|
||||
// CCmdTarget::OnFinalRelease();
|
||||
// }
|
||||
|
||||
|
||||
virtual LPDISPATCH GetIDispatch(BOOL bAddRef);
|
||||
// --- In : bAddRef: Specifies whether to increment the reference count for the object.
|
||||
// --- Out : none
|
||||
// --- Returns : The IDispatch pointer associated with the object
|
||||
// --- Effect : provides access to the IDispatch handle
|
||||
// Is used by the COXOwnThread base class
|
||||
|
||||
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(COXOwnThreadCmdTarget)
|
||||
public:
|
||||
virtual void OnFinalRelease();
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
|
||||
protected:
|
||||
COXOwnThreadCmdTarget(); // protected constructor used by dynamic creation
|
||||
virtual ~COXOwnThreadCmdTarget();
|
||||
|
||||
virtual LPUNKNOWN GetInterfaceHook(const void*);
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(COXOwnThreadCmdTarget)
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
// Generated OLE dispatch map functions
|
||||
//{{AFX_DISPATCH(COXOwnThreadCmdTarget)
|
||||
//}}AFX_DISPATCH
|
||||
DECLARE_DISPATCH_MAP()
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
#endif //__OXOWNTHREADCMDTARGET_H__
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@ -0,0 +1,136 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXPreviewDialog
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXPrvDlg.h
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from CFileDialog
|
||||
|
||||
// YES Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// YES Has a message map
|
||||
// YES Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// YES Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// This class extends the Common File Dialog with a specific
|
||||
// custom template in order to have a preview area in this dialog. To implement a
|
||||
// dialog that previews BMP's, derive a class from this class and implement two
|
||||
// virtual functions : OnNewFileSelect() and
|
||||
// OnPaintPreview(CDC* pDC, const CRect& paintRect)
|
||||
|
||||
// Remark:
|
||||
// This file uses resources.
|
||||
// The reserved ID ranges are : 23080 -> 23099 and 53080 -> 53099
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef __OXPRVDLG_H__
|
||||
#define __OXPRVDLG_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
|
||||
class OX_CLASS_DECL COXPreviewDialog : public CFileDialog
|
||||
{
|
||||
DECLARE_DYNAMIC(COXPreviewDialog)
|
||||
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
|
||||
protected:
|
||||
CStatic m_previewFrame;
|
||||
BOOL m_bPreview;
|
||||
BOOL m_bPrevPreview;
|
||||
CString m_sSelectedFile;
|
||||
CString m_sPrevSelectedFile;
|
||||
|
||||
class OX_CLASS_DECL COXPreview : public CButton
|
||||
{
|
||||
// Data Members
|
||||
public:
|
||||
protected:
|
||||
private:
|
||||
// Member Functions
|
||||
public:
|
||||
COXPreview();
|
||||
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
|
||||
protected:
|
||||
private:
|
||||
} m_preview;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
friend COXPreview;
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
COXPreviewDialog(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs
|
||||
LPCTSTR lpszDefExt = NULL,
|
||||
LPCTSTR lpszFileName = NULL,
|
||||
DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
||||
LPCTSTR lpszFilter = NULL,
|
||||
CWnd* pParentWnd = NULL);
|
||||
// --- In : see constructor MFC CFiledialog
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Contructor of object
|
||||
|
||||
virtual ~COXPreviewDialog();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of object
|
||||
|
||||
|
||||
protected:
|
||||
virtual void OnNewFileSelect(const CString& sFilename);
|
||||
virtual void OnPaintPreview(CDC* pDC, const CRect& paintRect);
|
||||
virtual void OnDoRealizePalette(CWnd* pFocusWnd);
|
||||
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
void CheckFileSelection();
|
||||
|
||||
#ifdef WIN32
|
||||
BOOL IsWin95();
|
||||
virtual void OnFileNameChange();
|
||||
CString GetFilePath() const;
|
||||
#endif
|
||||
|
||||
afx_msg void OnPreview();
|
||||
virtual BOOL OnInitDialog();
|
||||
|
||||
afx_msg void OnPaletteChanged(CWnd* pFocusWnd);
|
||||
afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
private:
|
||||
virtual void OnLBSelChangedNotify( UINT nIDBox, UINT iCurSel, UINT nCode);
|
||||
|
||||
};
|
||||
|
||||
#endif //__OXPRVDLG_H__
|
||||
|
||||
@ -0,0 +1,187 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXResultObj
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXResultObj.h
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from CObject
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// YES Persistent objects (saveable on disk)
|
||||
// NO Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// This class encapsulates a collection of COXResultParts
|
||||
|
||||
// Remark:
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __OXRESULTOBJ_H__
|
||||
#define __OXRESULTOBJ_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
#include "AfxTempl.h"
|
||||
#include "OXResultPart.h"
|
||||
|
||||
|
||||
class OX_CLASS_DECL COXResultObj : public CArray<COXResultPart, const COXResultPart&>
|
||||
{
|
||||
DECLARE_DYNAMIC(COXResultObj);
|
||||
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
protected:
|
||||
COXResultPart m_defaultPart;
|
||||
|
||||
private:
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
COXResultObj();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Constructs the object
|
||||
|
||||
COXResultObj(const COXResultPart& defaultPart);
|
||||
// --- In : defaultPart
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Constructs the object and sets the default part
|
||||
// The default part will be returned when
|
||||
// you want to retrieve a part when this object is empty
|
||||
|
||||
COXResultObj(const COXResultObj& result);
|
||||
// --- In : result : Object to copy
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Copy constructor
|
||||
|
||||
COXResultObj& operator=(const COXResultObj& result);
|
||||
// --- In : result : Object to assigne
|
||||
// --- Out :
|
||||
// --- Returns : This object
|
||||
// --- Effect : Assignment operator
|
||||
|
||||
void operator+=(const COXResultObj& result);
|
||||
// --- In : result : Object to add
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Adds the specified result to this object
|
||||
|
||||
void operator+=(const COXResultPart& resultPart);
|
||||
// --- In : resultPart : Object to add
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Adds the specified result part to this result object
|
||||
|
||||
COXResultPart& GetDefaultPart();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The default part
|
||||
|
||||
COXResultPart GetDefaultPart() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The default part
|
||||
|
||||
void SetDefaultPart(const COXResultPart& defaultPart);
|
||||
// --- In : defaultPart
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Sets the default part
|
||||
// The default part will be returned when
|
||||
// you want to retrieve a part when this object is empty
|
||||
|
||||
void Empty();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Empties this result object
|
||||
|
||||
BOOL IsEmpty() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : Whether this object contains any result itemùs (FALSE) or not (TRUE)
|
||||
// --- Effect :
|
||||
|
||||
COXResultPart& GetMostSeverePart();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The result part with the highest extended severity
|
||||
// --- Effect : When this object does not contain any parts,
|
||||
// a new part is added to this object and returned
|
||||
|
||||
COXResultPart GetMostSeverePart() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The result part with the highest extended severity
|
||||
// --- Effect : When this object does not contain any parts,
|
||||
// a new empty part is returned
|
||||
|
||||
COXResultPart* operator->();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The result part with the highest extended severity
|
||||
// --- Effect : When this object does not contain any parts,
|
||||
// a new part is added to this object and returned
|
||||
// This is a quick way to get the most severe part from
|
||||
// the collection and perform a function on it
|
||||
|
||||
virtual void Serialize(CArchive& ar);
|
||||
// --- In : ar : Archive used in serialization
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Serializes the object
|
||||
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : AssertValid performs a validity check on this object
|
||||
// by checking its internal state.
|
||||
// In the Debug version of the library, AssertValid may assert and
|
||||
// thus terminate the program.
|
||||
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
// --- In : dc : The diagnostic dump context for dumping, usually afxDump.
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Dumps the contents of the object to a CDumpContext object.
|
||||
// It provides diagnostic services for yourself and
|
||||
// other users of your class.
|
||||
#endif
|
||||
|
||||
virtual ~COXResultObj();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of the object
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif // __OXRESULTOBJ_H__
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,269 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXResultPart
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXResultPart.h
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from CObject
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// YES Persistent objects (saveable on disk)
|
||||
// NO Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// This class encapsulates a single result code and its message
|
||||
|
||||
// An object can be constructed from an HRESULT value.
|
||||
// Now the accompanying message will be retrieved from the message resource
|
||||
// When optional parameters are needed they can be supplied
|
||||
|
||||
// A group of these object can be stored in a COXResultObj
|
||||
|
||||
// Remark:
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __OXRESULTPART_H__
|
||||
#define __OXRESULTPART_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
#ifndef __AFXOLE_H__
|
||||
#include <AfxOle.h>
|
||||
#define __AFXOLE_H__
|
||||
#endif
|
||||
|
||||
|
||||
class OX_CLASS_DECL COXResultPart : public CObject
|
||||
{
|
||||
DECLARE_SERIAL(COXResultPart);
|
||||
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
protected:
|
||||
COleDateTime m_creationTime;
|
||||
HRESULT m_resultCode;
|
||||
CString m_sResultMessage;
|
||||
DWORD m_dwExtra;
|
||||
|
||||
static DWORD m_dwLangID;
|
||||
|
||||
private:
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
COXResultPart();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Constructs an empty result item object
|
||||
|
||||
COXResultPart(HRESULT resultCode, ...);
|
||||
COXResultPart(LPCTSTR pszModuleName, HRESULT resultCode, ...);
|
||||
// --- In : (optional) pszModuleName : Name of the module containing the message resource
|
||||
// resultCode : Result code to use
|
||||
// ... : Optional parameters used to build the message
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Constructs a result item object with the specified
|
||||
// resultcode
|
||||
// The appropriate message is retrieved from resource
|
||||
// and for this the optional parameters may be used
|
||||
|
||||
COXResultPart(const COXResultPart& resultItem);
|
||||
// --- In : resultItem : Object to copy
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Copy constructor
|
||||
|
||||
BOOL Initialize();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Initializes to an empty result item object
|
||||
|
||||
BOOL Initialize(HRESULT resultCode, ...);
|
||||
BOOL Initialize(LPCTSTR pszModuleName, HRESULT resultCode, ...);
|
||||
BOOL InitializeSpecial(LPCTSTR pszModuleName, DWORD resultCode, ...);
|
||||
// --- In : (optional) pszModuleName : Name of the module containing the message resource
|
||||
// resultCode : Result code to use
|
||||
// ... : Optional parameters used to build the message
|
||||
// --- Out :
|
||||
// --- Returns : Whether the message could be retrieved successfully
|
||||
// --- Effect : Initializes a result item object with the specified
|
||||
// resultcode
|
||||
// The appropriate message is retrieved from resource
|
||||
// and for this the optional parameters may be used
|
||||
|
||||
HRESULT GetResultCode() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The result code of this object
|
||||
// --- Effect :
|
||||
|
||||
void SetResultCode(HRESULT resultCode);
|
||||
// --- In : resultCode : New result code to set
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Sets the result code to a new value
|
||||
// Other parts (message etc) are not automatically updated
|
||||
|
||||
CString GetResultMessage() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The result message of this object
|
||||
// --- Effect :
|
||||
|
||||
void SetResultMessage(CString sResultMessage);
|
||||
// --- In : sResultMessage : New result message to set
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Sets the result code to a new value
|
||||
// Other parts (code etc) are not automatically updated
|
||||
|
||||
void AppendMessage(CString sMessage);
|
||||
// --- In : sMessage : Message to append
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Appends the specified text to the result message
|
||||
|
||||
CString BuildExtendedMessage() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The extended result message of this object
|
||||
// --- Effect :
|
||||
|
||||
COleDateTime GetTimeStamp() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The time stamp when the item was created
|
||||
// --- Effect :
|
||||
|
||||
void SetTimeStamp(COleDateTime creationTime);
|
||||
// --- In : creationTime : New creation time to set
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Sets the creation date to a new value
|
||||
// Other parts (code etc) are not automatically updated
|
||||
// The date must be valid
|
||||
|
||||
DWORD GetExtraData() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The extra data of this object
|
||||
// --- Effect :
|
||||
|
||||
void SetExtraData(DWORD dwExtra);
|
||||
// --- In : dwExtra : New extra data to set
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Sets the extra data to a new value
|
||||
// Other parts (code etc) are not automatically updated
|
||||
|
||||
COXResultPart& operator=(const COXResultPart& resultItem);
|
||||
// --- In : resultItem : Object to assigne
|
||||
// --- Out :
|
||||
// --- Returns : This object
|
||||
// --- Effect : Assignment operator
|
||||
|
||||
BOOL Succeeded() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : Whether the result code specifies success (SUCCEEDED)
|
||||
// --- Effect :
|
||||
|
||||
BOOL Failed() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : Whether the result code specifies failure (FAILED)
|
||||
// --- Effect :
|
||||
|
||||
WORD GetCode() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The code part of the result code (HRESULT_CODE)
|
||||
// --- Effect :
|
||||
|
||||
WORD GetFacility() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The facility part of the result code (HRESULT_FACILITY)
|
||||
// --- Effect :
|
||||
|
||||
WORD GetSeverity() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The severity part of the result code (HRESULT_SEVERITY)
|
||||
// --- Effect :
|
||||
|
||||
WORD GetSeverityEx() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The extended severity part of the result code (bits 31 and 30)
|
||||
// --- Effect :
|
||||
|
||||
virtual void Serialize(CArchive& ar);
|
||||
// --- In : ar : Archive used in serialization
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Serializes the object
|
||||
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : AssertValid performs a validity check on this object
|
||||
// by checking its internal state.
|
||||
// In the Debug version of the library, AssertValid may assert and
|
||||
// thus terminate the program.
|
||||
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
// --- In : dc : The diagnostic dump context for dumping, usually afxDump.
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Dumps the contents of the object to a CDumpContext object.
|
||||
// It provides diagnostic services for yourself and
|
||||
// other users of your class.
|
||||
#endif
|
||||
|
||||
virtual ~COXResultPart();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of the object
|
||||
|
||||
protected:
|
||||
BOOL InitializeEx(HRESULT resultCode, va_list* pArgs);
|
||||
BOOL InitializeEx(LPCTSTR pszModuleName, HRESULT resultCode, va_list* pArgs);
|
||||
BOOL InitializeExSpecial(LPCTSTR pszModuleName, DWORD dwResultCode, va_list* pArgs);
|
||||
static BOOL RetrieveResultMessage(CString sModuleName, HRESULT resultCode,
|
||||
va_list* pArgs, CString& sResultMessage);
|
||||
static BOOL RetrieveSpecialMessage(CString sModuleName, DWORD dwResultCode,
|
||||
va_list* pArgs, CString& sResultMessage);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
// Define some handy macros
|
||||
#include "OXResultPartDef.h"
|
||||
|
||||
#endif // __OXRESULTPART_H__
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,81 @@
|
||||
// ==========================================================================
|
||||
// Macro Definition for COXResultPart
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXResultPartDef.h
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// These macros only have an actual implementation if _DEBUG is defined
|
||||
// otherwise they all are defined empty
|
||||
|
||||
#ifndef __OXRESULTPARTDEF_H__
|
||||
#define __OXRESULTPARTDEF_H__
|
||||
|
||||
#ifdef _DEBUG
|
||||
// OX_TRACE_ERROR_EX(RES, TX)
|
||||
// --- In : RES : The numeric result code (long)
|
||||
// TX : A string which will be used as prefix
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Traces the messages associated with sepcified result code
|
||||
// together with leading text
|
||||
#define OX_TRACE_ERROR_EX(RES, TX) \
|
||||
{ \
|
||||
HRESULT r = (RES); \
|
||||
if (HRESULT_FACILITY(r) == 0) \
|
||||
r = HRESULT_FROM_WIN32(r); \
|
||||
if (FAILED(r)) \
|
||||
{ \
|
||||
COXResultPart resultPart(r); \
|
||||
TRACE(_T("%s : HRESULT = 0x%X\n\t%s"), (TX), r, resultPart.GetResultMessage()); \
|
||||
} \
|
||||
}
|
||||
|
||||
// OX_TRACE_ERROR_EX(RES)
|
||||
// --- In : RES : The numeric result code (long)
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Traces the messages associated with sepcified result code
|
||||
// together with the current file name and line number
|
||||
#define OX_TRACE_ERROR(RES) \
|
||||
{ \
|
||||
CString sLine; \
|
||||
sLine.Format(_T("%i"), __LINE__); \
|
||||
OX_TRACE_ERROR_EX(RES, CString(__FILE__) + _T(" (") + sLine + _T(")")); \
|
||||
}
|
||||
|
||||
// OX_TRACE_LAST_ERROR_EX(TX)
|
||||
// --- In : TX : A string which will be used as prefix
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Traces the message associated with the last error
|
||||
// together with leading text
|
||||
#define OX_TRACE_LAST_ERROR_EX(TX) \
|
||||
{ \
|
||||
HRESULT nLastError = ::GetLastError(); \
|
||||
OX_TRACE_ERROR_EX(HRESULT_FROM_WIN32(nLastError), TX); \
|
||||
}
|
||||
|
||||
// OX_TRACE_LAST_ERROR()
|
||||
// --- In : TX : A string which will be used as prefix
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Traces the message associated with the last error
|
||||
// together with the current file name and line number
|
||||
#define OX_TRACE_LAST_ERROR() \
|
||||
{ \
|
||||
HRESULT nLastError = ::GetLastError(); \
|
||||
CString sLine; \
|
||||
sLine.Format(_T("%i"), __LINE__); \
|
||||
OX_TRACE_ERROR_EX(HRESULT_FROM_WIN32(nLastError), CString(__FILE__) + _T(" (") + sLine + _T(")")); \
|
||||
}
|
||||
|
||||
#else
|
||||
#define OX_TRACE_ERROR_EX(RES, TX)
|
||||
#define OX_TRACE_ERROR(RES)
|
||||
#define OX_TRACE_LAST_ERROR_EX(TX)
|
||||
#define OX_TRACE_LAST_ERROR()
|
||||
#endif
|
||||
#endif // __OXRESULTPARTDEF_H__
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,144 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXSerialCommConfig
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXSCCFG.H
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// NO Is derived from Wnd
|
||||
// NO Two stage creation (constructor & Initialize())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// YES Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Description :
|
||||
// COXSerialCommConfig class
|
||||
// This object defines the port configuration settings like port ID, baudrate,
|
||||
// bytesize, parity, stopbits and flowcontrol. You can set also the size of
|
||||
// the software buffers and the timeout values of the ‘clear to send’,
|
||||
// ‘data set ready’ and ‘Carrier detect’ signals. These settings can be loaded
|
||||
// and saved to disk.
|
||||
|
||||
// Remark:
|
||||
//
|
||||
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __OXSCCFG_H_
|
||||
#define __OXSCCFG_H_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
|
||||
class OX_CLASS_DECL COXSerialCommConfig : public CObject
|
||||
{
|
||||
DECLARE_SERIAL(COXSerialCommConfig);
|
||||
|
||||
// Data Members
|
||||
public:
|
||||
enum EFlowControl // flow control enum type
|
||||
{
|
||||
NONE,
|
||||
HARDWARE,
|
||||
XON_XOFF
|
||||
};
|
||||
|
||||
BYTE m_nPortId; // 0..8 (COM1..COM9)
|
||||
UINT m_nBaudRate; // CBR_xxx (as in DCB)
|
||||
BYTE m_nByteSize; // 7..8 (as in DCB)
|
||||
BYTE m_nParity; // 0..2 (as in DCB)
|
||||
BYTE m_nStopBits; // 0/2 (as in DCB)
|
||||
EFlowControl m_eFlowControl; // flow control type
|
||||
|
||||
UINT m_nSizeReceivingQueue; // buffer size of the incomming queue
|
||||
UINT m_nSizeTransmissionQueue; // buffer size of the outgoing queue
|
||||
UINT m_nCdTimeout; // the time that the carrier must be down
|
||||
// before the signal is changing state
|
||||
UINT m_nCtsTimeout; // Clear to send timeout
|
||||
UINT m_nDsrTimeout; // Data set ready timeout
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
// Member Functions
|
||||
public:
|
||||
COXSerialCommConfig();
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: none
|
||||
// --- Effect: Constructs the configutration object
|
||||
|
||||
COXSerialCommConfig(COXSerialCommConfig& config);
|
||||
// --- In: config: another COXSerialCommConfig object
|
||||
// --- Out: none
|
||||
// --- Returns: none
|
||||
// --- Effect: copy constructor
|
||||
|
||||
COXSerialCommConfig& operator = (const COXSerialCommConfig& config);
|
||||
// --- In: config: another COXSerialCommConfig object
|
||||
// --- Out: none
|
||||
// --- Returns: the reference of the object that is copied into
|
||||
// --- Effect: copy operator
|
||||
|
||||
CString GetCommName() const;
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: the name of the communication device as a stdio filename
|
||||
// (example: "COM1" for port com1)
|
||||
// --- Effect: none
|
||||
|
||||
int DoConfigDialog(CString sTitle = _T(""));
|
||||
// --- In: sTitle: the title of the dialog box (a default title is used if empty)
|
||||
// --- Out: none
|
||||
// --- Returns: IDOK or IDCANCEL
|
||||
// --- Effect: start a modal configuration dialog box
|
||||
|
||||
BOOL IsPortAvailable() const;
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: if the port is available or not
|
||||
// --- Effect: tries to open the port
|
||||
|
||||
BOOL Load(CString sFileName);
|
||||
// --- In: sFileName: the filename of the configuration file
|
||||
// --- Out: none
|
||||
// --- Returns: if the configuration file is successfully loaded
|
||||
// --- Effect: loads the configuration file into this object
|
||||
|
||||
BOOL Save(CString sFileName);
|
||||
// --- In: sFileName: the filename of the configuration file
|
||||
// --- Out: none
|
||||
// --- Returns: if the configuration file is successfully saved
|
||||
// --- Effect: saves the configuration setting to file
|
||||
|
||||
protected:
|
||||
virtual void Serialize(CArchive& ar);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif //__OXSCCFG_H_
|
||||
@ -0,0 +1,22 @@
|
||||
#ifndef __OXSCCNST_H_
|
||||
#define __OXSCCNST_H_
|
||||
|
||||
const int COMM_MSRSHADOW = 35; // Modem Status Register "shadow"
|
||||
const int MSR_CTS = 0x10; // see Microsoft PSS ID Q101417
|
||||
const int MSR_DSR = 0x20;
|
||||
const int MSR_RI = 0x40;
|
||||
const int MSR_RLSD = 0x80;
|
||||
|
||||
const UINT DefaultSizeReceivingQueue = 4096;
|
||||
const UINT DefaultSizeTransmissionQueue = 4096;
|
||||
const UINT DefaultCdTimeout = 2000;
|
||||
const UINT DefaultCtsTimeout = 5000;
|
||||
const UINT DefaultDsrTimeout = 5000;
|
||||
|
||||
const int MaxNumberOfBuffers = 4;
|
||||
const int RS232TimerId = 0x1245;
|
||||
const int RS232TimerValue = 100; // 100 mSec.
|
||||
const UINT _Rs232PostMessage_ = WM_USER;
|
||||
const UINT _Rs232InternalNotify_ = WM_USER+1;
|
||||
|
||||
#endif __OXSCCNST_H_
|
||||
@ -0,0 +1,55 @@
|
||||
#ifndef __OXSCEXCP_H_
|
||||
#define __OXSCEXCP_H_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
|
||||
OX_API_DECL void AFXAPI AfxThrowSerialCommException(int cause,
|
||||
LPCTSTR lpszSerialCommName = NULL);
|
||||
|
||||
class OX_CLASS_DECL COXSerialCommException: public CFileException
|
||||
{
|
||||
DECLARE_DYNAMIC(COXSerialCommException)
|
||||
|
||||
// Data Members
|
||||
public:
|
||||
enum VALUE
|
||||
{
|
||||
none,
|
||||
notAvailable,
|
||||
breakDetect,
|
||||
rxTimeout,
|
||||
ctsTimeout,
|
||||
dsrTimeout,
|
||||
cdTimeout,
|
||||
frameError,
|
||||
parityError,
|
||||
overrunError,
|
||||
rxQueueOverflow,
|
||||
txQueueFull,
|
||||
wmQuitReceived,
|
||||
ioError,
|
||||
modeError
|
||||
};
|
||||
|
||||
int m_ext_cause;
|
||||
|
||||
// Member Functions
|
||||
public:
|
||||
COXSerialCommException(int cause = none,
|
||||
LPCTSTR lpszSerialCommName = NULL);
|
||||
COXSerialCommException(COXSerialCommException& other);
|
||||
COXSerialCommException& operator = (const COXSerialCommException& other);
|
||||
virtual BOOL GetErrorMessage( LPTSTR lpszError, UINT nMaxError, PUINT pnHelpContext = NULL );
|
||||
#ifdef _DEBUG
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif //__OXSCEXCP_H_
|
||||
@ -0,0 +1,274 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXSerialCommFile
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXSCFILE.H
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Is derived from CFile
|
||||
// NO Two stage creation (constructor & Initialize())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// YES Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Description :
|
||||
// COXSerialCommFile class
|
||||
// The COXSerialCommFile class is the main class which controls the serial port.
|
||||
// It is derived from CFile and is therefor compatible with MFC serialization.
|
||||
// Next to the derived interface, COXSerialCommFile is extended with some other
|
||||
// function for controlling the handshake signals, the read and write buffers and
|
||||
// the time-out values.
|
||||
//
|
||||
|
||||
// Remark:
|
||||
// If the following error appears the only solution is to add at the top of the
|
||||
// initinstance the following code: (the default depth is only 8!. Maximum = 120.)
|
||||
// int QueueDepth = 32;
|
||||
// while (!::SetMessageQueue(QueueDepth))
|
||||
// QueueDepth--;
|
||||
//
|
||||
// ERROR MESSAGE:
|
||||
// FATAL ERROR!
|
||||
// The Windows message queue is full!
|
||||
// Rs232 messages lost!
|
||||
// Increase the message queue depth.
|
||||
|
||||
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __OXSCFILE_H_
|
||||
#define __OXSCFILE_H_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
#include "OXSCCFG.H"
|
||||
#include "OXSCEXCP.H"
|
||||
|
||||
|
||||
class OX_CLASS_DECL COXSerialCommFile : public CFile
|
||||
{
|
||||
// Data Members
|
||||
public:
|
||||
|
||||
protected:
|
||||
HANDLE m_hCommDevice;
|
||||
|
||||
private:
|
||||
|
||||
// Member Functions
|
||||
public:
|
||||
COXSerialCommFile();
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: none
|
||||
// --- Effect: Constructs the object and initialize the internal state
|
||||
|
||||
virtual ~COXSerialCommFile();
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: none
|
||||
// --- Effect: Destructs the object
|
||||
|
||||
BOOL Open(const COXSerialCommConfig& config, COXSerialCommException* pException = NULL);
|
||||
// --- In: config: the configurations of the serial communication device to open
|
||||
// pException:
|
||||
// --- Out: none
|
||||
// --- Returns: if the opening was successful
|
||||
// --- Effect: opens the serial communication device configured in the config struct.
|
||||
|
||||
virtual void Close();
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: none
|
||||
// --- Effect: closes this serial comunication device
|
||||
|
||||
BOOL SetTimeouts(DWORD dwRxTimeout=5000, DWORD dwTxTimeout=5000); // time in milliseconds
|
||||
// --- In: dwRxTimeout:
|
||||
// dwTxTimeout:
|
||||
// --- Out: none
|
||||
// --- Returns: if ot was successful or not
|
||||
// --- Effect: sets the time-out parameters for all read and write operations on this serial
|
||||
// communications device.
|
||||
|
||||
BOOL IsOpen() const;
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: if the port is already opened or not
|
||||
// --- Effect: none
|
||||
|
||||
UINT Read( void* lpBuf, UINT nCount );
|
||||
// --- In: none
|
||||
// --- Out: lpBuf: reserved memory block to receive data
|
||||
// nCount: size of the reserved buffer
|
||||
// --- Returns: actual number of bytes received
|
||||
// --- Effect:
|
||||
|
||||
void Write( const void* lpBuf, UINT nCount );
|
||||
// --- In: lpBuf: address of data block to transmit
|
||||
// nCount: number of bytes to transmit
|
||||
// --- Out: none
|
||||
// --- Returns: none
|
||||
// --- Effect: transmits the data to the serial port
|
||||
|
||||
void PurgeRx();
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: none
|
||||
// --- Effect: makes the receive queue empty
|
||||
|
||||
void PurgeTx();
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: none
|
||||
// --- Effect: makes the transmit queue empty
|
||||
|
||||
BOOL IsRxQueueEmpty() const;
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: if the Receive queue is empty or not
|
||||
// --- Effect: none
|
||||
|
||||
BOOL IsTxQueueEmpty() const;
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: if the Transmit queue is empty or not
|
||||
// --- Effect: none
|
||||
|
||||
void SetDTR(BOOL bValue);
|
||||
// --- In: bValue: new value of the DTR flag
|
||||
// --- Out: none
|
||||
// --- Returns: none
|
||||
// --- Effect: Sets the handshake signal 'DTR' (data terminal ready )
|
||||
|
||||
void SetRTS(BOOL bValue);
|
||||
// --- In: bValue: new value of the RTS flag
|
||||
// --- Out: none
|
||||
// --- Returns: none
|
||||
// --- Effect: Sets the handshake signal 'RDSR' (request to send)
|
||||
|
||||
BOOL GetCTS() const;
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: the state of the 'CTS' (clear to send) flag
|
||||
// --- Effect: none
|
||||
|
||||
BOOL GetDSR() const;
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: the state of the 'DSR' (data set ready) flag
|
||||
// --- Effect: none
|
||||
|
||||
BOOL GetCD() const;
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: the state of the 'CD' (carrier detect) flag
|
||||
// --- Effect: none
|
||||
|
||||
BOOL GetRI() const;
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: the state of the 'RI' (ring indicator) flag
|
||||
// --- Effect: none
|
||||
|
||||
HANDLE GetSafeHandle() const;
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: a HANDLE to the COMM Device or NULL if no open handle exists
|
||||
// --- Effect:
|
||||
// --- Note: You may call this function on a non-attached COMM device. It will
|
||||
// return NULL.
|
||||
|
||||
BOOL SetCommMask(const DWORD dwEventMask);
|
||||
// --- In: dwEventMask: Specifies the events to be enabled. A value of zero
|
||||
// disables all events. The below table summarizes the
|
||||
// possible values for dwEventMask, you may combine these
|
||||
// using the bit-wise OR operator.
|
||||
//
|
||||
// Value Meaning
|
||||
// --------------------------------------------------------------------
|
||||
// EV_BREAK A break was detected on input.
|
||||
// EV_CTS The CTS (clear-to-send) signal changed state.
|
||||
// EV_DSR The DSR (data-set-ready) signal changed state.
|
||||
// EV_ERR A line-status error occurred. Line-status errors are CE_FRAME,
|
||||
// CE_OVERRUN, and CE_RXPARITY.
|
||||
// EV_RING A ring indicator was detected.
|
||||
// EV_RLSD The RLSD (receive-line-signal-detect) signal changed state.
|
||||
// EV_RXCHAR A character was received and placed in the input buffer.
|
||||
// EV_RXFLAG The event character was received and placed in the input
|
||||
// buffer. The event character is specified in the device's
|
||||
// DCB structure, which is applied to a serial port by using
|
||||
// the SetCommState function.
|
||||
// EV_TXEMPTY The last character in the output buffer was sent.
|
||||
//
|
||||
// --- Out: none
|
||||
// --- Returns: If the function succeeds, the return value is nonzero. Otherwise it is zero.
|
||||
// --- Effect: The SetCommMask function specifies the set of events that can be monitored
|
||||
// for a particular communications resource.
|
||||
|
||||
BOOL GetCommMask(DWORD& dwEventMask) const;
|
||||
// --- In: dwEventMask: a reference to a DWORD value to receive the event mask
|
||||
// --- Out: dwEventMask: this value receives the event mask
|
||||
// (see COXSerialCommFile::SetCommMask for more information)
|
||||
// --- Returns: If the function succeeds, the return value is nonzero. Otherwise it is zero.
|
||||
// --- Effect: none
|
||||
|
||||
BOOL GetCommProperties(LPCOMMPROP lpCommProp) const;
|
||||
// --- In: lpCommProp: address of communications properties structure
|
||||
// --- Out: lpCommProp: Pointer to a COMMPROP structure in which the
|
||||
// communications properties information is returned
|
||||
// --- Returns: If the function succeeds, the return value is nonzero. Otherwise it is zero.
|
||||
// --- Effect: The GetCommProperties function returns information from a device driver
|
||||
// about the configuration settings that are supported by the driver
|
||||
|
||||
UINT GetBytesToRead() const;
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: Number of bytes waiting to be read from the COMM port, 0 if none.
|
||||
// --- Effect: none
|
||||
|
||||
UINT GetBytesToWrite() const;
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: Number of bytes waiting to be sent to the COMM port, 0 if none.
|
||||
// --- Effect: none
|
||||
|
||||
protected:
|
||||
COXSerialCommException::VALUE GetCommException(COMSTAT& comstat) const;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
inline BOOL COXSerialCommFile::IsOpen() const
|
||||
{
|
||||
return GetSafeHandle() != NULL;
|
||||
}
|
||||
|
||||
inline HANDLE COXSerialCommFile::GetSafeHandle() const
|
||||
{
|
||||
return this == NULL ? NULL : m_hCommDevice;
|
||||
}
|
||||
|
||||
#endif // __OXSCFILE_H_
|
||||
@ -0,0 +1,112 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXSerialCommSetup
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXSCSTP.H
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Is derived from CDialog
|
||||
// YES Two stage creation (constructor & Initialize())
|
||||
// YES Has a message map
|
||||
// YES Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// YES Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Description :
|
||||
// COXSerialCommSetup class
|
||||
// The COXSerialCommSetup is a standard dialog for setting the Serial
|
||||
// Communication Configuration settings. This dialog can be popped up
|
||||
// with the DoConfigDialog() function of the COXSerialCommConfig class.
|
||||
|
||||
// Remark:
|
||||
//
|
||||
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __OXSCSTP_H_
|
||||
#define __OXSCSTP_H_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
#include "OXSCCFG.H"
|
||||
|
||||
// private header
|
||||
#include "OXRSERCM.H"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
class OX_CLASS_DECL COXSerialCommSetup : public CDialog
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
{
|
||||
// Data Members
|
||||
public:
|
||||
const CString m_sCommTitle;
|
||||
COXSerialCommConfig m_config;
|
||||
|
||||
//{{AFX_DATA(COXSerialCommSetup)
|
||||
enum { IDD = IDD_COMMSETUP };
|
||||
CString m_sBaudRate;
|
||||
CString m_sDataBit;
|
||||
CString m_sParity;
|
||||
CString m_sPort;
|
||||
CString m_sStopBit;
|
||||
CString m_sFlowControl;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
// Member Functions
|
||||
public:
|
||||
COXSerialCommSetup(CString sTitle = _T(""), CWnd* pParent = NULL);
|
||||
// --- In: sTitle: the title of the dialog box (used default title if ignored)
|
||||
// pParent: parent window
|
||||
// --- Out: none
|
||||
// --- Returns: none
|
||||
// --- Effect: constructs the dialog object
|
||||
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(COXSerialCommSetup)
|
||||
virtual BOOL OnInitDialog();
|
||||
virtual void OnOK();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
CString BaudRateToString(UINT Val);
|
||||
CString ParityToString(BYTE Val);
|
||||
CString FlowControlToString(COXSerialCommConfig::EFlowControl eVal);
|
||||
UINT BaudRateToVal(CString sString);
|
||||
BYTE ParityToVal(CString sString);
|
||||
COXSerialCommConfig::EFlowControl FlowControlToVal(CString sString);
|
||||
private:
|
||||
|
||||
};
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif //__OXSCSTP_H_
|
||||
@ -0,0 +1,292 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXSEHException
|
||||
// ==========================================================================
|
||||
|
||||
// Header File : OXSEH.h
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from CException
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// YES Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// This class is a C++ wrapper around Structured Exception Handling.
|
||||
// SEH-exceptions that are thrown can now be catched using the
|
||||
// C++ try - catch statements or by the MFC TRY - CATCH macros
|
||||
|
||||
// Remark:
|
||||
// Call the function EnableSEHTrapping() to enable this exception wrapper
|
||||
// All SEH exceptions are from that point onwwards translated to a
|
||||
// COXSEHException* exception.
|
||||
// The original exception code can be retrieved by calling the member function
|
||||
// GetCause()
|
||||
|
||||
// Example
|
||||
|
||||
// COXSEHException::EnableSEHTrapping();
|
||||
// TRY
|
||||
// {
|
||||
// int x = 1;
|
||||
// x = x / 0;
|
||||
// }
|
||||
// CATCH(COXSEHException, px)
|
||||
// {
|
||||
// if (pe->GetCause() == EXCEPTION_INT_DIVIDE_BY_ZERO)
|
||||
// ::AfxMessageBox(_T("Integer divide by zero trapped with TRY, CATCH"));
|
||||
// }
|
||||
// END_CATCH
|
||||
|
||||
// COXSEHException::EnableSEHTrapping();
|
||||
// try
|
||||
// {
|
||||
// int x = 1;
|
||||
// x = x / 0;
|
||||
// }
|
||||
// catch(COXSEHException* px)
|
||||
// {
|
||||
// if (pe->GetCause() == EXCEPTION_INT_DIVIDE_BY_ZERO)
|
||||
// ::AfxMessageBox(_T("Integer divide by zero trapped with try, catch"));
|
||||
// px->Delete();
|
||||
// }
|
||||
|
||||
// Note that all settings are organized on a per-thread base. So functions such as
|
||||
// EnableSEHTrapping() will enable trapping in the current thread.
|
||||
// If you are building a multi-threaded application and you want to trap all
|
||||
// exceptions, you should call EnableSEHTrapping() from within every thread
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
// This wrapper works only in WIN32 because WIN16 does not support SEH
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef __SEHEXCPT_H__
|
||||
#define __SEHEXCPT_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
#include <eh.h> // For _set_se_translator
|
||||
|
||||
// If you do not want to trap Floating Point exceptions, define OXSEH_USE_FP as 0
|
||||
#ifndef OXSEH_USE_FP
|
||||
#define OXSEH_USE_FP 1
|
||||
#endif //OXSEH_USE_FP
|
||||
|
||||
#if (0 < OXSEH_USE_FP)
|
||||
#include <float.h>
|
||||
#endif // (0 < OXSEH_USE_FP)
|
||||
|
||||
|
||||
class OX_CLASS_DECL COXSEHException : public CException
|
||||
{
|
||||
DECLARE_DYNAMIC(COXSEHException)
|
||||
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
|
||||
protected:
|
||||
_EXCEPTION_POINTERS* m_pEP;
|
||||
|
||||
typedef void (__cdecl *_se_translator_function)( unsigned int, _EXCEPTION_POINTERS*);
|
||||
class OX_CLASS_DECL COXSEHState : public CNoTrackObject
|
||||
{
|
||||
public:
|
||||
BOOL m_bSEHTrapping;
|
||||
BOOL m_bFPTrapping;
|
||||
unsigned int m_nPreviousFPControl;
|
||||
unsigned int m_nFPControlMask;
|
||||
_se_translator_function m_pfPreviousTranslator;
|
||||
|
||||
COXSEHState()
|
||||
:
|
||||
m_bSEHTrapping(FALSE),
|
||||
m_bFPTrapping(FALSE),
|
||||
m_nPreviousFPControl(0),
|
||||
#if (0 < OXSEH_USE_FP)
|
||||
m_nFPControlMask(_EM_ZERODIVIDE | _EM_INVALID | _EM_DENORMAL | _EM_OVERFLOW | _EM_UNDERFLOW | _EM_INEXACT),
|
||||
#else
|
||||
m_nFPControlMask(0),
|
||||
#endif // (0 < OXSEH_USE_FP)
|
||||
m_pfPreviousTranslator(0)
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
static CThreadLocal<COXSEHState> m_pSEHState;
|
||||
|
||||
private:
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
static void EnableSEHTrapping(BOOL bTrapFP = FALSE);
|
||||
// --- In : bTrapFP : Whether floating point exceptions should be trapped as well
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Start the mapping of SEH to C++ exceptions;
|
||||
|
||||
static void DisableSEHTrapping();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Stops the mapping of SEH to C++ exceptions;
|
||||
// EnableSEHTrapping() must have been called previously
|
||||
|
||||
static BOOL IsSEHTrappingEnabled();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : Whether the mapping of SEH to C++ exceptions is enabled
|
||||
// --- Effect :
|
||||
|
||||
static BOOL IsSEHFPTrappingEnabled();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : Whether FP exception will be trapped
|
||||
// --- Effect :
|
||||
|
||||
COXSEHException(_EXCEPTION_POINTERS* pEP = NULL);
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Contructor of object
|
||||
// It will initialize the internal state
|
||||
|
||||
UINT GetCause();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The cause why the exception was thrown.
|
||||
// It is the code used by SEH (e.g. EXCEPTION_ACCESS_VIOLATION)
|
||||
// See <winbase.h> for possible codes
|
||||
// --- Effect :
|
||||
|
||||
#ifdef _DEBUG
|
||||
virtual void Dump(CDumpContext&) const;
|
||||
virtual void AssertValid() const;
|
||||
#endif //_DEBUG
|
||||
|
||||
|
||||
virtual ~COXSEHException();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of object
|
||||
|
||||
protected:
|
||||
static void __cdecl MapSEHToCPPExceptions(UINT uCode, _EXCEPTION_POINTERS* pep);
|
||||
|
||||
private:
|
||||
|
||||
// Message handlers ---------------------------------------------------------
|
||||
|
||||
};
|
||||
|
||||
class OX_CLASS_DECL COXSEHMemoryException : public COXSEHException
|
||||
{
|
||||
DECLARE_DYNAMIC(COXSEHMemoryException)
|
||||
// Data members -------------------------------------------------------------
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
COXSEHMemoryException(_EXCEPTION_POINTERS* pEP = NULL);
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Contructor of object
|
||||
// It will initialize the internal state
|
||||
|
||||
BOOL IsInfoAvailable();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : Whether extra information is available
|
||||
// (Read/Write flag and virtual memory address)
|
||||
// --- Effect :
|
||||
|
||||
BOOL GetReadWriteFlag();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : Whether the exception occurred when trying to read (FALSE)
|
||||
// or to write (TRUE) to a virtual memory address
|
||||
// --- Effect : Be sure that IsInfoAvailable() == TRUE
|
||||
|
||||
DWORD GetAddress();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : Get the virtual memory address that resulted in an exception
|
||||
// --- Effect :
|
||||
// --- Effect : Be sure that IsInfoAvailable() == TRUE
|
||||
|
||||
#ifdef _DEBUG
|
||||
virtual void Dump(CDumpContext&) const;
|
||||
virtual void AssertValid() const;
|
||||
#endif //_DEBUG
|
||||
|
||||
virtual ~COXSEHMemoryException();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of object
|
||||
};
|
||||
|
||||
class OX_CLASS_DECL COXSEHMathException : public COXSEHException
|
||||
{
|
||||
DECLARE_DYNAMIC(COXSEHMathException)
|
||||
// Data members -------------------------------------------------------------
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
COXSEHMathException(_EXCEPTION_POINTERS* pEP = NULL);
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Contructor of object
|
||||
// It will initialize the internal state
|
||||
|
||||
#ifdef _DEBUG
|
||||
virtual void Dump(CDumpContext&) const;
|
||||
virtual void AssertValid() const;
|
||||
#endif //_DEBUG
|
||||
|
||||
virtual ~COXSEHMathException();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of object
|
||||
};
|
||||
|
||||
class OX_CLASS_DECL COXSEHSpecialException : public COXSEHException
|
||||
{
|
||||
DECLARE_DYNAMIC(COXSEHSpecialException)
|
||||
// Data members -------------------------------------------------------------
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
COXSEHSpecialException(_EXCEPTION_POINTERS* pEP = NULL);
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Contructor of object
|
||||
// It will initialize the internal state
|
||||
|
||||
#ifdef _DEBUG
|
||||
virtual void Dump(CDumpContext&) const;
|
||||
virtual void AssertValid() const;
|
||||
#endif //_DEBUG
|
||||
|
||||
virtual ~COXSEHSpecialException();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of object
|
||||
};
|
||||
|
||||
#endif
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,5 @@
|
||||
#include "OXSCFILE.H"
|
||||
#include "OXSCEXCP.H"
|
||||
#include "OXSCSTP.H"
|
||||
#include "OXSCCFG.H"
|
||||
#include "OXSCFILE.H"
|
||||
@ -0,0 +1,257 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#ifndef _OXSerCom_RC__
|
||||
#define _OXSerCom_RC__
|
||||
|
||||
#include "OXRSERCM.H"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"OXRSERCM.H\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_COMMSETUP DIALOG DISCARDABLE 0, 0, 163, 107
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Serial Comm Setup"
|
||||
FONT 8, "Helv"
|
||||
BEGIN
|
||||
LTEXT "&Port:",-1,6,9,17,8
|
||||
COMBOBOX IDC_PORT,45,7,48,50,CBS_DROPDOWNLIST | CBS_HASSTRINGS |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "&Baud Rate:",-1,6,24,38,8,NOT WS_GROUP
|
||||
COMBOBOX IDC_BAUDRATE,45,22,48,84,CBS_DROPDOWNLIST |
|
||||
CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "&Data Bits:",-1,6,39,34,8,NOT WS_GROUP
|
||||
COMBOBOX IDC_DATABIT,45,37,48,57,CBS_DROPDOWNLIST |
|
||||
CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "P&arity:",-1,6,54,22,8,NOT WS_GROUP
|
||||
COMBOBOX IDC_PARITY,45,52,48,57,CBS_DROPDOWNLIST | CBS_HASSTRINGS |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "&Stop Bits:",-1,6,69,33,8,NOT WS_GROUP
|
||||
COMBOBOX IDC_STOPBIT,45,67,48,33,CBS_DROPDOWNLIST |
|
||||
CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
|
||||
DEFPUSHBUTTON "&Ok",IDOK,107,6,50,14
|
||||
PUSHBUTTON "&Cancel",IDCANCEL,107,23,50,14
|
||||
LTEXT "&Flow Ctrl:",-1,6,84,33,8,NOT WS_GROUP
|
||||
COMBOBOX IDC_FLOWCONTROL,45,82,48,42,CBS_DROPDOWNLIST |
|
||||
CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog Info
|
||||
//
|
||||
|
||||
IDD_COMMSETUP DLGINIT
|
||||
BEGIN
|
||||
IDC_PORT, 0x403, 6, 0
|
||||
0x6f43, 0x206d, 0x0031,
|
||||
IDC_PORT, 0x403, 6, 0
|
||||
0x6f43, 0x206d, 0x0032,
|
||||
IDC_PORT, 0x403, 6, 0
|
||||
0x6f43, 0x206d, 0x0033,
|
||||
IDC_PORT, 0x403, 6, 0
|
||||
0x6f43, 0x206d, 0x0034,
|
||||
IDC_PORT, 0x403, 6, 0
|
||||
0x6f43, 0x206d, 0x0035,
|
||||
IDC_PORT, 0x403, 6, 0
|
||||
0x6f43, 0x206d, 0x0036,
|
||||
IDC_PORT, 0x403, 6, 0
|
||||
0x6f43, 0x206d, 0x0037,
|
||||
IDC_PORT, 0x403, 6, 0
|
||||
0x6f43, 0x206d, 0x0038,
|
||||
IDC_PORT, 0x403, 6, 0
|
||||
0x6f43, 0x206d, 0x0039,
|
||||
IDC_BAUDRATE, 0x403, 4, 0
|
||||
0x3131, 0x0030,
|
||||
IDC_BAUDRATE, 0x403, 4, 0
|
||||
0x3033, 0x0030,
|
||||
IDC_BAUDRATE, 0x403, 4, 0
|
||||
0x3036, 0x0030,
|
||||
IDC_BAUDRATE, 0x403, 5, 0
|
||||
0x3231, 0x3030, "\000"
|
||||
IDC_BAUDRATE, 0x403, 5, 0
|
||||
0x3432, 0x3030, "\000"
|
||||
IDC_BAUDRATE, 0x403, 5, 0
|
||||
0x3834, 0x3030, "\000"
|
||||
IDC_BAUDRATE, 0x403, 5, 0
|
||||
0x3639, 0x3030, "\000"
|
||||
IDC_BAUDRATE, 0x403, 6, 0
|
||||
0x3431, 0x3034, 0x0030,
|
||||
IDC_BAUDRATE, 0x403, 6, 0
|
||||
0x3931, 0x3032, 0x0030,
|
||||
IDC_BAUDRATE, 0x403, 6, 0
|
||||
0x3833, 0x3034, 0x0030,
|
||||
IDC_BAUDRATE, 0x403, 6, 0
|
||||
0x3735, 0x3036, 0x0030,
|
||||
IDC_BAUDRATE, 0x403, 7, 0
|
||||
0x3131, 0x3235, 0x3030, "\000"
|
||||
IDC_DATABIT, 0x403, 2, 0
|
||||
0x0034,
|
||||
IDC_DATABIT, 0x403, 2, 0
|
||||
0x0035,
|
||||
IDC_DATABIT, 0x403, 2, 0
|
||||
0x0036,
|
||||
IDC_DATABIT, 0x403, 2, 0
|
||||
0x0037,
|
||||
IDC_DATABIT, 0x403, 2, 0
|
||||
0x0038,
|
||||
IDC_PARITY, 0x403, 5, 0
|
||||
0x7645, 0x6e65, "\000"
|
||||
IDC_PARITY, 0x403, 4, 0
|
||||
0x644f, 0x0064,
|
||||
IDC_PARITY, 0x403, 10, 0
|
||||
0x6f4e, 0x5020, 0x7261, 0x7469, 0x0079,
|
||||
IDC_PARITY, 0x403, 5, 0
|
||||
0x614d, 0x6b72, "\000"
|
||||
IDC_PARITY, 0x403, 6, 0
|
||||
0x7053, 0x6361, 0x0065,
|
||||
IDC_STOPBIT, 0x403, 2, 0
|
||||
0x0031,
|
||||
IDC_STOPBIT, 0x403, 2, 0
|
||||
0x0032,
|
||||
IDC_FLOWCONTROL, 0x403, 5, 0
|
||||
0x6f4e, 0x656e, "\000"
|
||||
IDC_FLOWCONTROL, 0x403, 9, 0
|
||||
0x6148, 0x6472, 0x6177, 0x6572, "\000"
|
||||
IDC_FLOWCONTROL, 0x403, 11, 0
|
||||
0x6f58, 0x206e, 0x202f, 0x6f58, 0x6666, "\000"
|
||||
0
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_DEFAULT_TITLE "General Purpose Comm. Handler"
|
||||
IDS_MSG_DEFAULT_CONFIG "%s:\nConfiguration file not found.\nDefault Parameters Assumed."
|
||||
IDS_MSG_BAD_CONFIG "%s:\nError loading the parameters file.\nDefault Parameters Assumed."
|
||||
IDS_MSG_NO_SAVE "%s:\nError saving the parameters file."
|
||||
IDS_MSG_NO_PORT_AVAILABLE
|
||||
"The selected COM port is either not supported\nor is being used by another application.\nPlease select another port."
|
||||
IDS_MSG_PORT_UNAVAILABLE
|
||||
"%s:\nFailed to open the communication device.\nThe configurated COM port is either not supported\nor is being used by another application."
|
||||
IDS_SERIAL_NONAME "Unknown Name"
|
||||
IDS_SERIAL_NONE "No Error"
|
||||
IDS_SERIAL_NOT_AVAILABLE
|
||||
"%1:\nThe selected COM port is either not supported\nor is being used by another application.\nPlease select another port."
|
||||
IDS_SERIAL_BREAK_DETECT "%1:\nBreak Detect !"
|
||||
IDS_SERIAL_RX_TIMEOUT "%1:\nRx Timeout !"
|
||||
IDS_SERIAL_CTS_TIMEOUT "%1:\nClear To Send Timeout !"
|
||||
IDS_SERIAL_DSR_TIMEOUT "%1:\nData Set Ready Timeout !"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_SERIAL_CD_TIMEOUT "%1:\nCarrier Detect Timeout !"
|
||||
IDS_SERIAL_FRAME_ERROR "%1:\nFrame Error !"
|
||||
IDS_SERIAL_PARITY_ERROR "%1:\nParity Error !"
|
||||
IDS_SERIAL_OVERRUN_ERROR "%1:\nOverrun Error !"
|
||||
IDS_SERIAL_RX_QUEUE_OVERFLOW "%1:\nRx Buffer Overflow !"
|
||||
IDS_SERIAL_TX_QUEUE_FULL "%1:\nTx Buffer Full !"
|
||||
IDS_SERIAL_WM_QUIT_RECEIVED "%1:\nUnexpected WM_QUIT received !"
|
||||
IDS_SERIAL_IO_ERROR "%1:\nI/O Error !"
|
||||
IDS_SERIAL_MODE_ERROR "%1:\nMode Error ! (request mode not supported)"
|
||||
IDS_SERIAL_UNKNOWN_ERROR "%1:\nUnknown Error !"
|
||||
IDS_SERIAL_LOST_MESSAGES
|
||||
"FATAL ERROR!\nThe Windows message queue is full!\nSerial Comm messages lost!\nIncrease the message queue depth."
|
||||
IDS_DEFAULTFILE "unknown.cfg"
|
||||
IDS_110 "110"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_300 "300"
|
||||
IDS_600 "600"
|
||||
IDS_1200 "1200"
|
||||
IDS_2400 "2400"
|
||||
IDS_4800 "4800"
|
||||
IDS_9600 "9600"
|
||||
IDS_14400 "14400"
|
||||
IDS_19200 "19200"
|
||||
IDS_38400 "38400"
|
||||
IDS_56000 "56000"
|
||||
IDS_128000 "128000"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_256000 "256000"
|
||||
IDS_EVEN "Even"
|
||||
IDS_ODD "Odd"
|
||||
IDS_NOPARITY "No Parity"
|
||||
IDS_MARK "Mark"
|
||||
IDS_SPACE "Space"
|
||||
IDS_NONE "None"
|
||||
IDS_HARDWARE "Hardware"
|
||||
IDS_XONXOFF "Xon / Xoff"
|
||||
IDS_NOTIMER_AVAIL "RS232 Driver Internal Error:\nNo timer available to handle the timeout function.\nSolution: close some other application and then restart this one."
|
||||
IDS_57600 "57600"
|
||||
IDS_115200 "115200"
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
#endif //_OXSerCom_RC__
|
||||
@ -0,0 +1,381 @@
|
||||
// ==========================================================================
|
||||
// Template Specification : COXSPtr
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXSPtr.h
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// NO Derived from
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// YES Uses exceptions
|
||||
// (CMemoryException by NULL-pointer dereference)
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// This class works together with CObject derived classesto provide
|
||||
// a solution for smart pointers and objects
|
||||
// All access to the object must be done through its smart pointer
|
||||
|
||||
// Normally construction of the object is done together with the
|
||||
// smart pointer. So when a smart pointer is constructed it also constructs
|
||||
// the object
|
||||
// When you specify NULL as parameter when construcing a smart pointer
|
||||
// it will not construct an object
|
||||
|
||||
// The lifetime of objects is ruled by reference counting
|
||||
// When no references to the object exists it will be deleted.
|
||||
// You can remove the reference to an object explicitely by assigning
|
||||
// NULL to the smart pointer
|
||||
// You can also construct a new object explicitely by assigning the special value
|
||||
// NEW_OBJECT to it.
|
||||
|
||||
// Apart from construction and destruction everything that can be done with a
|
||||
// normal (dumb) pointer can also be done with a smart pointer
|
||||
|
||||
// Remark:
|
||||
// The runtime overhead of using a smart pointer instead of a dumb pointer
|
||||
// are very minimal
|
||||
// COXSPtr is a class with no base class and no virtual functions
|
||||
// The size of a smart pointer thus equals the size of its members :
|
||||
// two pointer (to the object and to the reference count).
|
||||
// All access functions of COXSPtr are inline and are very short.
|
||||
// E.g. operator-> just checks whether the pointer is not NULL
|
||||
// and returns it then
|
||||
// So computational overhead is minimal too.
|
||||
|
||||
// When you try to dereference a smart pointer that is NULL
|
||||
// a CMemoryException will be thrown (and in DEBUG the function will ASSERT)
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef __OXSPTR_H__
|
||||
#define __OXSPTR_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
|
||||
// Defining ENABLE_SMART_WRAPPER enables the possibility to wrap a smart pointer
|
||||
// around an existing object. The locking functions are also available then.
|
||||
// By default this is not defined and thus not enabled
|
||||
// #define ENABLE_SMART_WRAPPER 1
|
||||
|
||||
// Defining DISABLE_SMART_DOWNCAST_TEST disnables the runtime test when a
|
||||
// smart pointer is downcasted (from base class to derived class)
|
||||
// By default this is not defined and thus enabled
|
||||
// #define DISABLE_SMART_DOWNCAST_TEST 1
|
||||
|
||||
// Defining DISABLE_SMART_SERIALIZATION disnables the serialization functionality
|
||||
// of a smart pointer (and groups)
|
||||
// By default this is not defined and thus enabled
|
||||
// #define DISABLE_SMART_SERIALIZATION 1
|
||||
|
||||
// Defining DISABLE_SMART_CHECK disables the runtime checks during Debug
|
||||
// These checks include wrapping a smart pointer around an existing object,
|
||||
// a smart pointer around a steck based object and cyclic graphs.
|
||||
// By default this is not defined and thus enabled
|
||||
// #define DISABLE_SMART_CHECK 1
|
||||
|
||||
// Use special creator object (NEW_OBJECT) that can be used in the
|
||||
// constructor and assignment operator of a smart pointer
|
||||
// to construct a new object
|
||||
class OX_CLASS_DECL COXObjectCreator
|
||||
{
|
||||
// This class is only used to mark a special parameter
|
||||
// during construction or assignment of a smart pointer
|
||||
// No actual members are needed
|
||||
};
|
||||
extern OX_CLASS_DECL COXObjectCreator NEW_OBJECT;
|
||||
|
||||
template <class T> class OX_CLASS_DECL COXSPtr;
|
||||
#ifndef DISABLE_SMART_SERIALIZATION
|
||||
template <class T> CArchive& AFXAPI operator<<(CArchive& ar, const COXSPtr<T>& pSObj);
|
||||
template <class T> CArchive& AFXAPI operator>>(CArchive& ar, COXSPtr<T>& pSObj);
|
||||
#endif // DISABLE_SMART_SERIALIZATION
|
||||
|
||||
template <class T> class OX_CLASS_DECL COXSPtr
|
||||
{
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
protected:
|
||||
T* m_pSmartObject;
|
||||
LONG* m_pnReferenceCount;
|
||||
|
||||
private:
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
COXSPtr(const COXObjectCreator& objCreator = NEW_OBJECT);
|
||||
// --- In : objCreator : NEW_OBJECT : Creates a new object
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : This constructs a smart pointer and it also
|
||||
// creates the associated object
|
||||
// This is the default constructor
|
||||
// The only valid parameter is NEW_OBJECT
|
||||
|
||||
#ifndef ENABLE_SMART_WRAPPER
|
||||
COXSPtr(const COXObjectCreator* pNull);
|
||||
// --- In : pNull : NULL
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : This constructs a smart NULL pointer
|
||||
// The only valid parameter is NULL
|
||||
|
||||
#else
|
||||
|
||||
COXSPtr(T* pSObj);
|
||||
// --- In : pSObj : Pointer to the object
|
||||
// around which this smart pointer will be created
|
||||
// or NULL : Makes this a NULL-pointer
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : This constructs a smart pointer around an existing
|
||||
// object or constructs a smart NULL pointer
|
||||
// The object's lifetime is now decided by the smart pointer
|
||||
// You should not delete the object directly
|
||||
#endif // ENABLE_SMART_WRAPPER
|
||||
|
||||
COXSPtr(const COXSPtr& sPtr);
|
||||
// --- In : sPtr : The smart pointer to be copied
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Copy constructor
|
||||
|
||||
COXSPtr& operator=(const COXSPtr<T>& sPtr);
|
||||
// --- In : sPtr : A smart pointer
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Assignment operator
|
||||
|
||||
COXSPtr& operator=(const COXObjectCreator& objCreator);
|
||||
// --- In : objCreator : NEW_OBJECT
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Constructs a new object and assigns it to this smart pointer
|
||||
// The only valid parameter is NEW_OBJECT
|
||||
|
||||
#ifndef ENABLE_SMART_WRAPPER
|
||||
COXSPtr& operator=(const COXObjectCreator* pNull);
|
||||
// --- In : pNull : NULL
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Makes this smart pointer a smart NULL pointer
|
||||
// The only valid parameter is NULL
|
||||
|
||||
#else
|
||||
|
||||
COXSPtr& operator=(T* pSObj);
|
||||
// --- In : pSObj : A pointer to the object or NULL
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Assignment operator
|
||||
// If pSObj == NULL this smart pointer becomes a smart NULL pointer
|
||||
// The object's lifetime is now decided by the smart pointer
|
||||
// You should not delete the object directly
|
||||
#endif // ENABLE_SMART_WRAPPER
|
||||
|
||||
T& operator*() const;
|
||||
// throw(CMemoryException);
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The object pointed to
|
||||
// --- Effect : Dereference operator
|
||||
|
||||
T* operator->() const;
|
||||
// throw(CMemoryException);
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : Pointer to the object
|
||||
// --- Effect : Member operator
|
||||
|
||||
operator T*() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Conversion operator
|
||||
|
||||
BOOL operator!() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : Whether this pointer points to NULL (TRUE) or to
|
||||
// a valid object (FALSE)
|
||||
// --- Effect :
|
||||
|
||||
BOOL operator==(T* pSObj) const;
|
||||
// --- In : pSObj : Pointer to a smart element
|
||||
// --- Out :
|
||||
// --- Returns : Whether this pointer points to the specified
|
||||
// object
|
||||
// --- Effect :
|
||||
|
||||
BOOL operator!=(T* pSObj) const;
|
||||
// --- In : pSObj : Pointer to a smart element
|
||||
// --- Out :
|
||||
// --- Returns : Whether this pointer does not point to the specified
|
||||
// object
|
||||
// --- Effect :
|
||||
|
||||
#ifndef DISABLE_SMART_SERIALIZATION
|
||||
friend CArchive& AFXAPI operator<<(CArchive& ar, const COXSPtr<T>& pSObj);
|
||||
// --- In : ar : Archive to store the object in
|
||||
// pSObj : Object to store
|
||||
// --- Out :
|
||||
// --- Returns : The archive itself
|
||||
// --- Effect : This functions serializes the object wrapped by this smart pointer
|
||||
// Object I/O is pointer based to avoid added construction overhead and
|
||||
// to support polymorphism
|
||||
// Use the Serialize member function directly for embedded objects.
|
||||
|
||||
friend CArchive& AFXAPI operator>>(CArchive& ar, COXSPtr<T>& pSObj);
|
||||
// --- In : ar : Archive to load the object from
|
||||
// pSObj : Object pointer to load into
|
||||
// --- Out :
|
||||
// --- Returns : The archive itself
|
||||
// --- Effect : This functions serializes the object into this smart pointer
|
||||
// Object I/O is pointer based to avoid added construction overhead and
|
||||
// to support polymorphism
|
||||
// Use the Serialize member function directly for embedded objects.
|
||||
#endif // DISABLE_SMART_SERIALIZATION
|
||||
|
||||
COXSPtr& PolyAssign(T* pSObj, LONG* pnReferenceCount);
|
||||
// --- In : pSObj : Pointer to a T or T derived object
|
||||
// pnReferenceCount : Pointer to its reference count
|
||||
// --- Out :
|
||||
// --- Returns : A smart pointer wrapping the object
|
||||
// --- Effect : Assignment function, internally used for
|
||||
// polymorphic assignment
|
||||
// Do not call this function directly, use
|
||||
// the operator <<= instead
|
||||
|
||||
LONG* GetRefCountAddress() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The address of the reference count of the object
|
||||
// or NULL when smart null pointer
|
||||
// --- Effect : Helper function, internally used for polymorphic assignment
|
||||
// Do not call this function directly, use
|
||||
// the operator <<= instead
|
||||
|
||||
#ifdef ENABLE_SMART_WRAPPER
|
||||
// CAUTION : THE NEXT THREE FUNCTIONS ARE NOT INTENDED FOR NORMAL USE
|
||||
// THEY DISABLE A LOT OF IMPORTANT FUNCTIONALITY AND
|
||||
// SHOULD ONLY BE USED IN EXCEPTIONAL CIRCUMSTANCES
|
||||
|
||||
void Lock();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Locks all the smart pointers that point to the object
|
||||
// this smart pointer points to
|
||||
// Locking will disable automatic deletion when the
|
||||
// reference count reaches 0
|
||||
|
||||
void Unlock();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Unlocks all the smart pointers that point to the object
|
||||
// this smart pointer points to
|
||||
// Unlocking will re-enable automatic deletion when the
|
||||
// reference count reaches 0
|
||||
|
||||
BOOL IsLocked();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : Whether the smart pointer is locked or not
|
||||
// --- Effect :
|
||||
#endif // ENABLE_SMART_WRAPPER
|
||||
|
||||
#ifdef _DEBUG
|
||||
void AssertValid() const;
|
||||
#endif // _DEBUG
|
||||
|
||||
~COXSPtr();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : This destructs the pointer object
|
||||
|
||||
protected:
|
||||
LONG Grab();
|
||||
LONG Release();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
template <class BASE_T, class T>
|
||||
inline COXSPtr<BASE_T>& SmartUpCast(COXSPtr<BASE_T>& pBaseObj, const COXSPtr<T>& pObj)
|
||||
// --- In : pBaseObj : Smart pointer you want to assign to
|
||||
// pObj : Smart pointer being assigned
|
||||
// --- Out :
|
||||
// --- Returns : The smart pointer assigned to
|
||||
// --- Effect : This is the 'polymorphic assignemnt' operator
|
||||
// A smart pointer wrapping a T object can be assigned to a
|
||||
// smart pointer normally wrapping BASE_T object,
|
||||
// if T* could be assigned to BASE_T*
|
||||
// This means T must be derived from BASE_T
|
||||
{
|
||||
// The next line will generate a compiler error (cannot convert parameter 1 from ...)
|
||||
// if T (pObj) is not derived from BASE_T (pBaseObj)
|
||||
return pBaseObj.PolyAssign(pObj, pObj.GetRefCountAddress());
|
||||
};
|
||||
|
||||
template <class BASE_T, class T>
|
||||
inline COXSPtr<BASE_T>& operator<<=(COXSPtr<BASE_T>& pBaseObj, const COXSPtr<T>& pObj)
|
||||
{
|
||||
return SmartUpCast(pBaseObj, pObj);
|
||||
};
|
||||
|
||||
template <class BASE_T, class T>
|
||||
inline COXSPtr<T>& SmartDownCast(COXSPtr<T>& pObj, const COXSPtr<BASE_T>& pBaseObj)
|
||||
// --- In : pObj : Smart pointer you want to assign to
|
||||
// pBaseObj : Smart pointer being assigned
|
||||
// --- Out :
|
||||
// --- Returns : The smart pointer assigned to
|
||||
// --- Effect : This is the 'cast assignemnt' operator
|
||||
// A smart pointer wrapping a BASE_T object will be assigned to a
|
||||
// smart pointer wrapping a T object,
|
||||
// A runtime check will be performed, to check the validity
|
||||
// When an incorrect cast is performed a smart NULL pointer is returned
|
||||
{
|
||||
#ifndef DISABLE_SMART_DOWNCAST_TEST
|
||||
// The macro DYNAMIC_DOWNCAST does not work with templates, so we mimic that functionality
|
||||
// ... Build a (temporary T object) just to get to the runtime class
|
||||
COXSPtr<T> pDummyObj;
|
||||
if (pBaseObj != NULL && !pBaseObj->IsKindOf(pDummyObj->GetRuntimeClass()))
|
||||
{
|
||||
TRACE(_T("SmartDownCast (Cast assignment) returning smart NULL pointer\n"));
|
||||
return pObj.PolyAssign(NULL, NULL);
|
||||
}
|
||||
else
|
||||
#endif // DISABLE_SMART_DOWNCAST_TEST
|
||||
return pObj.PolyAssign((T*)(BASE_T*)pBaseObj, pBaseObj.GetRefCountAddress());
|
||||
};
|
||||
|
||||
template <class BASE_T, class T>
|
||||
inline COXSPtr<T>& operator>>=(COXSPtr<T>& pObj, const COXSPtr<BASE_T>& pBaseObj)
|
||||
{
|
||||
return SmartDownCast(pObj, pBaseObj);
|
||||
};
|
||||
|
||||
#include "OXSPtr.inl"
|
||||
|
||||
#endif // __OXSPTR_H__
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,517 @@
|
||||
// ==========================================================================
|
||||
// Template Implementation : COXSPtr
|
||||
// ==========================================================================
|
||||
|
||||
// Source file : OXSPtr.inl
|
||||
|
||||
// Source : R.Mortelmans
|
||||
// Creation Date : 19th December 1995
|
||||
// Last Modification : 23rd January 1996
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
// Definition of static members
|
||||
|
||||
#ifndef new
|
||||
#define new DEBUG_NEW
|
||||
#define _REMOVE_DEBUG_NEW
|
||||
#endif
|
||||
|
||||
#if defined(_DEBUG) && !defined(DISABLE_SMART_CHECK)
|
||||
#include "OXSWatcher.h"
|
||||
extern COXSmartWatcher smartWatcher;
|
||||
// We will use sizeof(*pObj) to get the size of the object pointed to by the smart pointer
|
||||
// This will not be correct when polymorhic assignment is used, but it's the best we can do
|
||||
#define REG_PTR_OBJ(pObj) smartWatcher.RegisterPointerAndObject(this, pObj, sizeof(*pObj))
|
||||
#define UNREG_OBJ(pObj) smartWatcher.UnRegisterObject(pObj)
|
||||
#define UNREG_PTR(pObj) smartWatcher.UnRegisterPointer(this, pObj)
|
||||
#define IS_REG_OBJ(pObj) smartWatcher.IsRegisteredObject(pObj)
|
||||
#else
|
||||
#define REG_PTR_OBJ(pObj)
|
||||
#define UNREG_OBJ(pObj)
|
||||
#define UNREG_PTR(pObj)
|
||||
#define IS_REG_OBJ(pObj) (FALSE)
|
||||
#endif // _DEBUG
|
||||
|
||||
// Use special ASSERT_VALID_SPTR macro to check the validity of a
|
||||
// smart pointer. Because COXSPtr is not derived from CObject the
|
||||
// normal ASSERT_VALID does not work
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define ASSERT_VALID_SPTR(pSPtr) (pSPtr)->AssertValid()
|
||||
#else
|
||||
#define ASSERT_VALID_SPTR(pSPtr)
|
||||
#endif // _DEBUG
|
||||
|
||||
// Data members -------------------------------------------------------------
|
||||
// protected:
|
||||
// T* m_pSmartObject;
|
||||
// --- Pointer to the object this smart pointer references
|
||||
// or NULL when the smart pointer does not point to anything
|
||||
|
||||
// LONG* m_pnReferenceCount;
|
||||
// --- Pointer to the reference count of the object pointed to
|
||||
// or NULL when the smart pointer does not point to anything
|
||||
// When the object is locked the reference count is a negative number
|
||||
|
||||
// private:
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
// public:
|
||||
|
||||
template <class T> inline COXSPtr<T>::COXSPtr(const COXObjectCreator& objCreator /* = NEW_OBJECT */)
|
||||
:
|
||||
m_pSmartObject(NULL),
|
||||
m_pnReferenceCount(NULL)
|
||||
{
|
||||
UNUSED(objCreator);
|
||||
ASSERT_VALID_SPTR(this);
|
||||
// ... May only be used to create a new object
|
||||
ASSERT(&objCreator == &NEW_OBJECT);
|
||||
|
||||
m_pSmartObject = new T;
|
||||
m_pnReferenceCount = new LONG(0);
|
||||
// ... Register new smart pointer (for debugging purposes only)
|
||||
Grab();
|
||||
|
||||
ASSERT_VALID_SPTR(this);
|
||||
}
|
||||
|
||||
#ifndef ENABLE_SMART_WRAPPER
|
||||
template <class T> inline COXSPtr<T>::COXSPtr(const COXObjectCreator* pNull)
|
||||
:
|
||||
m_pSmartObject(NULL),
|
||||
m_pnReferenceCount(NULL)
|
||||
{
|
||||
UNUSED(pNull);
|
||||
// ... May only assign NULL pointer
|
||||
ASSERT(pNull == NULL);
|
||||
ASSERT_VALID_SPTR(this);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template <class T> inline COXSPtr<T>::COXSPtr(T* pSObj)
|
||||
:
|
||||
m_pSmartObject(pSObj),
|
||||
m_pnReferenceCount(NULL)
|
||||
{
|
||||
// ... May only assign valid object
|
||||
ASSERT(pSObj == NULL || AfxIsValidAddress(pSObj, sizeof(T)));
|
||||
|
||||
if (pSObj != NULL)
|
||||
{
|
||||
m_pnReferenceCount = new LONG(0);
|
||||
// Make sure this object does not have another smart pointer wrapped
|
||||
// around it yet : For polymorhic assignemnt use SmartUpCast or operator<<=
|
||||
ASSERT(!IS_REG_OBJ(m_pSmartObject));
|
||||
// ... Register new smart pointer (for debugging purposes only)
|
||||
Grab();
|
||||
}
|
||||
|
||||
ASSERT_VALID_SPTR(this);
|
||||
}
|
||||
#endif // ENABLE_SMART_WRAPPER
|
||||
|
||||
template <class T> inline COXSPtr<T>::COXSPtr(const COXSPtr& sPtr)
|
||||
:
|
||||
m_pSmartObject(sPtr.m_pSmartObject),
|
||||
m_pnReferenceCount(sPtr.m_pnReferenceCount)
|
||||
{
|
||||
ASSERT_VALID_SPTR(&sPtr);
|
||||
ASSERT_VALID_SPTR(this);
|
||||
|
||||
if (m_pSmartObject != NULL)
|
||||
{
|
||||
// ... Should at least have one reference
|
||||
ASSERT(sPtr.m_pnReferenceCount != NULL);
|
||||
ASSERT(*sPtr.m_pnReferenceCount != 0);
|
||||
Grab();
|
||||
}
|
||||
|
||||
ASSERT_VALID_SPTR(this);
|
||||
}
|
||||
|
||||
template <class T> inline COXSPtr<T>& COXSPtr<T>::operator=(const COXSPtr<T>& sPtr)
|
||||
{
|
||||
ASSERT_VALID_SPTR(this);
|
||||
ASSERT_VALID_SPTR(&sPtr);
|
||||
|
||||
// ... Make sure that assigning the same smart element (a = a) works too
|
||||
if (m_pSmartObject != sPtr.m_pSmartObject)
|
||||
{
|
||||
if (m_pSmartObject != NULL)
|
||||
Release();
|
||||
m_pSmartObject = sPtr.m_pSmartObject;
|
||||
m_pnReferenceCount = NULL;
|
||||
if (m_pSmartObject != NULL)
|
||||
{
|
||||
// ... Should at least have one reference
|
||||
ASSERT(sPtr.m_pnReferenceCount != NULL);
|
||||
ASSERT(*sPtr.m_pnReferenceCount != 0);
|
||||
m_pnReferenceCount = sPtr.m_pnReferenceCount;
|
||||
Grab();
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT_VALID_SPTR(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T> inline COXSPtr<T>& COXSPtr<T>::operator=(const COXObjectCreator& objCreator)
|
||||
{
|
||||
ASSERT_VALID_SPTR(this);
|
||||
// ... May only be used to create a new object
|
||||
ASSERT(&objCreator == &NEW_OBJECT);
|
||||
|
||||
if (m_pSmartObject != NULL)
|
||||
Release();
|
||||
m_pSmartObject = new T;
|
||||
m_pnReferenceCount = new LONG(0);
|
||||
// ... Register new smart pointer (for debugging purposes only)
|
||||
Grab();
|
||||
|
||||
ASSERT_VALID_SPTR(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifndef ENABLE_SMART_WRAPPER
|
||||
template <class T> inline COXSPtr<T>& COXSPtr<T>::operator=(const COXObjectCreator* pNull)
|
||||
{
|
||||
UNUSED(pNull);
|
||||
ASSERT_VALID_SPTR(this);
|
||||
// ... May only assign smart NULL pointer
|
||||
ASSERT(pNull == NULL);
|
||||
|
||||
if (m_pSmartObject != NULL)
|
||||
Release();
|
||||
m_pSmartObject = NULL;
|
||||
|
||||
ASSERT_VALID_SPTR(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template <class T> inline COXSPtr<T>& COXSPtr<T>::operator=(T* pSObj)
|
||||
{
|
||||
ASSERT_VALID_SPTR(this);
|
||||
ASSERT(pSObj == NULL || AfxIsValidAddress(pSObj, sizeof(T)));
|
||||
|
||||
// ... Make sure that assigning the same smart element (a = a) works too
|
||||
if (m_pSmartObject != pSObj)
|
||||
{
|
||||
if (m_pSmartObject != NULL)
|
||||
Release();
|
||||
m_pSmartObject = pSObj;
|
||||
m_pnReferenceCount = NULL;
|
||||
if (m_pSmartObject != NULL)
|
||||
{
|
||||
m_pnReferenceCount = new LONG(0);
|
||||
// Make sure this object does not have another smart pointer wrapped
|
||||
// around it yet : For polymorhic assignemnt use SmartUpCast or operator<<=
|
||||
ASSERT(!IS_REG_OBJ(m_pSmartObject));
|
||||
// ... Register new smart pointer (for debugging purposes only)
|
||||
Grab();
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT_VALID_SPTR(this);
|
||||
return *this;
|
||||
}
|
||||
#endif // ENABLE_SMART_WRAPPER
|
||||
|
||||
template <class T> inline T& COXSPtr<T>::operator*() const
|
||||
{
|
||||
ASSERT_VALID_SPTR(this);
|
||||
if (m_pSmartObject == NULL)
|
||||
{
|
||||
TRACE(TEXT("COXSPtr<T>::operator* : Trying to dereference a NULL pointer, throwing memory exception\n"));
|
||||
ASSERT(FALSE);
|
||||
AfxThrowMemoryException();
|
||||
}
|
||||
return *m_pSmartObject;
|
||||
}
|
||||
|
||||
template <class T> inline T* COXSPtr<T>::operator->() const
|
||||
{
|
||||
ASSERT_VALID_SPTR(this);
|
||||
if (m_pSmartObject == NULL)
|
||||
{
|
||||
TRACE(TEXT("COXSPtr<T>::operator-> : Trying to dereference a NULL pointer, throwing memory exception\n"));
|
||||
ASSERT(FALSE);
|
||||
AfxThrowMemoryException();
|
||||
}
|
||||
return m_pSmartObject;
|
||||
}
|
||||
|
||||
template <class T> inline COXSPtr<T>::operator T*() const
|
||||
{
|
||||
ASSERT_VALID_SPTR(this);
|
||||
return m_pSmartObject;
|
||||
}
|
||||
|
||||
|
||||
template <class T> inline BOOL COXSPtr<T>::operator!() const
|
||||
{
|
||||
ASSERT_VALID_SPTR(this);
|
||||
return (m_pSmartObject == NULL);
|
||||
}
|
||||
|
||||
template <class T> inline BOOL COXSPtr<T>::operator==(T* pSObj) const
|
||||
{
|
||||
ASSERT_VALID_SPTR(this);
|
||||
return (m_pSmartObject == pSObj);
|
||||
}
|
||||
|
||||
template <class T> inline BOOL COXSPtr<T>::operator!=(T* pSObj) const
|
||||
{
|
||||
ASSERT_VALID_SPTR(this);
|
||||
return (m_pSmartObject != pSObj);
|
||||
}
|
||||
|
||||
#ifndef DISABLE_SMART_SERIALIZATION
|
||||
template <class T> inline CArchive& AFXAPI operator<<(CArchive& ar, const COXSPtr<T>& pSObj)
|
||||
{
|
||||
ASSERT_VALID_SPTR(&pSObj);
|
||||
// Let the object archive itself
|
||||
ar << pSObj.m_pSmartObject;
|
||||
return ar;
|
||||
}
|
||||
|
||||
template <class T> inline CArchive& AFXAPI operator>>(CArchive& ar, COXSPtr<T>& pSObj)
|
||||
{
|
||||
ASSERT_VALID_SPTR(&pSObj);
|
||||
T* pObj = NULL;
|
||||
|
||||
// Create an object dynamically when archiving
|
||||
ar >> pObj;
|
||||
|
||||
// Store the newly read object in this smart pointer
|
||||
if (pSObj.m_pSmartObject != NULL)
|
||||
pSObj.Release();
|
||||
pSObj.m_pSmartObject = pObj;
|
||||
pSObj.m_pnReferenceCount = NULL;
|
||||
|
||||
if (pSObj.m_pSmartObject != NULL)
|
||||
{
|
||||
pSObj.m_pnReferenceCount = new LONG(0);
|
||||
// ... Register new smart pointer (for debugging purposes only)
|
||||
pSObj.Grab();
|
||||
}
|
||||
|
||||
ASSERT_VALID_SPTR(&pSObj);
|
||||
|
||||
return ar;
|
||||
}
|
||||
#endif // DISABLE_SMART_SERIALIZATION
|
||||
|
||||
template <class T> inline COXSPtr<T>& COXSPtr<T>::PolyAssign(T* pSObj, LONG* pnReferenceCount)
|
||||
{
|
||||
ASSERT_VALID_SPTR(this);
|
||||
|
||||
// ... May only assign valid object
|
||||
ASSERT(pSObj == NULL || AfxIsValidAddress(pSObj, sizeof(T)));
|
||||
ASSERT(pnReferenceCount == NULL || AfxIsValidAddress(pnReferenceCount, sizeof(LONG)));
|
||||
|
||||
// ... Make sure that assigning the same smart element (a = a) works too
|
||||
if (m_pSmartObject != pSObj)
|
||||
{
|
||||
if (m_pSmartObject != NULL)
|
||||
Release();
|
||||
m_pSmartObject = pSObj;
|
||||
m_pnReferenceCount = NULL;
|
||||
if (m_pSmartObject != NULL)
|
||||
{
|
||||
// ... Should at least have one reference
|
||||
ASSERT(pnReferenceCount != NULL);
|
||||
ASSERT(*pnReferenceCount != 0);
|
||||
m_pnReferenceCount = pnReferenceCount;
|
||||
Grab();
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT_VALID_SPTR(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T> inline LONG* COXSPtr<T>::GetRefCountAddress() const
|
||||
{
|
||||
ASSERT_VALID_SPTR(this);
|
||||
return m_pnReferenceCount;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SMART_WRAPPER
|
||||
template <class T> inline void COXSPtr<T>::Lock()
|
||||
{
|
||||
ASSERT_VALID_SPTR(this);
|
||||
#ifdef _DEBUG
|
||||
if (m_pSmartObject == NULL)
|
||||
{
|
||||
ASSERT(m_pnReferenceCount == NULL);
|
||||
TRACE(TEXT("COXSPtr<T>::Lock : Trying to lock smart NULL pointer, ignoring\n"));
|
||||
}
|
||||
#endif // _DEBUG
|
||||
// Make reference count negative to mark a locked object
|
||||
if (m_pnReferenceCount != NULL && 0 < *m_pnReferenceCount)
|
||||
*m_pnReferenceCount = -*m_pnReferenceCount;
|
||||
ASSERT_VALID_SPTR(this);
|
||||
}
|
||||
|
||||
template <class T> inline void COXSPtr<T>::Unlock()
|
||||
{
|
||||
ASSERT_VALID_SPTR(this);
|
||||
#ifdef _DEBUG
|
||||
if (m_pSmartObject == NULL)
|
||||
{
|
||||
ASSERT(m_pnReferenceCount == NULL);
|
||||
TRACE(TEXT("COXSPtr<T>::Unlock : Trying to lock smart NULL pointer, ignoring\n"));
|
||||
}
|
||||
#endif // _DEBUG
|
||||
// Make reference count positive to mark an unlocked object
|
||||
if (m_pnReferenceCount != NULL && *m_pnReferenceCount < 0)
|
||||
*m_pnReferenceCount = -*m_pnReferenceCount;
|
||||
ASSERT_VALID_SPTR(this);
|
||||
}
|
||||
|
||||
template <class T> inline BOOL COXSPtr<T>::IsLocked()
|
||||
{
|
||||
ASSERT_VALID_SPTR(this);
|
||||
return (m_pnReferenceCount != NULL && *m_pnReferenceCount < 0);
|
||||
}
|
||||
#endif // ENABLE_SMART_WRAPPER
|
||||
|
||||
#ifdef _DEBUG
|
||||
template <class T> inline void COXSPtr<T>::AssertValid() const
|
||||
{
|
||||
ASSERT(this != NULL);
|
||||
ASSERT(AfxIsValidAddress(this, sizeof(COXSPtr<T>)));
|
||||
ASSERT(m_pSmartObject == NULL || AfxIsValidAddress(m_pSmartObject, sizeof(T)));
|
||||
|
||||
// Because thee next check has to many exceptions we skip it.
|
||||
/*
|
||||
#if defined(_INC_CRTDBG) && !defined(DISABLE_SMART_CHECK)
|
||||
// ... The next assert will fail if a block of memory was not allocated
|
||||
// on the local heap.
|
||||
// NEVER allocate objects for smart pointers on the STACK !!!
|
||||
// ... Because of polymorphic assignment we use _msize(m_pSmartObject) instead of sizeof(T)
|
||||
// ... NOTE : This test may also fail if a dynamically linked library (DLL)
|
||||
// contains a static link to the run-time library.
|
||||
// ... NOTE : If the object is not derived from CObject it will be allocated
|
||||
// as a _NORMAL_BLOCK instead of _CLIENT_BLOCK.
|
||||
// In this case you may recieve an assertion of the Debug Heap CRT library
|
||||
// (pHead->nBlockUse == nBlockUse). You may savely ignore this assert
|
||||
ASSERT(m_pSmartObject == NULL ||
|
||||
_CrtIsMemoryBlock((const void *)m_pSmartObject, _msize_dbg(m_pSmartObject, _CLIENT_BLOCK), NULL, NULL, NULL));
|
||||
#endif // _INC_CRTDBG
|
||||
*/
|
||||
ASSERT(m_pnReferenceCount == NULL || AfxIsValidAddress(m_pnReferenceCount, sizeof(LONG)));
|
||||
ASSERT( (m_pSmartObject == NULL && m_pnReferenceCount == NULL) ||
|
||||
(m_pSmartObject != NULL && m_pnReferenceCount != NULL) );
|
||||
ASSERT(m_pnReferenceCount == NULL || *m_pnReferenceCount != 0);
|
||||
#ifndef ENABLE_SMART_WRAPPER
|
||||
ASSERT(m_pnReferenceCount == NULL || 0 <= *m_pnReferenceCount);
|
||||
#endif // ENABLE_SMART_WRAPPER
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
template <class T> inline COXSPtr<T>::~COXSPtr()
|
||||
{
|
||||
ASSERT_VALID_SPTR(this);
|
||||
if (m_pSmartObject != NULL)
|
||||
Release();
|
||||
}
|
||||
|
||||
// protected:
|
||||
template <class T> inline LONG COXSPtr<T>::Grab()
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The reference count after Grab()
|
||||
// --- Effect : Increases the reference count by 1 for not locked objects
|
||||
// otherwise the reference count is decreased by 1
|
||||
{
|
||||
ASSERT(m_pnReferenceCount != NULL);
|
||||
REG_PTR_OBJ(m_pSmartObject);
|
||||
#ifndef ENABLE_SMART_WRAPPER
|
||||
ASSERT(0 <= *m_pnReferenceCount);
|
||||
(*m_pnReferenceCount)++;
|
||||
return *m_pnReferenceCount;
|
||||
#else
|
||||
if (0 <= *m_pnReferenceCount)
|
||||
{
|
||||
(*m_pnReferenceCount)++;
|
||||
return *m_pnReferenceCount;
|
||||
}
|
||||
else
|
||||
// Object is locked : use negative reference count
|
||||
{
|
||||
(*m_pnReferenceCount)--;
|
||||
// ... Always return a positive number
|
||||
return -*m_pnReferenceCount;
|
||||
}
|
||||
#endif // ENABLE_SMART_WRAPPER
|
||||
}
|
||||
|
||||
template <class T> inline LONG COXSPtr<T>::Release()
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The reference count after Release()
|
||||
// --- Effect : Decreases the reference count of non-locked objects by 1
|
||||
// for loked objects the reference count is increased by 1
|
||||
// Deletes the object and the reference count when 0 is reached
|
||||
{
|
||||
ASSERT_VALID_SPTR(this);
|
||||
ASSERT(m_pnReferenceCount != NULL);
|
||||
ASSERT(*m_pnReferenceCount != 0);
|
||||
|
||||
LONG nTempReferenceCount = 0;
|
||||
if (*m_pnReferenceCount == 1)
|
||||
{
|
||||
// ... Unregister smart pointer (for debugging purposes only)
|
||||
UNREG_OBJ(m_pSmartObject);
|
||||
// ... Object will be deleted and thus does not have to be reachable
|
||||
UNREG_PTR(NULL);
|
||||
delete m_pnReferenceCount;
|
||||
delete m_pSmartObject;
|
||||
}
|
||||
#ifndef ENABLE_SMART_WRAPPER
|
||||
else
|
||||
{
|
||||
ASSERT(0 < *m_pnReferenceCount);
|
||||
nTempReferenceCount = --(*m_pnReferenceCount);
|
||||
UNREG_PTR(m_pSmartObject);
|
||||
}
|
||||
#else
|
||||
else if (*m_pnReferenceCount == -1)
|
||||
{
|
||||
// Reference count of locked object reached 0, object NOT deleted
|
||||
// ... Unregister smart pointer (for debugging purposes only)
|
||||
UNREG_OBJ(m_pSmartObject);
|
||||
// ... Object will be deleted and thus does not have to be reachable
|
||||
UNREG_PTR(NULL);
|
||||
delete m_pnReferenceCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 <= *m_pnReferenceCount)
|
||||
nTempReferenceCount = --(*m_pnReferenceCount);
|
||||
else
|
||||
// ... Object is locked : use negative reference count
|
||||
// ... Always return a positive number
|
||||
nTempReferenceCount = -(++(*m_pnReferenceCount));
|
||||
UNREG_PTR(m_pSmartObject);
|
||||
}
|
||||
#endif // ENABLE_SMART_WRAPPER
|
||||
|
||||
m_pnReferenceCount = NULL;
|
||||
m_pSmartObject = NULL;
|
||||
return nTempReferenceCount;
|
||||
}
|
||||
|
||||
|
||||
// private:
|
||||
|
||||
#ifdef _REMOVE_DEBUG_NEW
|
||||
#undef new
|
||||
#undef _REMOVE_DEBUG_NEW
|
||||
#endif
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,130 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXSerializer
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXSRLZR.H
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// NO Is derived from CWnd
|
||||
// NO Two stage creation (constructor & Initialize())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// YES Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Description :
|
||||
// COXSerializer class
|
||||
// BOOL Initialize(LPCTSTR pFileName, CObject* pObject);
|
||||
// ---------------------------------------------------------
|
||||
// Set the filename that has to be serialized and its relative object.
|
||||
// return FALSE only if an invalid string pointer or a CObject derived
|
||||
// object pointer or a not serializable object is passed .
|
||||
// Initialize can be called anytime.
|
||||
//
|
||||
// BOOL Load(BOOL DisplayException = TRUE);
|
||||
// ----------------------------------------
|
||||
// Loads the object from the archive. The object and the file name
|
||||
// are to be set by the Initialize function.
|
||||
// DisplayException=FALSE: No messages by messagebox are displayed
|
||||
// return FALSE if this object was not initialized or a Exception was
|
||||
// encounterd. (see FileException,ArchiveException and MemoryException
|
||||
// public data member to obtains more informations)
|
||||
//
|
||||
// BOOL Save(BOOL DisplayException = TRUE);
|
||||
// ----------------------------------------------------
|
||||
// Store the object to the archive. The object and the file name
|
||||
// are to be set by the Initialize function.
|
||||
// DisplayException=FALSE: No messages by messagebox are displayed
|
||||
// return FALSE if this object was not initialized or a Exception was
|
||||
// encounterd. (see FileException,ArchiveException and MemoryException
|
||||
// public data member to obtains more informations)
|
||||
|
||||
// Remark:
|
||||
//
|
||||
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef __OXSRLZR_H__
|
||||
#define __OXSRLZR_H__
|
||||
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
|
||||
class OX_CLASS_DECL COXSerializer : public CObject
|
||||
{
|
||||
// Data Members
|
||||
public:
|
||||
CFileException m_fileException; // exceptions as data member
|
||||
CArchiveException m_archiveException; // if you chose not to display exceptions
|
||||
BOOL m_bMemoryException; // then you can check them via these members
|
||||
|
||||
protected:
|
||||
BOOL m_bInitialized; // if initialized or not
|
||||
CString m_sFileName; // the filename of the file to serialize from or to
|
||||
CObject* m_pObject; // the object to serialize
|
||||
|
||||
private:
|
||||
|
||||
// Member Functions
|
||||
public:
|
||||
COXSerializer();
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: none
|
||||
// --- Effect: constructs the object
|
||||
|
||||
virtual ~COXSerializer();
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: none
|
||||
// --- Effect: destructs the object
|
||||
|
||||
BOOL Initialize(CString sFileName, CObject* pObject);
|
||||
// --- In: sFileName: the filename of the file you want to serialize to or from
|
||||
// pObject: the parent object you want to serialize
|
||||
// --- Out: none
|
||||
// --- Returns: if the initialization was successful
|
||||
// --- Effect: initialize and checks if the object is serializable
|
||||
|
||||
BOOL Load(BOOL bDisplayException = TRUE);
|
||||
// --- In: bDisplayException: if the exception is reported
|
||||
// --- Out: none
|
||||
// --- Returns: if successful or not
|
||||
// --- Effect: loads the object (see initialize) from file
|
||||
|
||||
BOOL Save(BOOL bDisplayException = TRUE);
|
||||
// --- In: bDisplayException: if the exception is reported
|
||||
// --- Out: none
|
||||
// --- Returns: if successful or not
|
||||
// --- Effect: saves the object (see initialize) to file
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif // __SERIALIZE_ENH_H__
|
||||
|
||||
@ -0,0 +1,227 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXSendMail
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXSendMail.h
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from CObject
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// NO Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// The COXSendMail class is designed to send Mail from Windows NT service applications
|
||||
// like the Microsoft IIS server. The class has an extremely simple interface which
|
||||
// enables you to send mail with only 3 function calls.
|
||||
// The COXSendMail class is based on our MFC framework for extended MAPI (through
|
||||
// OLE Messaging). This framework provides 14 powerful classes which allow you to add
|
||||
// quickly and easily the ability to send and receive mail messages to your MFC application.
|
||||
// It also enables easy interaction with folders and address books. You can create
|
||||
// programmable messaging objects. The functionality of these objects can be used to build
|
||||
// workflow automation solutions.
|
||||
// You can add different kind of recipients (CC, BCC, distribution lists) and attachments
|
||||
// (binary, ole-objects) and send it to a MAPI compatible mail system (Exchange, Microsoft
|
||||
// Mail, Internet Mail, ...).
|
||||
//
|
||||
|
||||
// Remark:
|
||||
// If your NT service application logs on with a specific user account you must provide an
|
||||
// additional privilege for this account: the user-right "Restore Files and Directories" must
|
||||
// be granted. If the service uses the system account you have to impersonate a specific
|
||||
// user account if you send a message. For example, if you use the Microsoft IIS to call
|
||||
// your ISAPI extensions, the IIS will impersonate the anonymous WWW-account ‘USR_COMPUTER_NAME’
|
||||
// before calling your extension DLL.
|
||||
// You have to provide a suitable Profile for that user account. If MAPI logs on to a store or
|
||||
// transport provider it uses a MAPI profile which defines the providers to use.
|
||||
// Instantiate a COXSendMail object and call the Logon() function with the profile name and
|
||||
// password as parameters. Call the CreateMessage() function and add your recipients and attachments
|
||||
// with the AddRecipient() and AddAttachment() functions. Finally call the SendMessage() function
|
||||
// and you are done.
|
||||
//
|
||||
// *** There are two compile version of this class. One that uses our OXMapi framework (don't define
|
||||
// the OX_MAPI_DIRECT switch. And one that uses extended MAPI direct (use the #define OX_MAPI_DIRECT
|
||||
// switch.
|
||||
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __SENDMAIL_H__
|
||||
#define __SENDMAIL_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
|
||||
// See the *** remark section for the following switch
|
||||
//#define OX_MAPI_DIRECT
|
||||
|
||||
#ifndef OX_MAPI_DIRECT
|
||||
#include "oxmdisp.h"
|
||||
#else
|
||||
#include <mapix.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define CRecipientArray CArray<CMessage::SRecipient*, CMessage::SRecipient*>
|
||||
#define CAttachmentArray CArray<CMessage::SAttachment*, CMessage::SAttachment*>
|
||||
#define CInternRecipientArray CArray<SRecipient*, SRecipient*>
|
||||
#define CInternAttachmentArray CArray<SAttachment*, SAttachment*>
|
||||
|
||||
class OX_CLASS_DECL COXSendMail : public CObject
|
||||
{
|
||||
// Data Members
|
||||
public:
|
||||
enum ERecipientType
|
||||
{
|
||||
rtTO = 1,
|
||||
rtCC = 2,
|
||||
rtBCC = 3
|
||||
};
|
||||
enum EAttachmentType
|
||||
{
|
||||
atFileData = 1,
|
||||
atFileLink = 2,
|
||||
atOleObject = 3
|
||||
};
|
||||
class OX_CLASS_DECL CMessage
|
||||
{
|
||||
friend COXSendMail;
|
||||
// Data Members
|
||||
public:
|
||||
CString m_sSubject;
|
||||
CString m_sContent;
|
||||
|
||||
protected:
|
||||
struct SRecipient
|
||||
{
|
||||
CString sName;
|
||||
ERecipientType eType;
|
||||
};
|
||||
struct SAttachment
|
||||
{
|
||||
CString sPath;
|
||||
EAttachmentType eType;
|
||||
CString sOleDocument;
|
||||
};
|
||||
CInternRecipientArray m_recipients;
|
||||
CInternAttachmentArray m_attachments;
|
||||
|
||||
// Member Functions
|
||||
public:
|
||||
CMessage();
|
||||
virtual ~CMessage();
|
||||
void AddRecipient(CString sRecipient, ERecipientType eType);
|
||||
void AddAttachment(CString sAttachment, EAttachmentType eType, CString sOleDocument = _T(""));
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
CString m_sMAPIProfile;
|
||||
|
||||
#ifndef OX_MAPI_DIRECT
|
||||
COXMSession m_objSession;
|
||||
#endif
|
||||
|
||||
public:
|
||||
COXSendMail();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Contructor of object
|
||||
// It will initialize the internal state
|
||||
|
||||
virtual ~COXSendMail();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of object
|
||||
|
||||
BOOL Initialize(CString sProfileName, CString sPassword = _T(""));
|
||||
// --- In: sProfileName: name of the profile you want to log on with
|
||||
// sPassword: optional password to log on
|
||||
// --- Out: none
|
||||
// --- Returns: if successful or not
|
||||
// --- Effect: Logs on to the mail services defined in the given profile
|
||||
|
||||
BOOL IsInitialized();
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: if initialized or not
|
||||
// --- Effect: none
|
||||
|
||||
void Uninitialize();
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: none
|
||||
// --- Effect: logs off from the mail system and does some cleaning
|
||||
|
||||
CString GetProfile();
|
||||
// --- In: none
|
||||
// --- Out: none
|
||||
// --- Returns: if initialized the name of the profile
|
||||
// --- Effect: none
|
||||
|
||||
BOOL SendMessage(CMessage& message);
|
||||
// --- In: message: the message to send
|
||||
// --- Out: none
|
||||
// --- Returns: if message was send successful or not
|
||||
// --- Effect: sends the message
|
||||
|
||||
static CString GetReturnMsg(int nErr);
|
||||
// --- In: nErr: the error code returned by MAPI
|
||||
// --- Out: none
|
||||
// --- Returns: a description of the error message
|
||||
// --- Effect: none
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
// ******************************************************************
|
||||
// this is needed for the Extended MAPI alternative; see the *** remark section
|
||||
// ******************************************************************
|
||||
#ifdef OX_MAPI_DIRECT
|
||||
BOOL InitializeMessageStore();
|
||||
LPMESSAGE ComposeMessage(CMessage& message);
|
||||
HRESULT AddRecipients(LPMESSAGE pMessage, CRecipientArray& recipients);
|
||||
HRESULT AddAttachments(LPMESSAGE pMessage, CAttachmentArray& attachments);
|
||||
LPMAPISESSION m_pMAPISession;
|
||||
LPADRBOOK m_pAddressBook;
|
||||
LPENTRYID m_peidDefaultMDB;
|
||||
ULONG m_cbeidDefaultMDB;
|
||||
LPMDB m_pDefaultMDB;
|
||||
LPMAPIFOLDER m_pRootFolder;
|
||||
LPSTR m_szRecipient;
|
||||
ULONG m_uLogoffFlags;
|
||||
LPSTR m_szAttachData;
|
||||
#endif
|
||||
// ******************************************************************
|
||||
|
||||
};
|
||||
|
||||
#endif // __MAILTO_H__
|
||||
// ==========================================================================
|
||||
|
||||
@ -0,0 +1,114 @@
|
||||
#if !defined(_OXSSTATICMENUITEM_H__)
|
||||
#define _OXSSTATICMENUITEM_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
// OXStaticMenuItem.h : header file
|
||||
//
|
||||
|
||||
#include "OXHookWnd.h"
|
||||
#include "OXStaticText.h"
|
||||
#include "OXMainRes.h"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COXStaticMenuItem window
|
||||
|
||||
class OX_CLASS_DECL COXStaticMenuItem : public COXStaticText
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns:
|
||||
// --- Effect : Constructs the object
|
||||
COXStaticMenuItem();
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
protected:
|
||||
// flag specifies whether the mouse button is currently pressed in
|
||||
BOOL m_bPressedDown;
|
||||
// color of the text when item is active
|
||||
COLORREF m_clrActive;
|
||||
// color of the text when item is inactive
|
||||
COLORREF m_clrNormalText;
|
||||
|
||||
// helper object to spy for mouse entering and leaving events
|
||||
COXHookWnd m_MouseSpy;
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// --- In : clrText - text color in the inactive (normal) state
|
||||
// clrBack - background color
|
||||
// clrActive - text color in the active state
|
||||
// nFontHeight - text font height
|
||||
// nFontWeight - text font weight
|
||||
// sFontName - text font name
|
||||
// bEmboss - if TRUE then font will be drawn
|
||||
// with 3D effect
|
||||
// nHorzAlignment - horizontal alignment of the text
|
||||
// in the control
|
||||
// nVertAlignment - vertical alignment of the text
|
||||
// in the control
|
||||
// --- Out :
|
||||
// --- Returns:
|
||||
// --- Effect : Constructs the object
|
||||
void SetProperties(COLORREF clrText=::GetSysColor(COLOR_BTNTEXT),
|
||||
COLORREF clrBack=::GetSysColor(COLOR_BTNFACE),
|
||||
COLORREF clrActive=RGB(192,0,0), int nFontHeight=12,
|
||||
int nFontWeight=FW_NORMAL, CString sFontName=_T("MS Sans Serif"),
|
||||
BOOL bEmboss=TRUE, int nHorzAlignment=OX_ALIGNHORZ_LEFT,
|
||||
int nVertAlignment=OX_ALIGNVERT_CENTER);
|
||||
|
||||
|
||||
inline void SetActiveColor(COLORREF clrActive, BOOL bPrepareNow=FALSE)
|
||||
{
|
||||
m_clrActive=clrActive;
|
||||
if(m_MouseSpy.IsMouseOver())
|
||||
PrepareBitmap(bPrepareNow);
|
||||
}
|
||||
|
||||
inline COLORREF GetActiveColor() const { return m_clrActive; }
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(COXStaticMenuItem)
|
||||
protected:
|
||||
virtual void PreSubclassWindow();
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~COXStaticMenuItem();
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
|
||||
// helper to notify parent about COXStaticMenuItem events
|
||||
void NotifyParent(int nEventID);
|
||||
|
||||
//{{AFX_MSG(COXStaticMenuItem)
|
||||
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
|
||||
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
//}}AFX_MSG
|
||||
afx_msg LONG OnMouseEnter(WPARAM wParam, LPARAM lParam);
|
||||
afx_msg LONG OnMouseLeave(WPARAM wParam, LPARAM lParam);
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(_OXSSTATICMENUITEM_H__)
|
||||
@ -0,0 +1,261 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXThreadEngine
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXOwnThread.h
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// NO Is a Cwnd.
|
||||
// YES Two stage creation (constructor & Initialize())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// YES Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Description :
|
||||
// CThreadEngine class
|
||||
// You can use the COXThreadEngine for dedicated access to data objects.
|
||||
// It is a good approach to the design of multithreaded applications to prevent
|
||||
// as much as possible that specific data is accessed from more than one thread.
|
||||
// The class provides build-in functionality such as communication techniques
|
||||
// to communicate to and between different engines.
|
||||
// Suppose for example that we want to access a CMyOLEObject from more threads.
|
||||
// *** The first step is to derive a CMyEngine class from the COXThreadEngine base class.
|
||||
// We add the CMyOLEObject as a protected data member of the engine class.
|
||||
// Then we overload the pure virtual function "OnExecuteCmd()". This function will
|
||||
// be called internally by the COXThreadEngine and needs to dispatch the commands
|
||||
// to the appropriated function. Most of the time this can be implemented with a simply
|
||||
// switch structure.
|
||||
// Next, we have to derive a CMyCmd from the COXEngineCmd class to hold your
|
||||
// command parameters and return values. This class will be used internally to queue
|
||||
// multiple calls to the engine object.
|
||||
// Finally we provide a public wrapper function "DoSomething" which queues the CDoSomethingCmd
|
||||
// commands. We instantiate a CDoSomethingCmd object which we pass on to the PostCommand()
|
||||
// function. The PostCommand function will wait until the engine has executed the
|
||||
// command (in this example the command is synchronous). Before we return in this function
|
||||
// we need to release the command object. This object is reference counted and will
|
||||
// be destroyed automatically. If we now want to return a data member of the command
|
||||
// object, we need to copy the value to a temporary variable, because the command object could
|
||||
// be destroyed after we called the Release() function.
|
||||
//
|
||||
// *** Communication techniques:
|
||||
// + Synchronous, queued: create a COXEngineCmd without optional parameters and
|
||||
// post it with the PostCommand() function to the COXThreadEngine
|
||||
// + Synchronous, ASAP: create a COXEngineCmd without optional parameters and
|
||||
// post it with the PostCommand() function with the bASAP parameter set to TRUE
|
||||
// + Asynchronous, queued: create a COXEngineCmd with the first parameter set to FALSE
|
||||
// and post it with the PostCommand() function
|
||||
// + Asynchronous, ASAP: create a COXEngineCmd with the first parameter set to FALSE
|
||||
// and post it with the PostCommand() function with the bASAP parameter set to TRUE
|
||||
// * OPTIONAL for all the techniques, you can use a second parameter in the
|
||||
// constructor of COXEngineCmd if you want to receive a DONE notification.
|
||||
// This can be important for the asynchronous techniques. For this: the requesting
|
||||
// object need to be derived of COXDoneNotifier. You need to pass the this pointer
|
||||
// of the requesting object to the constructor of COXEngineCmd. Your requesting object
|
||||
// will now receive a DoneCommand() call after the execution of the command.
|
||||
// The command itself will be passed on as a parameter. You can use the command type and
|
||||
// the command index to track the initial request. For this, it is important that you
|
||||
// catalogue the index of the command after the construction of it.
|
||||
// Important is that you need to call the Release() function of your command also after
|
||||
// DONE notification.
|
||||
|
||||
// Remark:
|
||||
// If you forget the call the Release() function of COXEngineCmd you will end up
|
||||
// with memory leaks.
|
||||
// You need to call the COXEngineCmd::Release() function after you posted the command
|
||||
// with the COXThreadEngine::PostCommand() function. And you need to call the Release()
|
||||
// function ones again if you implement a "done notification" for your command.
|
||||
// If the object that requested the command is also running in his own engine,
|
||||
// it can be necessary to post done notification commands to the queue of your requesting
|
||||
// engine. In this case you need to use a own command for this "Post" which takes the first
|
||||
// one, that came with the "done notification" as a data member. In this case you must call
|
||||
// the Release() function of the first command in the destructor of the second one.
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef __OXTHREADENGINE_H_
|
||||
#define __OXTHREADENGINE_H_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
|
||||
|
||||
class COXEngineCmd;
|
||||
class COXThreadEngine;
|
||||
|
||||
class OX_CLASS_DECL COXDoneNotifier
|
||||
{
|
||||
friend COXThreadEngine;
|
||||
protected:
|
||||
virtual void DoneCommand(COXEngineCmd* pCmd) = 0;
|
||||
};
|
||||
|
||||
class OX_CLASS_DECL COXEngineCmd : public CObject
|
||||
{
|
||||
DECLARE_DYNAMIC(COXEngineCmd)
|
||||
|
||||
friend COXThreadEngine;
|
||||
|
||||
// Data Members
|
||||
public:
|
||||
DWORD m_dwIndex; // every instantiated command has an unique index
|
||||
|
||||
protected:
|
||||
COXDoneNotifier* m_pDoneNotifier; // for optional notification after execution
|
||||
HANDLE m_hFinishedEvent; // use for synchronisation of synchrone commands
|
||||
LONG m_nRef; // used for reference counting
|
||||
|
||||
private:
|
||||
static DWORD m_dwGlobalIndex; // internal cyclic counter
|
||||
|
||||
// Member Functions
|
||||
public:
|
||||
COXEngineCmd(BOOL bSynchrone = TRUE, COXDoneNotifier* pDoneNotifier = NULL);
|
||||
// --- In : bSynchrone: defines if the command will be executed synchronous or asynchronous
|
||||
// pDoneNotifier: will be notified when the execution of the command is done
|
||||
// --- Out : none
|
||||
// --- Returns : none
|
||||
// --- Effect : Contructor of an egine command
|
||||
|
||||
void Release();
|
||||
// --- In : none
|
||||
// --- Out : none
|
||||
// --- Returns : none
|
||||
// --- Effect : decreases the reference count and deletes the object if zero
|
||||
|
||||
BOOL IsSynchrone() const;
|
||||
// --- In : none
|
||||
// --- Out : none
|
||||
// --- Returns : if the command is synchronous or not
|
||||
// --- Effect :
|
||||
|
||||
protected:
|
||||
virtual ~COXEngineCmd();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
class OX_CLASS_DECL COXThreadEngine : public CObject
|
||||
{
|
||||
// Data Members
|
||||
public:
|
||||
|
||||
protected:
|
||||
BOOL m_bEndThread; // thread shall terminate during next thread event
|
||||
BOOL m_bInitialized; // if successfully initialised
|
||||
CWinThread* m_pThread; // thread pointer of the engines thread
|
||||
HANDLE m_hCreatedEvent;// event for initialisation synchronisation
|
||||
HANDLE m_hEndEvent; // event for termination synchronisation
|
||||
HANDLE m_hThreadEvent; // event when a new command is posted
|
||||
DWORD m_nTerinationTimeout;
|
||||
|
||||
class OX_CLASS_DECL COXEngineCmdList : public CTypedPtrList<CPtrList, COXEngineCmd*>
|
||||
{
|
||||
// Data Members
|
||||
public:
|
||||
protected:
|
||||
HANDLE m_hMutex;
|
||||
private:
|
||||
// Member functions
|
||||
public:
|
||||
COXEngineCmdList();
|
||||
virtual ~COXEngineCmdList();
|
||||
void Lock();
|
||||
void Unlock();
|
||||
protected:
|
||||
private:
|
||||
} m_cmdList;
|
||||
|
||||
private:
|
||||
|
||||
// Member Functions
|
||||
public:
|
||||
COXThreadEngine();
|
||||
// --- In : none
|
||||
// --- Out : none
|
||||
// --- Returns : none
|
||||
// --- Effect : construction of engine (still need to be initialised)
|
||||
|
||||
virtual ~COXThreadEngine();
|
||||
// --- In : none
|
||||
// --- Out : none
|
||||
// --- Returns : none
|
||||
// --- Effect : destructs the engine (need to be terminated first)
|
||||
|
||||
BOOL Initialize();
|
||||
// --- In : none
|
||||
// --- Out : none
|
||||
// --- Returns : if the engine is successfully initialised
|
||||
// --- Effect : start the engines thread (as a result
|
||||
// OnThreadConstruction() will be called)
|
||||
|
||||
BOOL IsInitialized();
|
||||
// --- In : none
|
||||
// --- Out : none
|
||||
// --- Returns : if the engine is successfully initialised
|
||||
// --- Effect :
|
||||
|
||||
void Terminate();
|
||||
// --- In : none
|
||||
// --- Out : none
|
||||
// --- Returns : none
|
||||
// --- Effect : stops the engines thread (first
|
||||
// OnThreadDestruction() will be called)
|
||||
|
||||
void PostCommand(COXEngineCmd* pCmd, BOOL bASAP = FALSE);
|
||||
// --- In : pCmd : the command that will be added to the engines queue
|
||||
// bASAP : the command will be executed as soon as possible
|
||||
// when this flag is used the command will be added to
|
||||
// the head instead of the tail of the queue
|
||||
// --- Out : none
|
||||
// --- Returns : none
|
||||
// --- Effect : the command is added to the engines queue and the engine
|
||||
// thread is notified by an event
|
||||
|
||||
protected:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// --- this function must be overloaded in your derived engine
|
||||
virtual void OnExecuteCmd(COXEngineCmd* pCmd) = 0;
|
||||
// --- In: pCmd: the next command in the queue that should be executed
|
||||
// --- Out: none
|
||||
// --- Returns: none
|
||||
// --- Effect: Up to YOU !!!!!
|
||||
|
||||
// these two function can be overloaded if some specific initialisation and
|
||||
// uninitialisation is needed
|
||||
virtual BOOL OnThreadCreation();
|
||||
virtual void OnThreadDestruction();
|
||||
|
||||
// these two function can be overloaded if some specific initialisation and
|
||||
// uninitialisation is needed
|
||||
virtual void OnThreadEvent();
|
||||
|
||||
private:
|
||||
void Run();
|
||||
static UINT StartThread( LPVOID pParam );
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // __OXTHREADENGINE_H_
|
||||
@ -0,0 +1,216 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXTimer
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXTimer.h
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from CObject
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// NO Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// This class can be used to measure the elapsed time between two moments
|
||||
// (interval timer) or the trigger a notification when a specified amount
|
||||
// of time has elapsed (notification timer)
|
||||
|
||||
// Remark:
|
||||
// All time is expressed in nanoseconds. But it is possible that such an
|
||||
// accuracy is not met (either by the hardware or by Win32).
|
||||
// An interval timer can be queried for its resolution
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __OXTIMER_H__
|
||||
#define __OXTIMER_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
#include <AfxTempl.h>
|
||||
|
||||
|
||||
class COXTimer;
|
||||
|
||||
// ... Type definition of the callback function
|
||||
typedef void (CALLBACK OX_TIMER_NOTIFICATION) (COXTimer* pTimer);
|
||||
typedef OX_TIMER_NOTIFICATION* P_OX_TIMER_NOTIFICATION;
|
||||
|
||||
// Some handy macros to convert between unit, milli, micro and nano
|
||||
// Nano seconds use a LONGLONG, unit, milli and micro use an int
|
||||
#define NANO_TO_MICRO(nano) (int)((LONGLONG)(nano) / 1000)
|
||||
#define NANO_TO_MILLI(nano) (int)((LONGLONG)(nano) / 1000000)
|
||||
#define NANO_TO_UNIT(nano) (int)((LONGLONG)(nano) / 1000000000)
|
||||
#define MICRO_TO_NANO(micro) ((LONGLONG)(micro) * 1000)
|
||||
#define MILLI_TO_NANO(milli) ((LONGLONG)(milli) * 1000000)
|
||||
#define UNIT_TO_NANO(unit) ((LONGLONG)(unit) * 1000000000)
|
||||
|
||||
class OX_CLASS_DECL COXTimer : public CObject
|
||||
{
|
||||
DECLARE_DYNAMIC(COXTimer);
|
||||
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
protected:
|
||||
LARGE_INTEGER m_startIntervalCounter;
|
||||
LARGE_INTEGER m_stopIntervalCounter;
|
||||
static LARGE_INTEGER m_nIntervalTimerFrequency; // -1 = not available, 0 = unknown, other OK
|
||||
|
||||
DWORD m_nUserData;
|
||||
P_OX_TIMER_NOTIFICATION m_pfNotification;
|
||||
UINT m_nNonSynchronizedTimerNotifierID;
|
||||
UINT m_nSynchronizedTimerNotifierID;
|
||||
BOOL m_bPeriodic;
|
||||
static CMap<COXTimer*, COXTimer*, BOOL, BOOL> m_allTimers;
|
||||
static CMap<DWORD, DWORD, COXTimer*, COXTimer*> m_synchronizedTimers;
|
||||
|
||||
private:
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Constructs the object
|
||||
COXTimer();
|
||||
|
||||
// *** Interval Timer functions
|
||||
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : Whether it succeeded or not. This function may fail if the platform
|
||||
// does not support a high accuracy interval timer
|
||||
// --- Effect : Starts the interval timer
|
||||
BOOL StartInterval();
|
||||
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Stops the interval timer
|
||||
void StopInterval();
|
||||
|
||||
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The elapsed time of the counter in nanoseconds
|
||||
// There are 1,000,000,000 nanoseconds in 1 second
|
||||
// If the value is not strictly positive an error has occurred
|
||||
// --- Effect : This function returns the elapsed time between the last start and stop
|
||||
// of the counter
|
||||
LONGLONG GetInterval() const;
|
||||
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The maximum accuracy of an interval timer specified in nanoseconds
|
||||
// There are 1,000,000,000 nanoseconds in 1 second
|
||||
// (return -1 in case the platform does not support a
|
||||
// high accuracy interval timer)
|
||||
// --- Effect :
|
||||
static LONGLONG GetIntervalAccuracy();
|
||||
|
||||
|
||||
// *** Notification Timer functions
|
||||
|
||||
// --- In : nDelay : The delay in nanoseconds that must elaps before the
|
||||
// notificvation function is called
|
||||
// pfTimerNotification : The notification function to call
|
||||
// bPeriodic : Whether the function should be called periodically (TRUE)
|
||||
// or just one (FALSE)
|
||||
// bSynchronized : Whether the callback should be called from this thread (TRUE)
|
||||
// or from a seperate dedicated thread (TRUE)
|
||||
// Using a seperate thread will produce more superieur results
|
||||
// nAccuracy : The minimum accuracy in nanoseconds. Bu default this is 1%
|
||||
// of the specified delay with a maximum of 1 second
|
||||
// --- Out :
|
||||
// --- Returns : Whether it succeeded or not.
|
||||
// --- Effect : Starts the timer notifier
|
||||
// Using this function with a very small delay time (< 10 ms) might
|
||||
// use so much CPU time that your computers seems to hang
|
||||
BOOL StartNotifier(LONGLONG nDelay, P_OX_TIMER_NOTIFICATION pfTimerNotification,
|
||||
BOOL bPeriodic = FALSE, BOOL bSynchronized = FALSE, LONGLONG nAccuracy = -1);
|
||||
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Stops the timer notifier
|
||||
void StopNotifier();
|
||||
|
||||
|
||||
// --- In : nUserData : The user data to associate with this timer
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect :
|
||||
void SetUserData(DWORD nUserData = 0);
|
||||
|
||||
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The user data associated with this timer
|
||||
// --- Effect :
|
||||
DWORD GetUserData() const;
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : AssertValid performs a validity check on this object
|
||||
// by checking its internal state.
|
||||
// In the Debug version of the library, AssertValid may assert and
|
||||
// thus terminate the program.
|
||||
virtual void AssertValid() const;
|
||||
|
||||
// --- In : dc : The diagnostic dump context for dumping, usually afxDump.
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Dumps the contents of the object to a CDumpContext object.
|
||||
// It provides diagnostic services for yourself and
|
||||
// other users of your class.
|
||||
// Note The Dump function does not print a newline character
|
||||
// at the end of its output.
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of the object
|
||||
virtual ~COXTimer();
|
||||
|
||||
protected:
|
||||
BOOL StartNonSynchronizedNotifier(int nMilliDelay, P_OX_TIMER_NOTIFICATION pfTimerNotification,
|
||||
BOOL bPeriodic, int nMilliAccuracy);
|
||||
static void CALLBACK NonSynchronizedNotificationCallback(UINT uTimerID, UINT uMsg,
|
||||
DWORD dwUser, DWORD dw1, DWORD dw2);
|
||||
void OnNonSynchronizedNotification();
|
||||
void StopNonSynchronizedNotifier();
|
||||
|
||||
BOOL StartSynchronizedNotifier(int nMilliDelay, P_OX_TIMER_NOTIFICATION pfTimerNotification,
|
||||
BOOL bPeriodic, int nMilliAccuracy);
|
||||
static void CALLBACK SynchronizedNotificationCallback(HWND hWnd, UINT uMsg,
|
||||
UINT nTimerID, DWORD nTime);
|
||||
void OnSynchronizedNotification();
|
||||
void StopSynchronizedNotifier();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif // __OXTIMER_H__
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,142 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXVariant
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXVariant.h
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from COleVariant
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// NO Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// This class is an extension on COleVariant
|
||||
// It supports the serialization of byte arrays (VT_UI1 | VT_ARRAY)
|
||||
|
||||
// Remark:
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __OXVARIANT_H__
|
||||
#define __OXVARIANT_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
|
||||
class OX_CLASS_DECL COXVariant : public COleVariant
|
||||
{
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
COXVariant();
|
||||
|
||||
COXVariant(const VARIANT& varSrc);
|
||||
COXVariant(LPCVARIANT pSrc);
|
||||
COXVariant(const COleVariant& varSrc);
|
||||
COXVariant(const COXVariant& varSrc);
|
||||
|
||||
COXVariant(LPCTSTR lpszSrc);
|
||||
COXVariant(CString& strSrc);
|
||||
|
||||
COXVariant(BYTE nSrc);
|
||||
COXVariant(short nSrc, VARTYPE vtSrc = VT_I2);
|
||||
COXVariant(long lSrc, VARTYPE vtSrc = VT_I4);
|
||||
COXVariant(const COleCurrency& curSrc);
|
||||
COXVariant(bool bSrc);
|
||||
|
||||
COXVariant(float fltSrc);
|
||||
COXVariant(double dblSrc);
|
||||
COXVariant(const COleDateTime& timeSrc);
|
||||
|
||||
COXVariant(const CByteArray& arrSrc);
|
||||
COXVariant(const CLongBinary& lbSrc);
|
||||
|
||||
COXVariant(LPCTSTR lpszSrc, VARTYPE vtSrc); // Used by DAO classes
|
||||
|
||||
// Assignemnt operators
|
||||
const COXVariant& operator=(const VARIANT& varSrc);
|
||||
const COXVariant& operator=(LPCVARIANT pSrc);
|
||||
const COXVariant& operator=(const COleVariant& varSrc);
|
||||
const COXVariant& operator=(const COXVariant& varSrc);
|
||||
|
||||
const COXVariant& operator=(const LPCTSTR lpszSrc);
|
||||
const COXVariant& operator=(const CString& strSrc);
|
||||
|
||||
const COXVariant& operator=(BYTE nSrc);
|
||||
const COXVariant& operator=(short nSrc);
|
||||
const COXVariant& operator=(long lSrc);
|
||||
const COXVariant& operator=(const COleCurrency& curSrc);
|
||||
const COXVariant& operator=(bool bSrc);
|
||||
|
||||
const COXVariant& operator=(float fltSrc);
|
||||
const COXVariant& operator=(double dblSrc);
|
||||
const COXVariant& operator=(const COleDateTime& dateSrc);
|
||||
|
||||
const COXVariant& operator=(const CByteArray& arrSrc);
|
||||
const COXVariant& operator=(const CLongBinary& lbSrc);
|
||||
|
||||
static void CheckError(SCODE sc);
|
||||
// --- In : The result an OLE call
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : If the result code indicates failure an COleException is thrown
|
||||
// unless it indicates out of memory, then a CMemoryException is thrown
|
||||
// When no failure is indicated, this function does nothing
|
||||
|
||||
virtual ~COXVariant();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of the object
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
// COXVariant diagnostics and serialization
|
||||
#ifdef _DEBUG
|
||||
OX_API_DECL CDumpContext& AFXAPI operator<<(CDumpContext& dc, COXVariant varSrc);
|
||||
#endif
|
||||
OX_API_DECL CArchive& AFXAPI operator<<(CArchive& ar, COXVariant varSrc);
|
||||
OX_API_DECL CArchive& AFXAPI operator>>(CArchive& ar, COXVariant& varSrc);
|
||||
|
||||
// special collections functions for COXVariant
|
||||
OX_API_DECL void AFXAPI ConstructElements(COXVariant* pElements, int nCount);
|
||||
OX_API_DECL void AFXAPI DestructElements(COXVariant* pElements, int nCount);
|
||||
OX_API_DECL void AFXAPI CopyElements(COXVariant* pDest, const COXVariant* pSrc,
|
||||
int nCount);
|
||||
OX_API_DECL void AFXAPI SerializeElements(CArchive& ar, COXVariant* pElements,
|
||||
int nCount);
|
||||
OX_API_DECL void AFXAPI DumpElements(CDumpContext& dc, COXVariant* pElements,
|
||||
int nCount);
|
||||
|
||||
#include "OXVariant.inl"
|
||||
|
||||
#endif // __OXVARIANT_H__
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,235 @@
|
||||
// ==========================================================================
|
||||
// Inline Implementation : COXVariant
|
||||
// ==========================================================================
|
||||
|
||||
// Source file : OXVariant.inl
|
||||
|
||||
// Source : R.Mortelmans
|
||||
// Creation Date : 7th March 1996
|
||||
// Last Modification : 7th March 1996
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Definition of static members
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
// public:
|
||||
inline COXVariant::COXVariant()
|
||||
:
|
||||
COleVariant()
|
||||
{
|
||||
}
|
||||
|
||||
inline COXVariant::COXVariant(const VARIANT& varSrc)
|
||||
:
|
||||
COleVariant(varSrc)
|
||||
{
|
||||
}
|
||||
|
||||
inline COXVariant::COXVariant(LPCVARIANT pSrc)
|
||||
:
|
||||
COleVariant(pSrc)
|
||||
{
|
||||
}
|
||||
|
||||
inline COXVariant::COXVariant(const COleVariant& varSrc)
|
||||
:
|
||||
COleVariant(varSrc)
|
||||
{
|
||||
}
|
||||
|
||||
inline COXVariant::COXVariant(const COXVariant& varSrc)
|
||||
:
|
||||
COleVariant((COleVariant) varSrc)
|
||||
{
|
||||
}
|
||||
|
||||
inline COXVariant::COXVariant(LPCTSTR lpszSrc)
|
||||
:
|
||||
COleVariant(lpszSrc)
|
||||
{
|
||||
}
|
||||
|
||||
inline COXVariant::COXVariant(CString& strSrc)
|
||||
:
|
||||
COleVariant(strSrc)
|
||||
{
|
||||
}
|
||||
|
||||
inline COXVariant::COXVariant(BYTE nSrc)
|
||||
:
|
||||
COleVariant(nSrc)
|
||||
{
|
||||
}
|
||||
|
||||
inline COXVariant::COXVariant(short nSrc, VARTYPE vtSrc /* = VT_I2 */)
|
||||
:
|
||||
COleVariant(nSrc, vtSrc)
|
||||
{
|
||||
}
|
||||
|
||||
inline COXVariant::COXVariant(long lSrc, VARTYPE vtSrc /* = VT_I4 */)
|
||||
:
|
||||
COleVariant(lSrc, vtSrc)
|
||||
{
|
||||
}
|
||||
|
||||
inline COXVariant::COXVariant(const COleCurrency& curSrc)
|
||||
:
|
||||
COleVariant(curSrc)
|
||||
{
|
||||
}
|
||||
|
||||
inline COXVariant::COXVariant(bool bSrc)
|
||||
:
|
||||
COleVariant((short)bSrc, VT_BOOL)
|
||||
{
|
||||
}
|
||||
|
||||
inline COXVariant::COXVariant(float fltSrc)
|
||||
:
|
||||
COleVariant(fltSrc)
|
||||
{
|
||||
}
|
||||
|
||||
inline COXVariant::COXVariant(double dblSrc)
|
||||
:
|
||||
COleVariant(dblSrc)
|
||||
{
|
||||
}
|
||||
|
||||
inline COXVariant::COXVariant(const COleDateTime& timeSrc)
|
||||
:
|
||||
COleVariant(timeSrc)
|
||||
{
|
||||
}
|
||||
|
||||
inline COXVariant::COXVariant(const CByteArray& arrSrc)
|
||||
:
|
||||
COleVariant(arrSrc)
|
||||
{
|
||||
}
|
||||
|
||||
inline COXVariant::COXVariant(const CLongBinary& lbSrc)
|
||||
:
|
||||
COleVariant(lbSrc)
|
||||
{
|
||||
}
|
||||
|
||||
inline COXVariant::COXVariant(LPCTSTR lpszSrc, VARTYPE vtSrc)
|
||||
:
|
||||
COleVariant(lpszSrc, vtSrc)
|
||||
{
|
||||
}
|
||||
|
||||
inline const COXVariant& COXVariant::operator=(const VARIANT& varSrc)
|
||||
{
|
||||
COleVariant::operator=(varSrc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const COXVariant& COXVariant::operator=(LPCVARIANT pSrc)
|
||||
{
|
||||
COleVariant::operator=(pSrc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const COXVariant& COXVariant::operator=(const COXVariant& varSrc)
|
||||
{
|
||||
COleVariant::operator=(varSrc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const COXVariant& COXVariant::operator=(const COleVariant& varSrc)
|
||||
{
|
||||
COleVariant::operator=(varSrc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const COXVariant& COXVariant::operator=(const LPCTSTR lpszSrc)
|
||||
{
|
||||
COleVariant::operator=(lpszSrc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const COXVariant& COXVariant::operator=(const CString& strSrc)
|
||||
{
|
||||
COleVariant::operator=(strSrc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const COXVariant& COXVariant::operator=(BYTE nSrc)
|
||||
{
|
||||
COleVariant::operator=(nSrc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const COXVariant& COXVariant::operator=(short nSrc)
|
||||
{
|
||||
COleVariant::operator=(nSrc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const COXVariant& COXVariant::operator=(long lSrc)
|
||||
{
|
||||
COleVariant::operator=(lSrc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const COXVariant& COXVariant::operator=(const COleCurrency& curSrc)
|
||||
{
|
||||
COleVariant::operator=(curSrc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const COXVariant& COXVariant::operator=(bool bSrc)
|
||||
{
|
||||
vt = VT_BOOL;
|
||||
|
||||
if (!bSrc)
|
||||
V_BOOL(this) = AFX_OLE_FALSE;
|
||||
else
|
||||
V_BOOL(this) = AFX_OLE_TRUE;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const COXVariant& COXVariant::operator=(float fltSrc)
|
||||
{
|
||||
COleVariant::operator=(fltSrc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const COXVariant& COXVariant::operator=(double dblSrc)
|
||||
{
|
||||
COleVariant::operator=(dblSrc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const COXVariant& COXVariant::operator=(const COleDateTime& dateSrc)
|
||||
{
|
||||
COleVariant::operator=(dateSrc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const COXVariant& COXVariant::operator=(const CByteArray& arrSrc)
|
||||
{
|
||||
COleVariant::operator=(arrSrc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const COXVariant& COXVariant::operator=(const CLongBinary& lbSrc)
|
||||
{
|
||||
COleVariant::operator=(lbSrc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline COXVariant::~COXVariant()
|
||||
{
|
||||
}
|
||||
|
||||
// protected:
|
||||
// private:
|
||||
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,150 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXVersionInfo
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXVerinfo.h
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from CObject
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// NO Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// This class can be used to retrieve the version information
|
||||
// from a file 5EXE, DLL, etc)
|
||||
|
||||
// Remark:
|
||||
// ***
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
// ***
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef __VERINFO_H__
|
||||
#define __VERINFO_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
|
||||
class OX_CLASS_DECL COXVersionInfo : public CObject
|
||||
{
|
||||
DECLARE_DYNAMIC(COXVersionInfo)
|
||||
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
DWORD m_dwSignature;
|
||||
DWORD m_dwStrucVersion;
|
||||
DWORD m_dwFileVersionMS;
|
||||
DWORD m_dwFileVersionLS;
|
||||
DWORD m_dwProductVersionMS;
|
||||
DWORD m_dwProductVersionLS;
|
||||
DWORD m_dwFileFlagsMask;
|
||||
DWORD m_dwFileFlags;
|
||||
DWORD m_dwFileOS;
|
||||
DWORD m_dwFileType;
|
||||
DWORD m_dwFileSubtype;
|
||||
DWORD m_dwFileDateMS;
|
||||
DWORD m_dwFileDateLS;
|
||||
|
||||
DWORD m_dwLanguageCountryID;
|
||||
CString m_sLanguageCountry;
|
||||
|
||||
CString m_sComments;
|
||||
CString m_sCompanyName;
|
||||
CString m_sFileDescription;
|
||||
CString m_sFileVersion;
|
||||
CString m_sInternalName;
|
||||
CString m_sLegalCopyright;
|
||||
CString m_sLegalTrademarks;
|
||||
CString m_sOriginalFilename;
|
||||
CString m_sPrivateBuild;
|
||||
CString m_sProductName;
|
||||
CString m_sProductVersion;
|
||||
CString m_sSpecialBuild;
|
||||
|
||||
protected:
|
||||
BOOL m_bValid;
|
||||
|
||||
static const DWORD m_dwFixedFileInfoSignature;
|
||||
static const DWORD m_dwAmericanEnglishTranslation;
|
||||
static LPCTSTR m_pszTranslation;
|
||||
static LPCTSTR m_pszFileInfo;
|
||||
|
||||
private:
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
COXVersionInfo();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Contructor of object
|
||||
// It will initialize the internal state
|
||||
|
||||
BOOL ReadInfo(LPCTSTR pszPathName);
|
||||
// --- In : pszPathName : The full path of the file of which the version info is requested
|
||||
// --- Out :
|
||||
// --- Returns : Whether version info was found
|
||||
// --- Effect : Extracts the version info for the file
|
||||
|
||||
BOOL ContainsValidInfo();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : Whether this version info contains valid info
|
||||
// --- Effect :
|
||||
|
||||
CString GetOSName();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : A text specifying the Operating System
|
||||
// --- Effect :
|
||||
|
||||
void Empty();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Clears the object
|
||||
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
virtual ~COXVersionInfo();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of object
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
// Message handlers ---------------------------------------------------------
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,153 @@
|
||||
// =============================================================================
|
||||
// Class Specification : COXWebView
|
||||
// =============================================================================
|
||||
//
|
||||
// Header file : OXWebView.h
|
||||
//
|
||||
// /////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Properties:
|
||||
//
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from CObject
|
||||
// YES Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// YES Has a message map
|
||||
// NO Needs a resource (template)
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// NO Uses exceptions
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Desciption :
|
||||
// This class provides a simple to use html viewer by leveraging
|
||||
// Microsoft's Internet Explorer web control.
|
||||
//
|
||||
// Remark:
|
||||
//
|
||||
// Prerequisites (necessary conditions):
|
||||
// The user must have Microsoft Internet Explorer v3.x (or higher)
|
||||
// installed on his machine in order for this class to function.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __OXWEBVIEW_H__
|
||||
#define __OXWEBVIEW_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
|
||||
#include <Exdisp.h>
|
||||
#include "OXWebCtrl.h"
|
||||
|
||||
|
||||
class OX_CLASS_DECL COXWebView : public CView
|
||||
{
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
protected:
|
||||
private:
|
||||
static CFont* m_pfontToolbarURL;
|
||||
static int m_nNumInstantiated;
|
||||
|
||||
CComboBox m_cbxToolbarURL;
|
||||
COXWebCtrl m_WebCtrl;
|
||||
CToolBar m_Toolbar;
|
||||
CToolTipCtrl m_Tooltips;
|
||||
|
||||
BOOL m_bCanGoBack;
|
||||
BOOL m_bCanGoForward;
|
||||
BOOL m_bCanRefresh;
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
virtual ~COXWebView();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of object
|
||||
|
||||
COXWebCtrl& GetWebControl()
|
||||
{ return m_WebCtrl; }
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : A reference to the web control embedded within the view.
|
||||
// --- Effect : This method allows the user to get at the web control
|
||||
// if access is needed.
|
||||
|
||||
CToolBar& GetToolbar()
|
||||
{ return m_Toolbar; }
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : A reference to the toolbar contained within the view.
|
||||
// --- Effect : This method allows the user to get at the toolbar of
|
||||
// the web view.
|
||||
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(COXWebView)
|
||||
public:
|
||||
virtual void OnDraw(CDC* pDC); // overridden to draw this view
|
||||
protected:
|
||||
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
|
||||
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
|
||||
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
DECLARE_DYNCREATE(COXWebView)
|
||||
enum { IDC_WEB_CTRL = 100, IDC_TOOLBAR_URL = 101 };
|
||||
|
||||
COXWebView(); // create from serialization only
|
||||
virtual void BeforeNavigate(LPCTSTR pcszURL, long lFlags, LPCTSTR pcszTargetFrameName, VARIANT* PostData, LPCTSTR pcszHeaders, VARIANT_BOOL* pbCancel);
|
||||
virtual void NavigateComplete(LPCTSTR pcszURL);
|
||||
virtual void StatusTextChange(LPCTSTR pcszText);
|
||||
virtual void Quit(VARIANT_BOOL* pbCancel);
|
||||
virtual void DownloadBegin();
|
||||
virtual void NewWindow(LPCTSTR pcszURL, long lFlags, LPCTSTR pcszTargetFrameName, VARIANT* PostData, LPCTSTR pcszHeaders, VARIANT_BOOL* pbCancel);
|
||||
virtual void ProgressChange(long lProgress, long lProgressMax);
|
||||
virtual void DownloadComplete();
|
||||
virtual void CommandStateChange(long lCmdID, BOOL bEnabled);
|
||||
virtual void PropertyChange(LPCTSTR pcszProperty);
|
||||
virtual void TitleChange(LPCTSTR pcszTitle);
|
||||
virtual void FrameBeforeNavigate(LPCTSTR pcszURL, long lFlags, LPCTSTR pcszTargetFrameName, VARIANT* PostData, LPCTSTR pcszHeaders, VARIANT_BOOL* pbCancel);
|
||||
virtual void FrameNavigateComplete(LPCTSTR pcszURL);
|
||||
virtual void FrameNewWindow(LPCTSTR pcszURL, long lFlags, LPCTSTR pcszTargetFrameName, VARIANT* PostData, LPCTSTR pcszHeaders, VARIANT_BOOL* pbCancel);
|
||||
|
||||
//{{AFX_MSG(COXWebView)
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||
afx_msg void OnWebviewBack();
|
||||
afx_msg void OnWebviewForward();
|
||||
afx_msg void OnUpdateWebviewBack(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateWebviewForward(CCmdUI* pCmdUI);
|
||||
afx_msg void OnWebviewHome();
|
||||
afx_msg void OnWebviewSearch();
|
||||
afx_msg void OnUpdateWebviewStop(CCmdUI* pCmdUI);
|
||||
afx_msg void OnWebviewStop();
|
||||
afx_msg void OnUpdateFilePrintPreview(CCmdUI* pCmdUI);
|
||||
afx_msg void OnFilePrint();
|
||||
afx_msg void OnUpdateWebviewRefresh(CCmdUI* pCmdUI);
|
||||
afx_msg void OnWebviewRefresh();
|
||||
//}}AFX_MSG
|
||||
afx_msg void OnToolbarURLChange();
|
||||
afx_msg BOOL OnTooltipNeedText(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
|
||||
DECLARE_MESSAGE_MAP()
|
||||
DECLARE_EVENTSINK_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // __OXWEBVIEW_H__
|
||||
|
||||
@ -0,0 +1,117 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#ifndef _OXWEBVIEW_RC__
|
||||
#define _OXWEBVIEW_RC__
|
||||
#include "OXMainRes.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Toolbar
|
||||
//
|
||||
|
||||
IDR_OX_WEBVIEW_BAR TOOLBAR DISCARDABLE 16, 15
|
||||
BEGIN
|
||||
BUTTON ID_OX_WEBVIEW_BACK
|
||||
BUTTON ID_OX_WEBVIEW_FORWARD
|
||||
BUTTON ID_OX_WEBVIEW_STOP
|
||||
BUTTON ID_OX_WEBVIEW_REFRESH
|
||||
BUTTON ID_OX_WEBVIEW_HOME
|
||||
BUTTON ID_OX_WEBVIEW_SEARCH
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
//
|
||||
|
||||
IDB_OX_WEBVIEW_BAR BITMAP DISCARDABLE "res\\OXWebBar.bmp"
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Dutch (Belgium) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NLB)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_DUTCH, SUBLANG_DUTCH_BELGIAN
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resrc1.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_OX_WEBVIEW_BACK "Navigates to previous page\nBack"
|
||||
ID_OX_WEBVIEW_STOP "Stops downloading the current page\nStop"
|
||||
ID_OX_WEBVIEW_HOME "Navigates to your start page\nHome"
|
||||
ID_OX_WEBVIEW_SEARCH "Navigates to your search page\nSearch"
|
||||
ID_OX_WEBVIEW_FORWARD "Navigates to next page\nForward"
|
||||
ID_OX_WEBVIEW_REFRESH "Refreshes the current page\nRefresh"
|
||||
END
|
||||
|
||||
#endif // Dutch (Belgium) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
#endif //_OXWEBVIEW_RC__
|
||||
@ -0,0 +1,122 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXDiffProgress
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : progress.h
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from CObject
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// NO Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// This class encapsulates a progress bar that will be used
|
||||
// when calculating the binary differences
|
||||
// You can derive from this class and use and own implementation
|
||||
|
||||
// Remark:
|
||||
// ***
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
// ***
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __PROGRESS_H__
|
||||
#define __PROGRESS_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
|
||||
class OX_CLASS_DECL COXDiffProgress : public CObject
|
||||
{
|
||||
DECLARE_DYNAMIC(COXDiffProgress)
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
|
||||
protected:
|
||||
LONG m_MinVal;
|
||||
LONG m_MaxVal;
|
||||
LONG m_CurPos;
|
||||
|
||||
private:
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
COXDiffProgress();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Contructor of object
|
||||
|
||||
virtual void Init(LONG minVal, LONG maxVal, LPCTSTR pszMessage);
|
||||
// --- In : minVal : Minimum value
|
||||
// maxVal : Maximum value
|
||||
// pszMessage : Message text to show
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Initializes the progress bar
|
||||
|
||||
virtual BOOL Adjust(LONG curVal);
|
||||
// --- In : curVal : The new current value
|
||||
// representing the progress
|
||||
// --- Out :
|
||||
// --- Returns : Whether the action may continue (TRUE)
|
||||
// returning FALSE will abort the action in progress
|
||||
// --- Effect : Adjust the progress bar
|
||||
|
||||
virtual void Abort(LPCTSTR pszMessage);
|
||||
// --- In : pszMessage : The abort message
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : This function shows a message to the user and
|
||||
// aborts the program
|
||||
// This function should never return
|
||||
|
||||
virtual void Close();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Closes the progress bar
|
||||
|
||||
#ifdef _DEBUG
|
||||
virtual void Dump(CDumpContext&) const;
|
||||
virtual void AssertValid() const;
|
||||
#endif //_DEBUG
|
||||
|
||||
virtual ~COXDiffProgress();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of object
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif // __PROGRESS_H__
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,43 @@
|
||||
|
||||
|
||||
#if _MSC_VER < 1400
|
||||
|
||||
#ifndef GetWindowLongPtr
|
||||
#define GetWindowLongPtr GetWindowLong
|
||||
#endif
|
||||
|
||||
#ifndef SetWindowLongPtr
|
||||
#define SetWindowLongPtr SetWindowLong
|
||||
#endif
|
||||
|
||||
#ifndef GetClassLongPtr
|
||||
#define GetClassLongPtr GetClassLong
|
||||
#endif
|
||||
|
||||
#ifndef SetClassLongPtr
|
||||
#define SetClassLongPtr SetClassLong
|
||||
#endif
|
||||
|
||||
#ifndef ULongToPtr
|
||||
#define ULongToPtr(x) x
|
||||
#endif
|
||||
|
||||
#ifndef LongToPtr
|
||||
#define LongToPtr(x) x
|
||||
#endif
|
||||
|
||||
#ifndef PtrToUint
|
||||
#define PtrToUint(x) x
|
||||
#endif
|
||||
|
||||
#ifndef PtrToInt
|
||||
#define PtrToInt(x) x
|
||||
#endif
|
||||
|
||||
typedef DWORD DWORD_PTR;
|
||||
typedef LONG LONG_PTR;
|
||||
typedef ULONG ULONG_PTR;
|
||||
|
||||
// Frustratingly, INT_PTR is an int in VC2005, and a long in VC6, so we can't define it here, the code needs to just handle it elsewhere
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,151 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXMainFrame
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : xmainfrm.h
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from CMDIFrameWnd
|
||||
|
||||
// YES Is a Cwnd.
|
||||
// YES Two stage creation (constructor & Create())
|
||||
// YES Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// NO Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// This is a base class that is used to provide a basic layer
|
||||
// for all MainFrames that we want to have a bitmap and/or color shown as
|
||||
// background. Palette handling is provided. It has a subclass for the MDICLIENT.
|
||||
// There is also some functionality to save and restore its position on
|
||||
// on the screen
|
||||
|
||||
// Remark:
|
||||
// ***
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
// ***
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef __X_MAINFRAME_H__
|
||||
#define __X_MAINFRAME_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
#include "xmdiclt.h"
|
||||
|
||||
// User message for sending palette changes to this MDI Childs
|
||||
#define WM_DOREALIZE (WM_USER + 105)
|
||||
|
||||
class OX_CLASS_DECL COXMainFrame : public CMDIFrameWnd
|
||||
{
|
||||
DECLARE_DYNAMIC(COXMainFrame)
|
||||
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
WINDOWPLACEMENT* m_pWindowPlacement;
|
||||
// --- The initial window placement.
|
||||
// This is used to initially show the window
|
||||
// The last used placement is persistently saved, and used the next time
|
||||
// the window is created
|
||||
|
||||
protected:
|
||||
COXMDIClient m_XMDIClient;
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
COXMainFrame();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Contructor of object
|
||||
// It will initialize the internal state
|
||||
|
||||
virtual BOOL CreateClient(LPCREATESTRUCT lpCreateStruct, CMenu* pWindowMenu );
|
||||
// --- In : lpCreateStruct : A long pointer to a CREATESTRUCT structure.
|
||||
// pWindowMenu : A pointer to the Window pop-up menu.
|
||||
// --- Out :
|
||||
// --- Returns : Nonzero if successful; otherwise 0.
|
||||
// --- Effect : Creates the MDI client window that manages the CMDIChildWnd objects.
|
||||
// This member function should be called if you override the
|
||||
// OnCreate member function directly.
|
||||
|
||||
void InitialShowWindow(WINDOWPLACEMENT& windowPlacement, UINT nCmdShow);
|
||||
// --- In : windowPlacement : The placement of the mainframe
|
||||
// that must be used the show the window initialy
|
||||
// nCmdShow :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Show the window in the correct state
|
||||
|
||||
BOOL SetPaletteState(BOOL bBackGround = TRUE);
|
||||
// --- In : bBackGround : whether the DIB on the MDI CLIENT is treated as
|
||||
// a background image or foreground for palette selecting
|
||||
// --- Out :
|
||||
// --- Returns : successful or not
|
||||
// --- Effect : Set this parameter always BEFORE you set a new Background
|
||||
|
||||
BOOL GetPaletteState();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : whether the DIB on the MDI CLIENT is treated as
|
||||
// a background or foreground image for palette selecting
|
||||
// --- Effect :
|
||||
|
||||
BOOL SetWallPaper(COLORREF rgbColor = RGB(192, 192, 192),
|
||||
EWallOrg eWallOrganisation = WP_Center , COXDIB* pDib = NULL );
|
||||
// --- In : rgbColor : The background color of te MDICLIENT
|
||||
// eWallOrganisation : the organisation of the bitmap on the MDI CLIENT
|
||||
// pDib : the Device Independant Bitmap to be painted on the MDI CLIENT
|
||||
// --- Out :
|
||||
// --- Returns : Succeeded or not
|
||||
// --- Effect : Paints a DIB with a special organisation and back color on the
|
||||
// Client area of the MDI Client of this mainframe
|
||||
|
||||
virtual ~COXMainFrame();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of object
|
||||
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
// Message handlers ---------------------------------------------------------
|
||||
//{{AFX_MSG(COXMainFrame)
|
||||
afx_msg void OnPaletteChanged(CWnd* pFocusWnd);
|
||||
afx_msg BOOL OnQueryNewPalette();
|
||||
afx_msg void OnClose();
|
||||
afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,146 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXMDIClient
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : xmdiclt.h
|
||||
|
||||
// This software along with its related components, documentation and files ("The Libraries")
|
||||
// is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
|
||||
// governed by a software license agreement ("Agreement"). Copies of the Agreement are
|
||||
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
|
||||
// to obtain this file, or directly from our office. For a copy of the license governing
|
||||
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from CWnd
|
||||
|
||||
// YES Is a Cwnd.
|
||||
// YES Two stage creation (constructor & Create())
|
||||
// YES Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// NO Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
// This class implements a MDIClient area. This is the window in the client area
|
||||
// of the MDiFrameWindow and which manages all the mdichild framewindows
|
||||
// This implementation takes care of painting a bitmap on its paint DC
|
||||
|
||||
// Remark:
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __XMDICLT_H__
|
||||
#define __XMDICLT_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "OXDllExt.h"
|
||||
|
||||
#include "oxdib.h" // Encapsulation of a Device independant bitmap
|
||||
#include "screen.h" // Enumeration of possible screen organisations
|
||||
|
||||
|
||||
// User message for sending palette changes to this MDI CLIENT
|
||||
#define WM_DOMDICLTREALIZE (WM_USER + 104)
|
||||
|
||||
class OX_CLASS_DECL COXMDIClient : public CWnd
|
||||
{
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
protected:
|
||||
COXDIB m_bmpBackGround;
|
||||
CPalette* m_pPictPalette;
|
||||
CBitmap* m_pTotalNewBitmap;
|
||||
COLORREF m_rgbBkColor;
|
||||
EWallOrg m_eWallPaperOrganisation;
|
||||
|
||||
CSize m_sizeClient;
|
||||
CSize m_DibSize;
|
||||
|
||||
HBITMAP m_hOldDestBitmap;
|
||||
HBITMAP m_hOldSrcBitmap;
|
||||
CDC m_MemDCSrc;
|
||||
CDC m_MemDCDest;
|
||||
|
||||
BOOL m_bFirstCreation;
|
||||
BOOL m_bBackGround;
|
||||
BOOL m_bWin4;
|
||||
|
||||
static WNDPROC pfnSuper;
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
COXMDIClient();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Contructor of object
|
||||
// It will initialize the internal state
|
||||
|
||||
virtual ~COXMDIClient();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of object
|
||||
|
||||
BOOL SetPaletteState(BOOL bBackGround = TRUE, EPalUpdate ePalUpdate = PU_IntelUpdate);
|
||||
// --- In : bBackGround : whether the DIB on the MDI CLIENT is treated as
|
||||
// a background image or foreground for palette selecting
|
||||
// ePalUpdate : Specifying PU_NoUpdate causes the palette not to be realized now
|
||||
// Specifying PU_IntelUpdate causes the palette to be realized intelligently
|
||||
// Specifying PU_ForceUpdate causes the palette to be realized now
|
||||
// --- Out :
|
||||
// --- Returns : successful or not
|
||||
// --- Effect : Set this parameter always BEFORE you set a new Background
|
||||
|
||||
BOOL GetPaletteState();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : whether the DIB on the MDI CLIENT is treated as
|
||||
// a background or foreground image for palette selecting
|
||||
// --- Effect :
|
||||
|
||||
BOOL SetNewBackGround(COLORREF rgbColor = GetSysColor(COLOR_APPWORKSPACE),
|
||||
EWallOrg eWallOrganisation = WP_Center , COXDIB* pDib = NULL );
|
||||
// --- In : rgbColor : The background color of te MDICLIENT
|
||||
// eWallOrganisation : the organisation of the bitmap on the MDI CLIENT
|
||||
// pDib : the Device Independant Bitmap to be painted on the MDI CLIENT
|
||||
// --- Out :
|
||||
// --- Returns : Succeeded or not
|
||||
// --- Effect : Paints a DIB with a special organisation and back color on the
|
||||
// client area of this MDI client window
|
||||
|
||||
virtual WNDPROC* GetSuperWndProcAddr();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns : The address in which to store the default WndProc for this class.
|
||||
// --- Effect : Needed when we subclass a Windows object
|
||||
|
||||
|
||||
protected:
|
||||
BOOL PrepareMemDC(int nWidth, int nHeight);
|
||||
|
||||
// Message handlers ---------------------------------------------------------
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(COXMDIClient)
|
||||
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
|
||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||
//}}AFX_MSG
|
||||
|
||||
afx_msg LRESULT OnDoMDICltRealize(WPARAM wParam, LPARAM lParam); // user message
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
#endif
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
1734
UltimateToolbox93_samples/Ultimate Toolbox/archive/include/oxmdisp.h
Normal file
1734
UltimateToolbox93_samples/Ultimate Toolbox/archive/include/oxmdisp.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,69 @@
|
||||
// ChildFrm.cpp : implementation of the CChildFrame class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Communicator.h"
|
||||
|
||||
#include "ChildFrm.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CChildFrame
|
||||
|
||||
IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
|
||||
//{{AFX_MSG_MAP(CChildFrame)
|
||||
// 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()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CChildFrame construction/destruction
|
||||
|
||||
CChildFrame::CChildFrame()
|
||||
{
|
||||
// TODO: add member initialization code here
|
||||
|
||||
}
|
||||
|
||||
CChildFrame::~CChildFrame()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
|
||||
{
|
||||
// TODO: Modify the Window class or styles here by modifying
|
||||
// the CREATESTRUCT cs
|
||||
cs.style &= ~WS_MAXIMIZEBOX;
|
||||
cs.style &= ~WS_MINIMIZEBOX;
|
||||
cs.style |= WS_MAXIMIZE;
|
||||
|
||||
|
||||
return CMDIChildWnd::PreCreateWindow(cs);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CChildFrame diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CChildFrame::AssertValid() const
|
||||
{
|
||||
CMDIChildWnd::AssertValid();
|
||||
}
|
||||
|
||||
void CChildFrame::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CMDIChildWnd::Dump(dc);
|
||||
}
|
||||
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CChildFrame message handlers
|
||||
@ -0,0 +1,40 @@
|
||||
// ChildFrm.h : interface of the CChildFrame class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CChildFrame : public CMDIChildWnd
|
||||
{
|
||||
DECLARE_DYNCREATE(CChildFrame)
|
||||
public:
|
||||
CChildFrame();
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CChildFrame)
|
||||
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CChildFrame();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CChildFrame)
|
||||
// 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()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@ -0,0 +1,188 @@
|
||||
// Communicator.cpp : Defines the class behaviors for the application.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Communicator.h"
|
||||
#include "utsampleAbout.h"
|
||||
#include "MainFrm.h"
|
||||
#include "ChildFrm.h"
|
||||
#include "CommunicatorDoc.h"
|
||||
#include "CommunicatorView.h"
|
||||
#include "HexView.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCommunicatorApp
|
||||
|
||||
BEGIN_MESSAGE_MAP(CCommunicatorApp, CWinApp)
|
||||
//{{AFX_MSG_MAP(CCommunicatorApp)
|
||||
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
|
||||
// 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
|
||||
// Standard file based document commands
|
||||
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
|
||||
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCommunicatorApp construction
|
||||
|
||||
CCommunicatorApp::CCommunicatorApp()
|
||||
:
|
||||
m_pHexDocTemplate(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// The one and only CCommunicatorApp object
|
||||
|
||||
CCommunicatorApp theApp;
|
||||
static HINSTANCE g_hRichEdDLL=NULL;
|
||||
|
||||
// This identifier was generated to be statistically unique for your app.
|
||||
// You may change it if you prefer to choose a specific identifier.
|
||||
|
||||
// {F44C48E0-6DD7-11CF-8508-00AA0021F02C}
|
||||
static const CLSID clsid =
|
||||
{ 0xf44c48e0, 0x6dd7, 0x11cf, { 0x85, 0x8, 0x0, 0xaa, 0x0, 0x21, 0xf0, 0x2c } };
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCommunicatorApp initialization
|
||||
|
||||
BOOL CCommunicatorApp::InitInstance()
|
||||
{
|
||||
if (!AfxSocketInit())
|
||||
{
|
||||
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Initialize RichEdit control
|
||||
// for About Dialog
|
||||
if(g_hRichEdDLL==NULL)
|
||||
{
|
||||
g_hRichEdDLL=::LoadLibrary(_T("RICHED32.DLL"));
|
||||
if(g_hRichEdDLL==NULL)
|
||||
TRACE(_T("Cannot load library to display RichEditTextControl"));
|
||||
}
|
||||
|
||||
|
||||
// Initialize OLE libraries
|
||||
if (!AfxOleInit())
|
||||
{
|
||||
AfxMessageBox(IDP_OLE_INIT_FAILED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef _AFXDLL
|
||||
Enable3dControls(); // Call this when using MFC in a shared DLL
|
||||
#else
|
||||
Enable3dControlsStatic(); // Call this when linking to MFC statically
|
||||
#endif
|
||||
|
||||
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
|
||||
|
||||
// Register the application's document templates. Document templates
|
||||
// serve as the connection between documents, frame windows and views.
|
||||
|
||||
CMultiDocTemplate* pDocTemplate;
|
||||
pDocTemplate = new CMultiDocTemplate(
|
||||
IDR_COMMTYPE,
|
||||
RUNTIME_CLASS(CCommunicatorDoc),
|
||||
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
|
||||
RUNTIME_CLASS(CCommunicatorView));
|
||||
AddDocTemplate(pDocTemplate);
|
||||
|
||||
m_pHexDocTemplate = new CMultiDocTemplate(
|
||||
IDR_COMMTYPE,
|
||||
RUNTIME_CLASS(CCommunicatorDoc),
|
||||
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
|
||||
RUNTIME_CLASS(CHexView));
|
||||
|
||||
// Connect the COleTemplateServer to the document template.
|
||||
// The COleTemplateServer creates new documents on behalf
|
||||
// of requesting OLE containers by using information
|
||||
// specified in the document template.
|
||||
m_server.ConnectTemplate(clsid, pDocTemplate, FALSE);
|
||||
|
||||
// Register all OLE server factories as running. This enables the
|
||||
// OLE libraries to create objects from other applications.
|
||||
COleTemplateServer::RegisterAll();
|
||||
// Note: MDI applications register all server objects without regard
|
||||
// to the /Embedding or /Automation on the command line.
|
||||
|
||||
// create main MDI Frame window
|
||||
CMainFrame* pMainFrame = new CMainFrame;
|
||||
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
|
||||
return FALSE;
|
||||
m_pMainWnd = pMainFrame;
|
||||
|
||||
// Enable drag/drop open
|
||||
m_pMainWnd->DragAcceptFiles();
|
||||
|
||||
// Enable DDE Execute open
|
||||
EnableShellOpen();
|
||||
RegisterShellFileTypes(TRUE);
|
||||
|
||||
// Parse command line for standard shell commands, DDE, file open
|
||||
CCommandLineInfo cmdInfo;
|
||||
ParseCommandLine(cmdInfo);
|
||||
|
||||
// Check to see if launched as OLE server
|
||||
if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
|
||||
{
|
||||
// Application was run with /Embedding or /Automation. Don't show the
|
||||
// main window in this case.
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When a server application is launched stand-alone, it is a good idea
|
||||
// to update the system registry in case it has been damaged.
|
||||
m_server.UpdateRegistry(OAT_DISPATCH_OBJECT);
|
||||
COleObjectFactory::UpdateRegistryAll();
|
||||
|
||||
// Dispatch commands specified on the command line
|
||||
if (!ProcessShellCommand(cmdInfo))
|
||||
return FALSE;
|
||||
|
||||
// The main window has been initialized, so show and update it.
|
||||
pMainFrame->ShowWindow(m_nCmdShow);
|
||||
pMainFrame->UpdateWindow();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CAboutDlg dialog used for App About
|
||||
|
||||
|
||||
|
||||
// App command to run the dialog
|
||||
void CCommunicatorApp::OnAppAbout()
|
||||
{
|
||||
CUTSampleAboutDlg aboutDlg(IDR_MAINFRAME,ID_DESCRIPTION_FILE);
|
||||
aboutDlg.DoModal();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCommunicatorApp commands
|
||||
|
||||
int CCommunicatorApp::ExitInstance()
|
||||
{
|
||||
if (m_pHexDocTemplate != NULL)
|
||||
delete m_pHexDocTemplate;
|
||||
|
||||
// unload the library
|
||||
if(g_hRichEdDLL!=NULL)
|
||||
::FreeLibrary(g_hRichEdDLL);
|
||||
|
||||
return CWinApp::ExitInstance();
|
||||
}
|
||||
@ -0,0 +1,318 @@
|
||||
# Microsoft Developer Studio Project File - Name="Communicator" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=Communicator - Win32 Unicode_Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Communicator.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Communicator.mak" CFG="Communicator - Win32 Unicode_Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Communicator - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "Communicator - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "Communicator - Win32 Release_Shared" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "Communicator - Win32 Unicode_Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "Communicator - Win32 Unicode_Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Communicator - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 6
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\Release"
|
||||
# PROP BASE Intermediate_Dir ".\Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 5
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
|
||||
# ADD CPP /nologo /MT /W4 /GX /O2 /I "..\..\include" /I "..\..\..\include" /I "..\..\..\source\utsampleabout" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x813 /d "NDEBUG" /d "_AFXDLL"
|
||||
# ADD RSC /l 0x813 /i "..\..\..\include" /i "..\..\..\source\utsampleabout" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 /nologo /subsystem:windows /machine:I386 /out:"Communicator.exe" /section:.sdata,rws
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "Communicator - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 6
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\Debug"
|
||||
# PROP BASE Intermediate_Dir ".\Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 6
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\Debug"
|
||||
# PROP Intermediate_Dir ".\Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
|
||||
# ADD CPP /nologo /MDd /W4 /Gm /GX /ZI /Od /I "..\..\include" /I "..\..\..\include" /I "..\..\..\source\utsampleabout" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /FR /Yu"stdafx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x813 /d "_DEBUG" /d "_AFXDLL"
|
||||
# ADD RSC /l 0x813 /i "..\..\..\include" /i "..\..\..\source\utsampleabout" /d "_DEBUG" /d "_AFXDLL"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386
|
||||
# ADD LINK32 /nologo /subsystem:windows /profile /debug /machine:I386 /out:"Communicator.exe" /section:.sdata,rws
|
||||
|
||||
!ELSEIF "$(CFG)" == "Communicator - Win32 Release_Shared"
|
||||
|
||||
# PROP BASE Use_MFC 5
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Communic"
|
||||
# PROP BASE Intermediate_Dir "Communic"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 6
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release_Shared"
|
||||
# PROP Intermediate_Dir "Release_Shared"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W4 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /GX /O2 /I "..\..\include" /I "..\..\..\include" /I "..\..\..\source\utsampleabout" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x813 /d "NDEBUG"
|
||||
# ADD RSC /l 0x813 /i "..\..\..\include" /i "..\..\..\source\utsampleabout" /d "NDEBUG" /d "_AFXDLL"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 /out:"Communicator.exe" /section:.sdata,rws
|
||||
# SUBTRACT BASE LINK32 /pdb:none
|
||||
# ADD LINK32 /nologo /subsystem:windows /machine:I386 /out:"Communicator.exe" /section:.sdata,rws
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "Communicator - Win32 Unicode_Debug"
|
||||
|
||||
# PROP BASE Use_MFC 6
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Communi0"
|
||||
# PROP BASE Intermediate_Dir "Communi0"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 6
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Unicode_Debug"
|
||||
# PROP Intermediate_Dir "Unicode_Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MDd /W4 /Gm /GX /Zi /Od /I "..\..\..\include" /I "..\..\..\source\utsampleabout" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /FR /Yu"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /MDd /W4 /Gm /GX /ZI /Od /I "..\..\include" /I "..\..\..\include" /I "..\..\..\source\utsampleabout" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /D "_UNICODE" /FR /Yu"stdafx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x813 /i "..\..\..\include" /i "..\..\..\source\utsampleabout" /d "_DEBUG" /d "_AFXDLL"
|
||||
# ADD RSC /l 0x813 /i "..\..\..\include" /i "..\..\..\source\utsampleabout" /d "_DEBUG" /d "_AFXDLL"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /subsystem:windows /profile /debug /machine:I386 /out:"Communicator.exe" /section:.sdata,rws
|
||||
# ADD LINK32 /nologo /entry:"wWinMainCRTStartup" /subsystem:windows /profile /debug /machine:I386 /out:"Communicator.exe" /section:.sdata,rws
|
||||
|
||||
!ELSEIF "$(CFG)" == "Communicator - Win32 Unicode_Release"
|
||||
|
||||
# PROP BASE Use_MFC 5
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Communi1"
|
||||
# PROP BASE Intermediate_Dir "Communi1"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 5
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Unicode_Release"
|
||||
# PROP Intermediate_Dir "Unicode_Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W4 /GX /O2 /I "..\..\..\include" /I "..\..\..\source\utsampleabout" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /MT /W4 /GX /O2 /I "..\..\include" /I "..\..\..\include" /I "..\..\..\source\utsampleabout" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_UNICODE" /Yu"stdafx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x813 /i "..\..\..\include" /i "..\..\..\source\utsampleabout" /d "NDEBUG"
|
||||
# ADD RSC /l 0x813 /i "..\..\..\include" /i "..\..\..\source\utsampleabout" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 /out:"Communicator.exe" /section:.sdata,rws
|
||||
# SUBTRACT BASE LINK32 /pdb:none
|
||||
# ADD LINK32 /nologo /entry:"wWinMainCRTStartup" /subsystem:windows /machine:I386 /out:"Communicator.exe" /section:.sdata,rws
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Communicator - Win32 Release"
|
||||
# Name "Communicator - Win32 Debug"
|
||||
# Name "Communicator - Win32 Release_Shared"
|
||||
# Name "Communicator - Win32 Unicode_Debug"
|
||||
# Name "Communicator - Win32 Unicode_Release"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
|
||||
# Begin Group "UTSource"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\source\OXBlob.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\source\OXCommMsg.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\source\OXCommunicator.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\source\OXVariant.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Source\UTSampleAbout\UTSampleAbout.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ChildFrm.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Communicator.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Communicator.odl
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Communicator.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CommunicatorDoc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CommunicatorView.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\HexView.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MainFrm.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\OXDataCommunicator.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ReadMe.txt
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SendDataDlg.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
# ADD CPP /Yc"stdafx.h"
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ChildFrm.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Communicator.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CommunicatorDoc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CommunicatorView.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\HexView.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MainFrm.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\OXDataCommunicator.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SendDataDlg.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\res\Communicator.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\res\Communicator.rc2
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\res\CommunicatorDoc.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CommunicatorInfo.rtf
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Communicator"=.\Communicator.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
// Communicator.h : main header file for the COMMUNICATOR application
|
||||
//
|
||||
//----------------- Dundas Software ----------------------------------------
|
||||
//========================================================================
|
||||
|
||||
#ifndef __AFXWIN_H__
|
||||
#error include 'stdafx.h' before including this file for PCH
|
||||
#endif
|
||||
|
||||
#include "resource.h" // main symbols
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCommunicatorApp:
|
||||
// See Communicator.cpp for the implementation of this class
|
||||
//
|
||||
|
||||
class CCommunicatorApp : public CWinApp
|
||||
{
|
||||
public:
|
||||
CCommunicatorApp();
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CCommunicatorApp)
|
||||
public:
|
||||
virtual BOOL InitInstance();
|
||||
virtual int ExitInstance();
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
COleTemplateServer m_server;
|
||||
// Server object for document creation
|
||||
|
||||
CMultiDocTemplate* m_pHexDocTemplate;
|
||||
|
||||
//{{AFX_MSG(CCommunicatorApp)
|
||||
afx_msg void OnAppAbout();
|
||||
// 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()
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@ -0,0 +1,39 @@
|
||||
// Communicator.odl : type library source for Communicator.exe
|
||||
|
||||
// This file will be processed by the Make Type Library (mktyplib) tool to
|
||||
// produce the type library (Communicator.tlb).
|
||||
|
||||
[ uuid(F44C48E1-6DD7-11CF-8508-00AA0021F02C), version(1.0) ]
|
||||
library Communicator
|
||||
{
|
||||
importlib("stdole32.tlb");
|
||||
|
||||
// Primary dispatch interface for CCommunicatorDoc
|
||||
|
||||
[ uuid(F44C48E2-6DD7-11CF-8508-00AA0021F02C) ]
|
||||
dispinterface IComm
|
||||
{
|
||||
properties:
|
||||
// NOTE - ClassWizard will maintain property information here.
|
||||
// Use extreme caution when editing this section.
|
||||
//{{AFX_ODL_PROP(CCommunicatorDoc)
|
||||
//}}AFX_ODL_PROP
|
||||
|
||||
methods:
|
||||
// NOTE - ClassWizard will maintain method information here.
|
||||
// Use extreme caution when editing this section.
|
||||
//{{AFX_ODL_METHOD(CCommunicatorDoc)
|
||||
//}}AFX_ODL_METHOD
|
||||
|
||||
};
|
||||
|
||||
// Class information for CCommunicatorDoc
|
||||
|
||||
[ uuid(F44C48E0-6DD7-11CF-8508-00AA0021F02C) ]
|
||||
coclass CCommunicatorDoc
|
||||
{
|
||||
[default] dispinterface IComm;
|
||||
};
|
||||
|
||||
//{{AFX_APPEND_ODL}}
|
||||
};
|
||||
@ -0,0 +1,404 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDR_COMMTYPE ICON DISCARDABLE "res\\CommunicatorDoc.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDR_MAINFRAME MENU PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&New\tCtrl+N", ID_FILE_NEW
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", ID_APP_EXIT
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&About Communicator...", ID_APP_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
IDR_COMMTYPE MENU PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&New\tCtrl+N", ID_FILE_NEW
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", ID_APP_EXIT
|
||||
END
|
||||
POPUP "&Window"
|
||||
BEGIN
|
||||
MENUITEM "Tile ", ID_WINDOW_TILE_VERT
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&About Communicator...", ID_APP_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,1
|
||||
PRODUCTVERSION 1,0,0,1
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904B0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "\0"
|
||||
VALUE "FileDescription", "COMMUNICATOR MFC Application\0"
|
||||
VALUE "FileVersion", "1, 0, 0, 1\0"
|
||||
VALUE "InternalName", "COMMUNICATOR\0"
|
||||
VALUE "LegalCopyright", "Copyright © 1996\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename", "COMMUNICATOR.EXE\0"
|
||||
VALUE "ProductName", "COMMUNICATOR Application\0"
|
||||
VALUE "ProductVersion", "1, 0, 0, 1\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // !_MAC
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
//
|
||||
|
||||
IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDP_OLE_INIT_FAILED "OLE initialization failed. Make sure that the OLE libraries are the correct version."
|
||||
IDP_SOCKETS_INIT_FAILED "Windows sockets initialization failed."
|
||||
END
|
||||
|
||||
STRINGTABLE PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
IDR_MAINFRAME "Communicator"
|
||||
IDR_COMMTYPE "\nComm\nComm\nCommun Files (*.cmm)\n.CMM\nCommunicator.Document\nComm Document"
|
||||
IDS_INVALID_VALUE "The specified value is not valid for this type"
|
||||
IDS_FAILED_LISTEN "The Listen failed"
|
||||
IDS_FAILED_CONNECT "Failed to establish connection"
|
||||
END
|
||||
|
||||
STRINGTABLE PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_APP_TITLE "Communicator"
|
||||
AFX_IDS_IDLEMESSAGE "Ready"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_INDICATOR_EXT "EXT"
|
||||
ID_INDICATOR_CAPS "CAP"
|
||||
ID_INDICATOR_NUM "NUM"
|
||||
ID_INDICATOR_SCRL "SCRL"
|
||||
ID_INDICATOR_OVR "OVR"
|
||||
ID_INDICATOR_REC "REC"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_FILE_NEW "Create a new document\nNew"
|
||||
ID_FILE_OPEN "Open an existing document\nOpen"
|
||||
ID_FILE_CLOSE "Close the active document\nClose"
|
||||
ID_FILE_SAVE "Save the active document\nSave"
|
||||
ID_FILE_SAVE_AS "Save the active document with a new name\nSave As"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_APP_ABOUT "Display program information, version number and copyright\nAbout"
|
||||
ID_APP_EXIT "Quit the application; prompts to save documents\nExit"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_FILE_MRU_FILE1 "Open this document"
|
||||
ID_FILE_MRU_FILE2 "Open this document"
|
||||
ID_FILE_MRU_FILE3 "Open this document"
|
||||
ID_FILE_MRU_FILE4 "Open this document"
|
||||
ID_FILE_MRU_FILE5 "Open this document"
|
||||
ID_FILE_MRU_FILE6 "Open this document"
|
||||
ID_FILE_MRU_FILE7 "Open this document"
|
||||
ID_FILE_MRU_FILE8 "Open this document"
|
||||
ID_FILE_MRU_FILE9 "Open this document"
|
||||
ID_FILE_MRU_FILE10 "Open this document"
|
||||
ID_FILE_MRU_FILE11 "Open this document"
|
||||
ID_FILE_MRU_FILE12 "Open this document"
|
||||
ID_FILE_MRU_FILE13 "Open this document"
|
||||
ID_FILE_MRU_FILE14 "Open this document"
|
||||
ID_FILE_MRU_FILE15 "Open this document"
|
||||
ID_FILE_MRU_FILE16 "Open this document"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_NEXT_PANE "Switch to the next window pane\nNext Pane"
|
||||
ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_SCSIZE "Change the window size"
|
||||
AFX_IDS_SCMOVE "Change the window position"
|
||||
AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_SCRESTORE "Restore the window to normal size"
|
||||
AFX_IDS_SCTASKLIST "Activate Task List"
|
||||
AFX_IDS_MDICHILD "Activate this window"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_DESCRIPTION_FILE "communicatorinfo.rtf"
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Dutch (Belgium) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NLB)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_DUTCH, SUBLANG_DUTCH_BELGIAN
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDR_MAINFRAME ICON DISCARDABLE "res\\Communicator.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_SEND_DATA DIALOG DISCARDABLE 0, 0, 190, 230
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Send data"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
EDITTEXT IDC_VALUE,7,104,155,14,ES_AUTOHSCROLL
|
||||
DEFPUSHBUTTON "&Add",IDC_ADD,70,124,50,14
|
||||
LISTBOX IDC_LIST,7,150,176,49,WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "OK",IDOK,40,206,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,100,206,50,14
|
||||
CONTROL "&Empty",IDC_EMPTY,"Button",BS_AUTORADIOBUTTON |
|
||||
WS_GROUP,17,20,35,10
|
||||
CONTROL "&Null",IDC_NULL,"Button",BS_AUTORADIOBUTTON,17,33,28,10
|
||||
CONTROL "&Bool",IDC_BOOL,"Button",BS_AUTORADIOBUTTON,17,46,30,10
|
||||
CONTROL "&UI1 (char)",IDC_UI1,"Button",BS_AUTORADIOBUTTON,17,59,
|
||||
45,10
|
||||
CONTROL "&I2 (short)",IDC_I2,"Button",BS_AUTORADIOBUTTON,63,20,
|
||||
41,10
|
||||
CONTROL "&I4 (int)",IDC_I4,"Button",BS_AUTORADIOBUTTON,63,33,33,
|
||||
10
|
||||
CONTROL "&CY (Currency)",IDC_CY,"Button",BS_AUTORADIOBUTTON,63,
|
||||
46,57,10
|
||||
CONTROL "&R4 (float)",IDC_R4,"Button",BS_AUTORADIOBUTTON,63,59,
|
||||
43,10
|
||||
CONTROL "&R8 (double)",IDC_R8,"Button",BS_AUTORADIOBUTTON,120,20,
|
||||
51,10
|
||||
CONTROL "&Str",IDC_BSTR,"Button",BS_AUTORADIOBUTTON,120,33,29,10
|
||||
CONTROL "&Date",IDC_DATE,"Button",BS_AUTORADIOBUTTON,120,46,33,
|
||||
10
|
||||
CONTROL "&Error",IDC_ERROR,"Button",BS_AUTORADIOBUTTON,120,59,31,
|
||||
10
|
||||
CONTROL "&Binary Large Object",IDC_BINARY,"Button",
|
||||
BS_AUTORADIOBUTTON,63,74,73,10
|
||||
LTEXT "&Value",IDC_STATIC,7,91,19,8
|
||||
GROUPBOX "Type",IDC_STATIC,7,7,176,81
|
||||
DEFPUSHBUTTON "...",IDC_BROWSE,168,104,15,14
|
||||
END
|
||||
|
||||
IDD_COMMUNICATOR_FORM DIALOG DISCARDABLE 0, 0, 246, 277
|
||||
STYLE WS_CHILD
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
GROUPBOX "Server",IDC_SERVER_GROUP,7,7,232,103
|
||||
LTEXT "Local Address",IDC_LOCAL_ADDRESS_LABEL,15,17,46,8
|
||||
EDITTEXT IDC_LOCAL_ADDRESS,15,29,62,12,ES_AUTOHSCROLL |
|
||||
ES_READONLY | NOT WS_TABSTOP
|
||||
LTEXT "Local Port",IDC_LOCAL_PORT_LABEL,82,17,35,8
|
||||
EDITTEXT IDC_LOCAL_PORT,82,29,34,12,ES_AUTOHSCROLL
|
||||
PUSHBUTTON "&Listen",IDC_LISTEN,127,28,50,14
|
||||
PUSHBUTTON "Shut&down",IDC_SHUTDOWN,182,28,50,14
|
||||
LTEXT "Client Addresses",IDC_CLIENT_ADDRESSES_LABEL,15,47,60,8
|
||||
LISTBOX IDC_CLIENT_ADDRESSES,15,58,157,44,LBS_NOINTEGRALHEIGHT |
|
||||
LBS_EXTENDEDSEL | WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "&Send",IDC_SEND_CLIENT,182,60,50,14
|
||||
PUSHBUTTON "&Disconnect",IDC_DISCONNECT_CLIENT,182,85,50,14
|
||||
GROUPBOX "Client",IDC_CLIENT_GROUP,7,113,232,50
|
||||
LTEXT "Remote Address",IDC_REMOTE_ADDRESS_LABEL,14,127,57,8
|
||||
EDITTEXT IDC_REMOTE_ADDRESS,14,139,62,12,ES_AUTOHSCROLL | NOT
|
||||
WS_TABSTOP
|
||||
LTEXT "Remote Port",IDC_REMOTE_PORT_LABEL,82,128,39,8
|
||||
EDITTEXT IDC_REMOTE_PORT,82,138,34,12,ES_AUTOHSCROLL
|
||||
PUSHBUTTON "&Connect",IDC_CONNECT_SERVER,125,126,50,14
|
||||
PUSHBUTTON "&Send",IDC_SEND_SERVER,182,126,50,14
|
||||
PUSHBUTTON "Disconnect",IDC_DISCONNECT_SERVER,182,144,50,14
|
||||
PUSHBUTTON "&Spy",IDC_SPY,59,170,50,14
|
||||
LTEXT "Received Data",-1,7,175,47,8
|
||||
EDITTEXT IDC_RECEIVED_DATA,7,189,232,61,ES_MULTILINE |
|
||||
ES_AUTOHSCROLL | WS_VSCROLL
|
||||
PUSHBUTTON "Cancel Actions",IDC_CANCEL,93,256,59,14
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_SEND_DATA, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 183
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 220
|
||||
END
|
||||
|
||||
IDD_COMMUNICATOR_FORM, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 239
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 270
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
|
||||
"#define _AFX_NO_OLE_RESOURCES\r\n"
|
||||
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
|
||||
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
|
||||
"#include ""utsampleAbout.rc""\r\n"
|
||||
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
|
||||
"#ifdef _WIN32\r\n"
|
||||
"LANGUAGE 9, 1\r\n"
|
||||
"#pragma code_page(1252)\r\n"
|
||||
"#endif\r\n"
|
||||
"#include ""res\\Communicator.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
|
||||
"#include ""afxres.rc"" // Standard components\r\n"
|
||||
"#endif\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // Dutch (Belgium) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
#define _AFX_NO_SPLITTER_RESOURCES
|
||||
#define _AFX_NO_OLE_RESOURCES
|
||||
#define _AFX_NO_TRACKER_RESOURCES
|
||||
#define _AFX_NO_PROPERTY_RESOURCES
|
||||
#include "utsampleAbout.rc"
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE 9, 1
|
||||
#pragma code_page(1252)
|
||||
#endif
|
||||
#include "res\Communicator.rc2" // non-Microsoft Visual C++ edited resources
|
||||
#include "afxres.rc" // Standard components
|
||||
#endif
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
REGEDIT
|
||||
; This .REG file may be used by your SETUP program.
|
||||
; If a SETUP program is not available, the entries below will be
|
||||
; registered in your InitInstance automatically with a call to
|
||||
; CWinApp::RegisterShellFileTypes and COleObjectFactory::UpdateRegistryAll.
|
||||
|
||||
HKEY_CLASSES_ROOT\.CMM = Communicator.Document
|
||||
HKEY_CLASSES_ROOT\Communicator.Document\shell\open\command = COMMUNICATOR.EXE %1
|
||||
HKEY_CLASSES_ROOT\Communicator.Document\shell\open\ddeexec = [open("%1")]
|
||||
HKEY_CLASSES_ROOT\Communicator.Document\shell\open\ddeexec\application = COMMUNICATOR
|
||||
; note: the application is optional
|
||||
; (it defaults to the app name in "command")
|
||||
|
||||
HKEY_CLASSES_ROOT\Communicator.Document = Comm Document
|
||||
HKEY_CLASSES_ROOT\Communicator.Document\CLSID = {F44C48E0-6DD7-11CF-8508-00AA0021F02C}
|
||||
|
||||
HKEY_CLASSES_ROOT\CLSID\{F44C48E0-6DD7-11CF-8508-00AA0021F02C} = Comm Document
|
||||
HKEY_CLASSES_ROOT\CLSID\{F44C48E0-6DD7-11CF-8508-00AA0021F02C}\LocalServer32 = COMMUNICATOR.EXE
|
||||
HKEY_CLASSES_ROOT\CLSID\{F44C48E0-6DD7-11CF-8508-00AA0021F02C}\ProgId = Communicator.Document
|
||||
@ -0,0 +1,465 @@
|
||||
// CommunicatorDoc.cpp : implementation of the CCommunicatorDoc class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Communicator.h"
|
||||
|
||||
#include "CommunicatorDoc.h"
|
||||
#include "OXCommMsg.h"
|
||||
#include "HexView.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCommunicatorDoc
|
||||
|
||||
IMPLEMENT_DYNCREATE(CCommunicatorDoc, CDocument)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CCommunicatorDoc, CDocument)
|
||||
//{{AFX_MSG_MAP(CCommunicatorDoc)
|
||||
ON_BN_CLICKED(IDC_SPY, OnSpy)
|
||||
ON_BN_CLICKED(IDC_CANCEL, OnCancel)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
BEGIN_DISPATCH_MAP(CCommunicatorDoc, CDocument)
|
||||
//{{AFX_DISPATCH_MAP(CCommunicatorDoc)
|
||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code!
|
||||
//}}AFX_DISPATCH_MAP
|
||||
END_DISPATCH_MAP()
|
||||
|
||||
// Note: we add support for IID_IComm to support typesafe binding
|
||||
// from VBA. This IID must match the GUID that is attached to the
|
||||
// dispinterface in the .ODL file.
|
||||
|
||||
// {F44C48E2-6DD7-11CF-8508-00AA0021F02C}
|
||||
static const IID IID_IComm =
|
||||
{ 0xf44c48e2, 0x6dd7, 0x11cf, { 0x85, 0x8, 0x0, 0xaa, 0x0, 0x21, 0xf0, 0x2c } };
|
||||
|
||||
BEGIN_INTERFACE_MAP(CCommunicatorDoc, CDocument)
|
||||
INTERFACE_PART(CCommunicatorDoc, IID_IComm, Dispatch)
|
||||
END_INTERFACE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCommunicatorDoc construction/destruction
|
||||
|
||||
CCommunicatorDoc::CCommunicatorDoc()
|
||||
:
|
||||
m_dataCommunicator(this),
|
||||
m_pCancelWnd(NULL),
|
||||
m_nTimeOut(10000)
|
||||
{
|
||||
m_pCancelWnd = AfxGetMainWnd();
|
||||
|
||||
EnableAutomation();
|
||||
|
||||
AfxOleLockApp();
|
||||
}
|
||||
|
||||
CCommunicatorDoc::~CCommunicatorDoc()
|
||||
{
|
||||
AfxOleUnlockApp();
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
BOOL CCommunicatorDoc::OnNewDocument()
|
||||
{
|
||||
if (!CDocument::OnNewDocument())
|
||||
return FALSE;
|
||||
|
||||
// Get the local server name
|
||||
const int nMaxAddressLength = 128;
|
||||
char szLocalAddress[nMaxAddressLength];
|
||||
gethostname(szLocalAddress, nMaxAddressLength);
|
||||
m_sLocalAddress = szLocalAddress;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CString CCommunicatorDoc::GetLocalAddress() const
|
||||
{
|
||||
return m_sLocalAddress;
|
||||
}
|
||||
|
||||
UINT CCommunicatorDoc::GetLocalPort() const
|
||||
{
|
||||
CString sAddress;
|
||||
UINT nPort;
|
||||
if ((m_dataCommunicator.m_hSocket != INVALID_SOCKET) &&
|
||||
((CAsyncSocket*)&m_dataCommunicator)->GetSockName(sAddress, nPort))
|
||||
{
|
||||
return nPort;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL CCommunicatorDoc::IsOpen()
|
||||
{
|
||||
return m_dataCommunicator.IsOpen();
|
||||
}
|
||||
|
||||
BOOL CCommunicatorDoc::IsListening()
|
||||
{
|
||||
return m_dataCommunicator.IsListening();
|
||||
}
|
||||
|
||||
BOOL CCommunicatorDoc::IsBlocking()
|
||||
{
|
||||
return m_dataCommunicator.AreAnyBlocking();
|
||||
}
|
||||
|
||||
void CCommunicatorDoc::CancelBlocking()
|
||||
{
|
||||
m_dataCommunicator.CancelAllBlockingCalls();
|
||||
}
|
||||
|
||||
BOOL CCommunicatorDoc::Listen(long nServerPort)
|
||||
{
|
||||
BOOL bSuccess = TRUE;
|
||||
if (m_dataCommunicator.m_hSocket != INVALID_SOCKET);
|
||||
{
|
||||
if (m_dataCommunicator.Create(nServerPort) &&
|
||||
m_dataCommunicator.Listen())
|
||||
{
|
||||
m_dataCommunicator.Initialize(m_nTimeOut, m_pCancelWnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE(_T("CComServerDoc::Listen : Failed to create socket server\n"));
|
||||
m_dataCommunicator.Close();
|
||||
bSuccess = FALSE;
|
||||
}
|
||||
}
|
||||
ASSERT(bSuccess == m_dataCommunicator.IsListening());
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
void CCommunicatorDoc::Shutdown()
|
||||
{
|
||||
// ... m_pDataCommunicator may already be NULL
|
||||
TRY
|
||||
{
|
||||
m_dataCommunicator.Close();
|
||||
}
|
||||
END_TRY
|
||||
// Warn view of shutdown
|
||||
UpdateAllViews(NULL, NotifyRemoveAllClients, NULL);
|
||||
}
|
||||
|
||||
void CCommunicatorDoc::DisconnectClient(HCLIENT_COMMUNICATOR hClient)
|
||||
{
|
||||
COXCommunicator* pClientCommunicator = m_dataCommunicator.GetClientCommunicator(hClient);
|
||||
if (pClientCommunicator == NULL)
|
||||
return;
|
||||
TRY
|
||||
{
|
||||
pClientCommunicator->Close();
|
||||
}
|
||||
END_TRY
|
||||
|
||||
// Warn view
|
||||
CHintData hintData;
|
||||
hintData.m_hClient = hClient;
|
||||
UpdateAllViews(NULL, NotifyRemoveClient, &hintData);
|
||||
}
|
||||
|
||||
BOOL CCommunicatorDoc::Send(HCLIENT_COMMUNICATOR hClient, COXCommMsg* pCommMsg)
|
||||
{
|
||||
ASSERT(pCommMsg != NULL);
|
||||
COXCommunicator* pClientCommunicator = m_dataCommunicator.GetClientCommunicator(hClient);
|
||||
if (pClientCommunicator == NULL)
|
||||
return FALSE;
|
||||
BOOL bSuccess = FALSE;
|
||||
TRY
|
||||
{
|
||||
pCommMsg->Serialize(*pClientCommunicator->GetOutStream());
|
||||
pClientCommunicator->GetOutStream()->Flush();
|
||||
bSuccess = TRUE;
|
||||
}
|
||||
END_TRY
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
BOOL CCommunicatorDoc::ConnectServer(CString sRemoteAddress, int nRemotePort, int nLocalPort)
|
||||
{
|
||||
BOOL bSuccess = TRUE;
|
||||
if (!m_dataCommunicator.Create(nLocalPort) ||
|
||||
!(m_dataCommunicator.Initialize(m_nTimeOut, m_pCancelWnd), TRUE) ||
|
||||
!m_dataCommunicator.Connect(sRemoteAddress, nRemotePort))
|
||||
{
|
||||
TRACE(_T("CComServerDoc::ConnectServer : Failed to create socket server\n"));
|
||||
|
||||
m_dataCommunicator.Close();
|
||||
bSuccess = FALSE;
|
||||
}
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
BOOL CCommunicatorDoc::SendServer(COXCommMsg* pCommMsg)
|
||||
{
|
||||
BOOL bSuccess = FALSE;
|
||||
TRY
|
||||
{
|
||||
if (m_dataCommunicator.GetOutStream() != NULL)
|
||||
{
|
||||
pCommMsg->Serialize(*m_dataCommunicator.GetOutStream());
|
||||
m_dataCommunicator.GetOutStream()->Flush();
|
||||
bSuccess = TRUE;
|
||||
}
|
||||
}
|
||||
END_TRY
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
void CCommunicatorDoc::OnReceive(HCLIENT_COMMUNICATOR hClient, COXCommunicator* pCommunicator, int nErrorCode)
|
||||
{
|
||||
POSITION pos = GetFirstViewPosition();
|
||||
if (pos != NULL)
|
||||
GetNextView(pos);
|
||||
if (pos == NULL)
|
||||
// At most one view is attached to this doc, which cannot be a Spy view
|
||||
OnReceiveDirect(hClient, pCommunicator, nErrorCode);
|
||||
else
|
||||
// More than one view is attached to this doc,
|
||||
// at least one of them must be Spy view
|
||||
OnReceiveHex(hClient, pCommunicator, nErrorCode);
|
||||
}
|
||||
|
||||
void CCommunicatorDoc::OnReceiveDirect(HCLIENT_COMMUNICATOR hClient,
|
||||
COXCommunicator* pCommunicator, int nErrorCode)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(nErrorCode);
|
||||
|
||||
if (pCommunicator->GetMaxReadable() == 0)
|
||||
// Ignore no data
|
||||
return;
|
||||
|
||||
CArchive* pInStream = pCommunicator->GetInStream();
|
||||
|
||||
CHintData hintData;
|
||||
COXCommMsg commMsg;
|
||||
|
||||
BOOL bVariantSuccess = FALSE;
|
||||
|
||||
// Read the data directly in a variant array
|
||||
TRY
|
||||
{
|
||||
commMsg.Serialize(*pInStream);
|
||||
bVariantSuccess = TRUE;
|
||||
}
|
||||
CATCH(CFileException, e)
|
||||
{
|
||||
TRACE(_T("CComServerDoc::OnClientReceive : Catching CFileException\n"));
|
||||
}
|
||||
AND_CATCH(CArchiveException, e)
|
||||
{
|
||||
TRACE(_T("CComServerDoc::OnClientReceive : Catching CArchiveException\n"));
|
||||
}
|
||||
END_CATCH
|
||||
|
||||
hintData.m_hClient = hClient;
|
||||
hintData.m_pData = NULL;
|
||||
hintData.m_nDataLength = 0;
|
||||
if (bVariantSuccess)
|
||||
hintData.m_pCommMsg = &commMsg;
|
||||
UpdateAllViews(NULL, NotifyAddData, &hintData);
|
||||
}
|
||||
|
||||
void CCommunicatorDoc::OnReceiveHex(HCLIENT_COMMUNICATOR hClient, COXCommunicator* pCommunicator, int nErrorCode)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(nErrorCode);
|
||||
|
||||
if (pCommunicator->GetMaxReadable() == 0)
|
||||
// Ignore no data
|
||||
return;
|
||||
|
||||
CArchive* pInStream = pCommunicator->GetInStream();
|
||||
|
||||
CHintData hintData;
|
||||
UINT nDataLength = 0;
|
||||
BYTE* pData = NULL;
|
||||
COXCommMsg commMsg;
|
||||
|
||||
BOOL bDataSuccess = FALSE;
|
||||
BOOL bVariantSuccess = FALSE;
|
||||
|
||||
// First read into memory block
|
||||
CMemFile memFile;
|
||||
TRY
|
||||
{
|
||||
unsigned char pc[2];;
|
||||
pc[1] = '\0';
|
||||
do
|
||||
{
|
||||
do
|
||||
{
|
||||
pInStream->Read(pc, 1);
|
||||
memFile.Write(pc, 1);
|
||||
} while (!pInStream->IsBufferEmpty());
|
||||
} while(pCommunicator->GetMaxReadable() != 0);
|
||||
nDataLength = memFile.GetLength();
|
||||
pData = memFile.Detach();
|
||||
bDataSuccess = TRUE;
|
||||
}
|
||||
CATCH(CFileException, e)
|
||||
{
|
||||
TRACE(_T("CComServerDoc::OnReceive : Catching CFileException\n"));
|
||||
if (pData == NULL)
|
||||
{
|
||||
nDataLength = memFile.GetLength();
|
||||
pData = memFile.Detach();
|
||||
}
|
||||
}
|
||||
AND_CATCH(CArchiveException, e)
|
||||
{
|
||||
TRACE(_T("CComServerDoc::OnReceive : Catching CArchiveException\n"));
|
||||
if (pData == NULL)
|
||||
{
|
||||
nDataLength = memFile.GetLength();
|
||||
pData = memFile.Detach();
|
||||
}
|
||||
}
|
||||
END_CATCH
|
||||
|
||||
// Now reread the data in a variant array
|
||||
TRY
|
||||
{
|
||||
memFile.Attach(pData, nDataLength);
|
||||
CArchive inStream(&memFile, CArchive::load);
|
||||
commMsg.Serialize(inStream);
|
||||
memFile.Detach();
|
||||
bVariantSuccess = TRUE;
|
||||
}
|
||||
CATCH(CFileException, e)
|
||||
{
|
||||
TRACE(_T("CComServerDoc::OnClientReceive : Catching CFileException\n"));
|
||||
memFile.Detach();
|
||||
}
|
||||
AND_CATCH(CArchiveException, e)
|
||||
{
|
||||
TRACE(_T("CComServerDoc::OnClientReceive : Catching CArchiveException\n"));
|
||||
memFile.Detach();
|
||||
}
|
||||
END_CATCH
|
||||
|
||||
hintData.m_hClient = hClient;
|
||||
if (bDataSuccess)
|
||||
{
|
||||
hintData.m_pData = pData;
|
||||
hintData.m_nDataLength = nDataLength;
|
||||
}
|
||||
if (bVariantSuccess)
|
||||
hintData.m_pCommMsg = &commMsg;
|
||||
UpdateAllViews(NULL, NotifyAddData, &hintData);
|
||||
|
||||
// Clean up memory
|
||||
free(pData);
|
||||
}
|
||||
|
||||
void CCommunicatorDoc::OnClientCreate(HCLIENT_COMMUNICATOR hClient,
|
||||
COXCommunicator* pClientCommunicator)
|
||||
{
|
||||
CHintData hintData;
|
||||
hintData.m_hClient = hClient;
|
||||
pClientCommunicator->GetPeerName(hintData.m_sClientAddress, hintData.m_nClientPort);
|
||||
UpdateAllViews(NULL, NotifyAddClient, &hintData);
|
||||
}
|
||||
|
||||
void CCommunicatorDoc::OnClientReceive(HCLIENT_COMMUNICATOR hClient,
|
||||
COXCommunicator* pClientCommunicator,
|
||||
DWORD nSize, int nErrorCode)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(nSize);
|
||||
OnReceive(hClient, pClientCommunicator, nErrorCode);
|
||||
}
|
||||
|
||||
void CCommunicatorDoc::OnClientClose(HCLIENT_COMMUNICATOR hClient,
|
||||
COXCommunicator* pClientCommunicator,
|
||||
int nErrorCode)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(nErrorCode);
|
||||
UNREFERENCED_PARAMETER(pClientCommunicator);
|
||||
CHintData hintData;
|
||||
hintData.m_hClient = hClient;
|
||||
UpdateAllViews(NULL, NotifyRemoveClient, &hintData);
|
||||
}
|
||||
|
||||
void CCommunicatorDoc::OnServerReceive(DWORD nSize, int nErrorCode)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(nSize);
|
||||
OnReceive(0, &m_dataCommunicator, nErrorCode);
|
||||
}
|
||||
|
||||
void CCommunicatorDoc::OnServerClose(int nErrorCode)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(nErrorCode);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCommunicatorDoc serialization
|
||||
|
||||
void CCommunicatorDoc::Serialize(CArchive& ar)
|
||||
{
|
||||
if (ar.IsStoring())
|
||||
{
|
||||
// TODO: add storing code here
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: add loading code here
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCommunicatorDoc diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CCommunicatorDoc::AssertValid() const
|
||||
{
|
||||
CDocument::AssertValid();
|
||||
}
|
||||
|
||||
void CCommunicatorDoc::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CDocument::Dump(dc);
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCommunicatorDoc commands
|
||||
|
||||
void CCommunicatorDoc::OnSpy()
|
||||
{
|
||||
COleDateTime oleDate;
|
||||
SYSTEMTIME t;
|
||||
t.wYear = 1996;
|
||||
t.wMonth = 10;
|
||||
t.wDay = 6;
|
||||
t.wHour = 16;
|
||||
t.wMinute = 53;
|
||||
t.wSecond = 24;
|
||||
|
||||
oleDate = t;
|
||||
|
||||
|
||||
CFrameWnd* pHexFrame = NULL;
|
||||
pHexFrame = ((CCommunicatorApp*)AfxGetApp())->m_pHexDocTemplate->CreateNewFrame(this, NULL);
|
||||
pHexFrame->InitialUpdateFrame(this, TRUE);
|
||||
}
|
||||
|
||||
void CCommunicatorDoc::OnCancel()
|
||||
{
|
||||
m_dataCommunicator.CancelAllBlockingCalls();
|
||||
}
|
||||
|
||||
BOOL CCommunicatorDoc::IsModified()
|
||||
{
|
||||
// Never ask to save the doc
|
||||
return FALSE;
|
||||
}
|
||||
@ -0,0 +1,118 @@
|
||||
// CommunicatorDoc.h : interface of the CCommunicatorDoc class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "OXDataCommunicator.h"
|
||||
|
||||
class COXCommMsg;
|
||||
|
||||
class CCommunicatorDoc : public CDocument
|
||||
{
|
||||
protected: // create from serialization only
|
||||
CCommunicatorDoc();
|
||||
DECLARE_DYNCREATE(CCommunicatorDoc)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
CString GetLocalAddress() const;
|
||||
UINT GetLocalPort() const;
|
||||
BOOL IsOpen();
|
||||
BOOL IsListening();
|
||||
BOOL IsBlocking();
|
||||
void CancelBlocking();
|
||||
|
||||
BOOL Listen(long nServerPort);
|
||||
void Shutdown();
|
||||
void DisconnectClient(HCLIENT_COMMUNICATOR hClient);
|
||||
BOOL Send(HCLIENT_COMMUNICATOR hClient, COXCommMsg* pCommMsg);
|
||||
BOOL ConnectServer(CString sRemoteAddress, int nRemotePort, int nLocalPort);
|
||||
BOOL SendServer(COXCommMsg* pCommMsg);
|
||||
|
||||
void OnReceive(HCLIENT_COMMUNICATOR hClient, COXCommunicator* pCommunicator, int nErrorCode);
|
||||
void OnReceiveDirect(HCLIENT_COMMUNICATOR hClient, COXCommunicator* pCommunicator, int nErrorCode);
|
||||
void OnReceiveHex(HCLIENT_COMMUNICATOR hClient, COXCommunicator* pCommunicator, int nErrorCode);
|
||||
|
||||
void OnClientCreate(HCLIENT_COMMUNICATOR hClient, COXCommunicator* pClientCommunicator);
|
||||
void OnClientReceive(HCLIENT_COMMUNICATOR hClient, COXCommunicator* pClientCommunicator, DWORD nSize, int nErrorCode);
|
||||
void OnClientClose(HCLIENT_COMMUNICATOR hClient, COXCommunicator* pClientCommunicator, int nErrorCode);
|
||||
void OnServerReceive(DWORD nSize, int nErrorCode);
|
||||
void OnServerClose(int nErrorCode);
|
||||
|
||||
enum
|
||||
{
|
||||
NotifyAddClient = 1,
|
||||
NotifyRemoveClient = 2,
|
||||
NotifyRemoveAllClients =3,
|
||||
NotifyAddData = 4
|
||||
};
|
||||
|
||||
class CHintData : public CObject
|
||||
{
|
||||
public:
|
||||
HCLIENT_COMMUNICATOR m_hClient;
|
||||
CString m_sClientAddress;
|
||||
UINT m_nClientPort;
|
||||
COXCommMsg* m_pCommMsg;
|
||||
BYTE* m_pData;
|
||||
UINT m_nDataLength;
|
||||
CHintData()
|
||||
:
|
||||
m_hClient(0),
|
||||
m_sClientAddress(""),
|
||||
m_nClientPort(0),
|
||||
m_pCommMsg(NULL),
|
||||
m_pData(NULL),
|
||||
m_nDataLength(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CCommunicatorDoc)
|
||||
public:
|
||||
virtual BOOL OnNewDocument();
|
||||
virtual void Serialize(CArchive& ar);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
virtual BOOL IsModified();
|
||||
|
||||
protected:
|
||||
CString m_sLocalAddress;
|
||||
COXDataCommunicator m_dataCommunicator;
|
||||
CWnd* m_pCancelWnd;
|
||||
UINT m_nTimeOut;
|
||||
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CCommunicatorDoc();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CCommunicatorDoc)
|
||||
afx_msg void OnSpy();
|
||||
afx_msg void OnCancel();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
// Generated OLE dispatch map functions
|
||||
//{{AFX_DISPATCH(CCommunicatorDoc)
|
||||
// NOTE - the ClassWizard will add and remove member functions here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code !
|
||||
//}}AFX_DISPATCH
|
||||
DECLARE_DISPATCH_MAP()
|
||||
DECLARE_INTERFACE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Binary file not shown.
@ -0,0 +1,503 @@
|
||||
// CommunicatorView.cpp : implementation of the CCommunicatorView class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Communicator.h"
|
||||
|
||||
#include "CommunicatorDoc.h"
|
||||
#include "CommunicatorView.h"
|
||||
#include "SendDataDlg.h"
|
||||
#include "OXBlob.h"
|
||||
|
||||
#include <afxpriv.h> // for OnIdleUpdateCmdUI
|
||||
#include <afxmt.h> // For mutex support
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCommunicatorView
|
||||
|
||||
#pragma data_seg(".sdata")
|
||||
// Store the usage count of this application so that multiple instances will
|
||||
// cascade nicely on the screen
|
||||
LONG nUsageCount = 0;
|
||||
#pragma data_seg()
|
||||
|
||||
|
||||
IMPLEMENT_DYNCREATE(CCommunicatorView, CFormView)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CCommunicatorView, CFormView)
|
||||
//{{AFX_MSG_MAP(CCommunicatorView)
|
||||
ON_BN_CLICKED(IDC_CONNECT_SERVER, OnConnectServer)
|
||||
ON_BN_CLICKED(IDC_DISCONNECT_CLIENT, OnDisconnectClient)
|
||||
ON_BN_CLICKED(IDC_DISCONNECT_SERVER, OnDisconnectServer)
|
||||
ON_BN_CLICKED(IDC_LISTEN, OnListen)
|
||||
ON_BN_CLICKED(IDC_SEND_CLIENT, OnSendClient)
|
||||
ON_BN_CLICKED(IDC_SEND_SERVER, OnSendServer)
|
||||
ON_BN_CLICKED(IDC_SHUTDOWN, OnShutdown)
|
||||
ON_MESSAGE_VOID(WM_IDLEUPDATECMDUI, OnIdleUpdateCmdUI)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCommunicatorView construction/destruction
|
||||
|
||||
CCommunicatorView::CCommunicatorView()
|
||||
: CFormView(CCommunicatorView::IDD)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CCommunicatorView)
|
||||
m_sLocalAddress = _T("");
|
||||
m_nLocalPort = 1000;
|
||||
m_sRemoteAddress = _T("");
|
||||
m_nRemotePort = 1000;
|
||||
//}}AFX_DATA_INIT
|
||||
// TODO: add construction code here
|
||||
|
||||
}
|
||||
|
||||
CCommunicatorView::~CCommunicatorView()
|
||||
{
|
||||
}
|
||||
|
||||
void CCommunicatorView::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CFormView::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CCommunicatorView)
|
||||
DDX_Control(pDX, IDC_CANCEL, m_wndCancel);
|
||||
DDX_Control(pDX, IDC_LOCAL_PORT_LABEL, m_wndLocalPortLabel);
|
||||
DDX_Control(pDX, IDC_SERVER_GROUP, m_wndServerGroup);
|
||||
DDX_Control(pDX, IDC_REMOTE_ADDRESS_LABEL, m_wndRemoteAddressLabel);
|
||||
DDX_Control(pDX, IDC_REMOTE_PORT_LABEL, m_wndRemotePortLabel);
|
||||
DDX_Control(pDX, IDC_LOCAL_ADDRESS_LABEL, m_wndLocalAddressLabel);
|
||||
DDX_Control(pDX, IDC_CLIENT_GROUP, m_wndClientGroup);
|
||||
DDX_Control(pDX, IDC_CLIENT_ADDRESSES_LABEL, m_wndClientAddressLabel);
|
||||
DDX_Control(pDX, IDC_SEND_SERVER, m_wndSendServer);
|
||||
DDX_Control(pDX, IDC_DISCONNECT_SERVER, m_wndDisconnectServer);
|
||||
DDX_Control(pDX, IDC_CONNECT_SERVER, m_wndConnectServer);
|
||||
DDX_Control(pDX, IDC_REMOTE_PORT, m_wndRemotePort);
|
||||
DDX_Control(pDX, IDC_REMOTE_ADDRESS, m_wndRemoteAddress);
|
||||
DDX_Control(pDX, IDC_DISCONNECT_CLIENT, m_wndDisconnectClient);
|
||||
DDX_Control(pDX, IDC_SEND_CLIENT, m_wndSendClient);
|
||||
DDX_Control(pDX, IDC_SHUTDOWN, m_wndShutdown);
|
||||
DDX_Control(pDX, IDC_LISTEN, m_wndListen);
|
||||
DDX_Control(pDX, IDC_LOCAL_PORT, m_wndLocalPort);
|
||||
DDX_Control(pDX, IDC_LOCAL_ADDRESS, m_wndLocalAddress);
|
||||
DDX_Control(pDX, IDC_CLIENT_ADDRESSES, m_wndClientAddresses);
|
||||
DDX_Control(pDX, IDC_RECEIVED_DATA, m_wndReceivedData);
|
||||
DDX_Text(pDX, IDC_LOCAL_ADDRESS, m_sLocalAddress);
|
||||
DDX_Text(pDX, IDC_LOCAL_PORT, m_nLocalPort);
|
||||
DDX_Text(pDX, IDC_REMOTE_ADDRESS, m_sRemoteAddress);
|
||||
DDX_Text(pDX, IDC_REMOTE_PORT, m_nRemotePort);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
BOOL CCommunicatorView::PreCreateWindow(CREATESTRUCT& cs)
|
||||
{
|
||||
// TODO: Modify the Window class or styles here by modifying
|
||||
// the CREATESTRUCT cs
|
||||
|
||||
return CFormView::PreCreateWindow(cs);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCommunicatorView diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CCommunicatorView::AssertValid() const
|
||||
{
|
||||
CFormView::AssertValid();
|
||||
}
|
||||
|
||||
void CCommunicatorView::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CFormView::Dump(dc);
|
||||
}
|
||||
|
||||
CCommunicatorDoc* CCommunicatorView::GetDocument() // non-debug version is inline
|
||||
{
|
||||
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCommunicatorDoc)));
|
||||
return (CCommunicatorDoc*)m_pDocument;
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCommunicatorView message handlers
|
||||
|
||||
void CCommunicatorView::OnConnectServer()
|
||||
{
|
||||
if (GetDocument()->IsBlocking())
|
||||
{
|
||||
TRACE(_T("CCommunicatorView::OnConnectServer : Communicator is still blocking\n"));
|
||||
MessageBeep(0xFFFF);
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateData(TRUE);
|
||||
// If remote address is not filled out, try a local connection
|
||||
if (m_sRemoteAddress.IsEmpty())
|
||||
{
|
||||
m_sRemoteAddress = GetDocument()->GetLocalAddress();
|
||||
UpdateData(FALSE);
|
||||
}
|
||||
// Do not use the specified local port, let winsockets pick one
|
||||
if (!GetDocument()->ConnectServer(m_sRemoteAddress, m_nRemotePort, 0))
|
||||
AfxMessageBox(IDS_FAILED_CONNECT, MB_ICONEXCLAMATION);
|
||||
m_nLocalPort = GetDocument()->GetLocalPort();
|
||||
UpdateData(FALSE);
|
||||
}
|
||||
|
||||
void CCommunicatorView::OnDisconnectClient()
|
||||
{
|
||||
if (GetDocument()->IsBlocking())
|
||||
{
|
||||
TRACE(_T("CCommunicatorView::OnDisconnectClient : Communicator is still blocking\n"));
|
||||
MessageBeep(0xFFFF);
|
||||
return;
|
||||
}
|
||||
|
||||
UINT nSelCount = m_wndClientAddresses.GetSelCount();
|
||||
if (0 < nSelCount)
|
||||
{
|
||||
int index;
|
||||
int* rgSels = new int[nSelCount];
|
||||
m_wndClientAddresses.GetSelItems(nSelCount, rgSels);
|
||||
for (index = (int)nSelCount - 1; 0 <= index; index--)
|
||||
GetDocument()->DisconnectClient(m_wndClientAddresses.GetItemData(rgSels[index]));
|
||||
delete rgSels;
|
||||
}
|
||||
}
|
||||
|
||||
void CCommunicatorView::OnDisconnectServer()
|
||||
{
|
||||
if (GetDocument()->IsBlocking())
|
||||
{
|
||||
TRACE(_T("CCommunicatorView::OnDisconnectServer : Communicator is still blocking\n"));
|
||||
MessageBeep(0xFFFF);
|
||||
return;
|
||||
}
|
||||
|
||||
GetDocument()->Shutdown();
|
||||
}
|
||||
|
||||
void CCommunicatorView::OnListen()
|
||||
{
|
||||
if (GetDocument()->IsBlocking())
|
||||
{
|
||||
TRACE(_T("CCommunicatorView::OnListen : Communicator is still blocking\n"));
|
||||
MessageBeep(0xFFFF);
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateData(TRUE);
|
||||
if (!GetDocument()->Listen(m_nLocalPort))
|
||||
AfxMessageBox(IDS_FAILED_LISTEN, MB_ICONEXCLAMATION);
|
||||
}
|
||||
|
||||
void CCommunicatorView::OnSendClient()
|
||||
{
|
||||
if (GetDocument()->IsBlocking())
|
||||
{
|
||||
TRACE(_T("CCommunicatorView::OnSendClient : Communicator is still blocking\n"));
|
||||
MessageBeep(0xFFFF);
|
||||
return;
|
||||
}
|
||||
|
||||
COXCommMsg* pCommMsg = new COXCommMsg;
|
||||
|
||||
CSendDataDlg dlg(pCommMsg);
|
||||
if (dlg.DoModal() == IDOK)
|
||||
{
|
||||
UINT nSelCount = m_wndClientAddresses.GetSelCount();
|
||||
if (0 < nSelCount)
|
||||
{
|
||||
int index;
|
||||
int* rgSels = new int[nSelCount];
|
||||
m_wndClientAddresses.GetSelItems(nSelCount, rgSels);
|
||||
for (index = 0; index < (int)nSelCount; index++)
|
||||
GetDocument()->Send(m_wndClientAddresses.GetItemData(rgSels[index]), pCommMsg);
|
||||
delete rgSels;
|
||||
}
|
||||
}
|
||||
delete pCommMsg;
|
||||
}
|
||||
|
||||
void CCommunicatorView::OnSendServer()
|
||||
{
|
||||
if (GetDocument()->IsBlocking())
|
||||
{
|
||||
TRACE(_T("CCommunicatorView::OnSendServer : Communicator is still blocking\n"));
|
||||
MessageBeep(0xFFFF);
|
||||
return;
|
||||
}
|
||||
|
||||
COXCommMsg* pCommMsg = new COXCommMsg;
|
||||
|
||||
CSendDataDlg dlg(pCommMsg);
|
||||
if (dlg.DoModal() == IDOK)
|
||||
GetDocument()->SendServer(pCommMsg);
|
||||
|
||||
delete pCommMsg;
|
||||
}
|
||||
|
||||
void CCommunicatorView::OnShutdown()
|
||||
{
|
||||
if (GetDocument()->IsBlocking())
|
||||
{
|
||||
TRACE(_T("CCommunicatorView::OnShutdown : Communicator is still blocking\n"));
|
||||
MessageBeep(0xFFFF);
|
||||
return;
|
||||
}
|
||||
|
||||
GetDocument()->Shutdown();
|
||||
}
|
||||
|
||||
void CCommunicatorView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(pSender);
|
||||
CCommunicatorDoc::CHintData* pHintData = (CCommunicatorDoc::CHintData*)pHint;
|
||||
CString sText;
|
||||
int index;
|
||||
switch(lHint)
|
||||
{
|
||||
case CCommunicatorDoc::NotifyAddClient:
|
||||
// Add the client address to the list
|
||||
sText.Format(_T("%i. %s (%i)"), pHintData->m_hClient,
|
||||
(LPCTSTR)pHintData->m_sClientAddress, pHintData->m_nClientPort);
|
||||
|
||||
index = m_wndClientAddresses.AddString(sText);
|
||||
m_wndClientAddresses.SetItemData(index, pHintData->m_hClient);
|
||||
// If nothing is selected, select this item
|
||||
if (m_wndClientAddresses.GetSelCount() == 0)
|
||||
m_wndClientAddresses.SetSel(index);
|
||||
break;
|
||||
case CCommunicatorDoc::NotifyRemoveClient:
|
||||
// Remove the client address from the list
|
||||
for (index = 0; index < m_wndClientAddresses.GetCount(); index++)
|
||||
{
|
||||
if ((int)m_wndClientAddresses.GetItemData(index) == pHintData->m_hClient)
|
||||
m_wndClientAddresses.DeleteString(index);
|
||||
}
|
||||
// If nothing is selected, select the first one
|
||||
if (m_wndClientAddresses.GetSelCount() == 0)
|
||||
m_wndClientAddresses.SetSel(0);
|
||||
break;
|
||||
case CCommunicatorDoc::NotifyRemoveAllClients:
|
||||
// Remove all the client address from the list
|
||||
m_wndClientAddresses.ResetContent();
|
||||
break;
|
||||
case CCommunicatorDoc::NotifyAddData:
|
||||
// Show the received data
|
||||
ShowData(pHintData);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CCommunicatorView::ShowData(CCommunicatorDoc::CHintData* pHintData)
|
||||
{
|
||||
CString sText;
|
||||
CString sValue;
|
||||
if (pHintData->m_pCommMsg == NULL)
|
||||
{
|
||||
if (pHintData->m_nDataLength != 0)
|
||||
sText.Format(_T("%i. <Unknown Format> (length = %i)\r\n"),
|
||||
pHintData->m_hClient, pHintData->m_nDataLength);
|
||||
else
|
||||
sText.Format(_T("%i. <Unknown Format> (length = unknown)\r\n"),
|
||||
pHintData->m_hClient);
|
||||
AddText(sText);
|
||||
return;
|
||||
}
|
||||
|
||||
sText.Format(_T("%i. Array of size %i\r\n"),
|
||||
pHintData->m_hClient, pHintData->m_pCommMsg->GetSize());
|
||||
AddText(sText);
|
||||
|
||||
COXVariant variant;
|
||||
UINT nOleType;
|
||||
UINT nType;
|
||||
for (int index = 0; index < pHintData->m_pCommMsg->GetSize(); index++)
|
||||
{
|
||||
// Convert variant to string to visualize
|
||||
variant = pHintData->m_pCommMsg->GetAt(index);
|
||||
nOleType = V_VT(&variant);
|
||||
for (nType = 0;
|
||||
(nType < COXCommMsg::m_nArgumentTypesCount) && (nOleType != (UINT)COXCommMsg::m_types[nType]);
|
||||
nType++)
|
||||
;
|
||||
// ... Must have found the type
|
||||
ASSERT(nType < COXCommMsg::m_nArgumentTypesCount);
|
||||
|
||||
sValue.Empty();
|
||||
TRY
|
||||
{
|
||||
if (nOleType != COXCommMsg::ATBlob)
|
||||
{
|
||||
if (V_VT(&variant) == COXCommMsg::ATError)
|
||||
// ... Variant is a union, just change the type
|
||||
// oleVariant.lVal= oleVariant.scode ;
|
||||
V_VT(&variant) = COXCommMsg::ATI4;
|
||||
variant.ChangeType(COXCommMsg::ATStr);
|
||||
sValue = V_BSTR(&variant);
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(nOleType == COXCommMsg::ATBlob);
|
||||
CString sTempPath;
|
||||
CString sTempFileName;
|
||||
COXBlob blob;
|
||||
VERIFY(::GetTempPath(_MAX_PATH, sTempPath.GetBuffer(_MAX_PATH)) != 0);
|
||||
sTempPath.ReleaseBuffer();
|
||||
VERIFY(::GetTempFileName(sTempPath, _T("BLB"), 0,
|
||||
sTempFileName.GetBuffer(_MAX_PATH)) != 0);
|
||||
sTempFileName.ReleaseBuffer();
|
||||
blob = variant;
|
||||
blob.WriteRaw(sTempFileName);
|
||||
sValue.Format(_T("<binary of length %i> (stored as %s)"), blob.GetSize(), sTempFileName);
|
||||
}
|
||||
}
|
||||
END_TRY
|
||||
sText.Format(_T("\t%i. (%s) %s\r\n"),
|
||||
index + 1,
|
||||
(LPCTSTR)COXCommMsg::m_typeNames[nType],
|
||||
(LPCTSTR)sValue);
|
||||
AddText(sText);
|
||||
}
|
||||
}
|
||||
|
||||
void CCommunicatorView::AddText(LPCTSTR pszText)
|
||||
{
|
||||
LONG nWindowTextLength;
|
||||
nWindowTextLength = m_wndReceivedData.GetWindowTextLength();
|
||||
m_wndReceivedData.SetSel(nWindowTextLength, nWindowTextLength);
|
||||
m_wndReceivedData.ReplaceSel(pszText);
|
||||
}
|
||||
|
||||
void CCommunicatorView::OnInitialUpdate()
|
||||
{
|
||||
CFormView::OnInitialUpdate();
|
||||
|
||||
// Show local server name
|
||||
m_sLocalAddress = GetDocument()->GetLocalAddress();
|
||||
UpdateData(FALSE);
|
||||
|
||||
// Fit frame around view
|
||||
ResizeParentToFit(FALSE);
|
||||
|
||||
// Fit mainframe around frame, do this only once
|
||||
static bMainFrameResized = FALSE;
|
||||
if (!bMainFrameResized)
|
||||
{
|
||||
bMainFrameResized = TRUE;
|
||||
|
||||
// Get the size of frame and main frame
|
||||
CRect frameRect;
|
||||
CRect mainFrameRect;
|
||||
CRect mainFrameClientRect;
|
||||
GetParentFrame()->GetWindowRect(frameRect);
|
||||
AfxGetMainWnd()->GetWindowRect(mainFrameRect);
|
||||
AfxGetMainWnd()->GetClientRect(mainFrameClientRect);
|
||||
|
||||
// Resize the mainframe so that this view frame will completely fill the client area
|
||||
mainFrameRect.right += frameRect.Width() - mainFrameClientRect.Width();
|
||||
mainFrameRect.bottom += frameRect.Height() - mainFrameClientRect.Height();
|
||||
|
||||
// Take other windows into account that also populate the main frames client area
|
||||
CWnd* pChild;
|
||||
CRect childRect;
|
||||
pChild = AfxGetMainWnd()->GetWindow(GW_CHILD);
|
||||
while (pChild != NULL)
|
||||
{
|
||||
// ... Skip the MDI frame window
|
||||
if (pChild != GetParentFrame()->GetParent())
|
||||
{
|
||||
pChild->GetWindowRect(childRect);
|
||||
// Statusbar and buttonbar take up the entire width (or height)
|
||||
// Use the smallest of the two
|
||||
if (childRect.Height() < childRect.Width())
|
||||
mainFrameRect.bottom += childRect.Height();
|
||||
else
|
||||
mainFrameRect.right += childRect.Width();
|
||||
}
|
||||
pChild = pChild->GetWindow(GW_HWNDNEXT);
|
||||
}
|
||||
|
||||
// Position multiple instance next to each other
|
||||
CMutex mutex(FALSE, _T("COMMUNICATOR_MOVE"));
|
||||
// ... Lock the mutex, destructor will unlock
|
||||
CSingleLock lock(&mutex, TRUE);
|
||||
nUsageCount++;
|
||||
|
||||
// If at most two instances are running
|
||||
if (nUsageCount <= 2)
|
||||
{
|
||||
// Put main frame in top left corner (0,0)
|
||||
mainFrameRect.right -= mainFrameRect.left;
|
||||
mainFrameRect.bottom -= mainFrameRect.top;
|
||||
mainFrameRect.left = 0;
|
||||
mainFrameRect.top = 0;
|
||||
|
||||
// Position it next to the other instance (if it exists)
|
||||
mainFrameRect.left = mainFrameRect.right * (nUsageCount - 1);
|
||||
mainFrameRect.right = mainFrameRect.right * nUsageCount;
|
||||
}
|
||||
|
||||
AfxGetMainWnd()->MoveWindow(mainFrameRect);
|
||||
}
|
||||
}
|
||||
|
||||
void CCommunicatorView::OnIdleUpdateCmdUI()
|
||||
{
|
||||
BOOL bClientSelected = (0 < m_wndClientAddresses.GetSelCount());
|
||||
BOOL bOpen = GetDocument()->IsOpen();
|
||||
BOOL bServer = FALSE;
|
||||
BOOL bClient = FALSE;
|
||||
if (bOpen)
|
||||
{
|
||||
bServer = GetDocument()->IsListening();
|
||||
bClient = !bServer;
|
||||
}
|
||||
|
||||
// Conditionally disable controls
|
||||
// Server
|
||||
m_wndServerGroup. EnableWindow(!bOpen || bServer);
|
||||
m_wndLocalAddressLabel. EnableWindow(!bOpen);
|
||||
m_wndLocalAddress. EnableWindow(!bOpen);
|
||||
m_wndLocalPortLabel. EnableWindow(!bOpen);
|
||||
m_wndLocalPort. EnableWindow(!bOpen);
|
||||
m_wndListen. EnableWindow(!bOpen);
|
||||
m_wndShutdown. EnableWindow(bServer);
|
||||
m_wndSendClient. EnableWindow(bServer && bClientSelected);
|
||||
m_wndDisconnectClient. EnableWindow(bServer && bClientSelected);
|
||||
m_wndClientAddressLabel.EnableWindow(bServer);
|
||||
m_wndClientAddresses. EnableWindow(bServer);
|
||||
|
||||
// Client
|
||||
m_wndClientGroup. EnableWindow(!bOpen || bClient);
|
||||
m_wndRemoteAddressLabel.EnableWindow(!bOpen);
|
||||
m_wndRemoteAddress. EnableWindow(!bOpen);
|
||||
m_wndRemotePortLabel. EnableWindow(!bOpen);
|
||||
m_wndRemotePort. EnableWindow(!bOpen);
|
||||
m_wndConnectServer. EnableWindow(!bOpen);
|
||||
m_wndSendServer. EnableWindow(bClient);
|
||||
m_wndDisconnectServer. EnableWindow(bClient);
|
||||
|
||||
// Global
|
||||
m_wndCancel. EnableWindow(bOpen);
|
||||
}
|
||||
|
||||
void CCommunicatorView::PostNcDestroy()
|
||||
{
|
||||
// Relase this instance count
|
||||
CMutex mutex(FALSE, _T("COMMUNICATOR_MOVE"));
|
||||
// ... Lock the mutex, destructor will unlock
|
||||
CSingleLock lock(&mutex, TRUE);
|
||||
nUsageCount--;
|
||||
|
||||
CFormView::PostNcDestroy();
|
||||
}
|
||||
@ -0,0 +1,94 @@
|
||||
// CommunicatorView.h : interface of the CCommunicatorView class
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CCommunicatorView : public CFormView
|
||||
{
|
||||
protected: // create from serialization only
|
||||
CCommunicatorView();
|
||||
DECLARE_DYNCREATE(CCommunicatorView)
|
||||
|
||||
public:
|
||||
//{{AFX_DATA(CCommunicatorView)
|
||||
enum { IDD = IDD_COMMUNICATOR_FORM };
|
||||
CButton m_wndCancel;
|
||||
CStatic m_wndLocalPortLabel;
|
||||
CButton m_wndServerGroup;
|
||||
CStatic m_wndRemoteAddressLabel;
|
||||
CStatic m_wndRemotePortLabel;
|
||||
CStatic m_wndLocalAddressLabel;
|
||||
CButton m_wndClientGroup;
|
||||
CStatic m_wndClientAddressLabel;
|
||||
CButton m_wndSendServer;
|
||||
CButton m_wndDisconnectServer;
|
||||
CButton m_wndConnectServer;
|
||||
CEdit m_wndRemotePort;
|
||||
CEdit m_wndRemoteAddress;
|
||||
CButton m_wndDisconnectClient;
|
||||
CButton m_wndSendClient;
|
||||
CButton m_wndShutdown;
|
||||
CButton m_wndListen;
|
||||
CEdit m_wndLocalPort;
|
||||
CEdit m_wndLocalAddress;
|
||||
CListBox m_wndClientAddresses;
|
||||
CEdit m_wndReceivedData;
|
||||
CString m_sLocalAddress;
|
||||
int m_nLocalPort;
|
||||
CString m_sRemoteAddress;
|
||||
int m_nRemotePort;
|
||||
//}}AFX_DATA
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
CCommunicatorDoc* GetDocument();
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CCommunicatorView)
|
||||
public:
|
||||
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
|
||||
virtual void OnInitialUpdate();
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
|
||||
virtual void PostNcDestroy();
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CCommunicatorView();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void ShowData(CCommunicatorDoc::CHintData* pHintData);
|
||||
void AddText(LPCTSTR pszText);
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CCommunicatorView)
|
||||
afx_msg void OnConnectServer();
|
||||
afx_msg void OnDisconnectClient();
|
||||
afx_msg void OnDisconnectServer();
|
||||
afx_msg void OnListen();
|
||||
afx_msg void OnSendClient();
|
||||
afx_msg void OnSendServer();
|
||||
afx_msg void OnShutdown();
|
||||
afx_msg void OnIdleUpdateCmdUI();
|
||||
afx_msg void OnCancel();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
#ifndef _DEBUG // debug version in CommunicatorView.cpp
|
||||
inline CCommunicatorDoc* CCommunicatorView::GetDocument()
|
||||
{ return (CCommunicatorDoc*)m_pDocument; }
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@ -0,0 +1,153 @@
|
||||
// HexView.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Communicator.h"
|
||||
#include "CommunicatorDoc.h"
|
||||
#include "HexView.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CHexView
|
||||
|
||||
IMPLEMENT_DYNCREATE(CHexView, CEditView)
|
||||
|
||||
CHexView::CHexView()
|
||||
{
|
||||
}
|
||||
|
||||
CHexView::~CHexView()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CHexView, CEditView)
|
||||
//{{AFX_MSG_MAP(CHexView)
|
||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CHexView diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CHexView::AssertValid() const
|
||||
{
|
||||
CEditView::AssertValid();
|
||||
}
|
||||
|
||||
void CHexView::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CEditView::Dump(dc);
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CHexView message handlers
|
||||
|
||||
void CHexView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(pSender);
|
||||
CCommunicatorDoc::CHintData* pHintData = (CCommunicatorDoc::CHintData*)pHint;
|
||||
CString sText;
|
||||
|
||||
if (lHint == CCommunicatorDoc::NotifyAddData)
|
||||
{
|
||||
sText.Format(_T("%i. Data length = 0x%X (%i)\r\n"),
|
||||
pHintData->m_hClient, pHintData->m_nDataLength, pHintData->m_nDataLength);
|
||||
AddText(sText);
|
||||
|
||||
// Show the received data
|
||||
if (pHintData->m_pData == NULL)
|
||||
{
|
||||
sText = _T("\t<Unknown Data>\r\n");
|
||||
AddText(sText);
|
||||
return;
|
||||
}
|
||||
|
||||
BYTE* pData = pHintData->m_pData;
|
||||
UINT nMaxIndex = pHintData->m_nDataLength;
|
||||
UINT nIndex = 0;
|
||||
CString sRaw;
|
||||
CString sHex;
|
||||
CString sHexTemp;
|
||||
while (nIndex < nMaxIndex)
|
||||
{
|
||||
// Split in two parts (of 8 bytes) seperated by a space
|
||||
sRaw.Empty();
|
||||
sHex.Empty();
|
||||
|
||||
// ... Add offset
|
||||
sRaw.Format(_T("%4.4X "), nIndex);
|
||||
|
||||
for (int nLoop = 0; nLoop < 2; nLoop++)
|
||||
{
|
||||
// Calculate 8 bytes
|
||||
UINT nPartIndex = 0;
|
||||
while (nPartIndex < 8 && nIndex < nMaxIndex)
|
||||
{
|
||||
if (isprint(pData[nIndex]))
|
||||
sRaw += (char)pData[nIndex];
|
||||
else
|
||||
sRaw += _T('.');
|
||||
sHexTemp.Format(_T("%2.2X "), pData[nIndex]);
|
||||
sHex += sHexTemp;
|
||||
nPartIndex++;
|
||||
nIndex++;
|
||||
}
|
||||
|
||||
sRaw += _T(' ');
|
||||
sHex += _T(' ');
|
||||
}
|
||||
|
||||
// Show the text
|
||||
sText.Format(_T("%-24.24s|%s\r\n"), sRaw, sHex);
|
||||
AddText(sText);
|
||||
}
|
||||
AddText(_T("\r\n"));
|
||||
}
|
||||
}
|
||||
|
||||
void CHexView::AddText(LPCTSTR pszText)
|
||||
{
|
||||
LONG nWindowTextLength;
|
||||
nWindowTextLength = GetEditCtrl().GetWindowTextLength();
|
||||
GetEditCtrl().SetSel(nWindowTextLength, nWindowTextLength);
|
||||
GetEditCtrl().ReplaceSel(pszText);
|
||||
}
|
||||
|
||||
|
||||
BOOL CHexView::PreCreateWindow(CREATESTRUCT& cs)
|
||||
{
|
||||
BOOL bRet = CEditView::PreCreateWindow(cs);
|
||||
cs.style |= ES_READONLY;
|
||||
return bRet;
|
||||
}
|
||||
|
||||
void CHexView::OnInitialUpdate()
|
||||
{
|
||||
CEditView::OnInitialUpdate();
|
||||
|
||||
// Create a fixed size font
|
||||
m_font.CreateFont( 0, // nHeight
|
||||
0, // nWidth
|
||||
0, // nEscapement
|
||||
0, // nOrientation
|
||||
FW_DONTCARE, // nWeight
|
||||
FALSE, // bItalic
|
||||
FALSE, // bUnderline
|
||||
0, // cStrikeOut
|
||||
DEFAULT_CHARSET, // nCharSet
|
||||
OUT_DEFAULT_PRECIS, // nOutPrecision
|
||||
CLIP_DEFAULT_PRECIS, // nClipPrecision
|
||||
DEFAULT_QUALITY, // nQuality
|
||||
FIXED_PITCH, // nPitchAndFamily
|
||||
NULL); // lpszFacename
|
||||
|
||||
GetEditCtrl().SetFont(&m_font, FALSE);
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
// HexView.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CHexView view
|
||||
|
||||
class CHexView : public CEditView
|
||||
{
|
||||
protected:
|
||||
CHexView(); // protected constructor used by dynamic creation
|
||||
DECLARE_DYNCREATE(CHexView)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CHexView)
|
||||
public:
|
||||
virtual void OnInitialUpdate();
|
||||
protected:
|
||||
virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
|
||||
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
CFont m_font;
|
||||
|
||||
void AddText(LPCTSTR pszText);
|
||||
virtual ~CHexView();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CHexView)
|
||||
// NOTE - the ClassWizard will add and remove member functions here.
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@ -0,0 +1,128 @@
|
||||
// MainFrm.cpp : implementation of the CMainFrame class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Communicator.h"
|
||||
#include "CommunicatorDoc.h"
|
||||
|
||||
#include "MainFrm.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame
|
||||
|
||||
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
|
||||
//{{AFX_MSG_MAP(CMainFrame)
|
||||
ON_WM_CREATE()
|
||||
ON_WM_CLOSE()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
static UINT indicators[] =
|
||||
{
|
||||
ID_SEPARATOR, // status line indicator
|
||||
ID_INDICATOR_CAPS,
|
||||
ID_INDICATOR_NUM,
|
||||
ID_INDICATOR_SCRL,
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame construction/destruction
|
||||
|
||||
CMainFrame::CMainFrame()
|
||||
{
|
||||
// TODO: add member initialization code here
|
||||
|
||||
}
|
||||
|
||||
CMainFrame::~CMainFrame()
|
||||
{
|
||||
}
|
||||
|
||||
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||||
{
|
||||
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
|
||||
{
|
||||
// TODO: Modify the Window class or styles here by modifying
|
||||
// the CREATESTRUCT cs
|
||||
// cs.style &= ~WS_MAXIMIZEBOX;
|
||||
cs.style |= WS_MAXIMIZE;
|
||||
|
||||
cs.style &= ~WS_MINIMIZEBOX;
|
||||
|
||||
return CMDIFrameWnd::PreCreateWindow(cs);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CMainFrame::AssertValid() const
|
||||
{
|
||||
CMDIFrameWnd::AssertValid();
|
||||
}
|
||||
|
||||
void CMainFrame::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CMDIFrameWnd::Dump(dc);
|
||||
}
|
||||
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame message handlers
|
||||
|
||||
void CMainFrame::OnClose()
|
||||
{
|
||||
// Check whether there are documents that are still blocking
|
||||
// (and thus have started a second message loop)
|
||||
BOOL bBlocking = FALSE;
|
||||
|
||||
POSITION pos;
|
||||
CDocTemplate* pDocTemplate;
|
||||
CCommunicatorDoc* pComDoc;
|
||||
|
||||
// Get the one (and only) document template
|
||||
pos = AfxGetApp()->GetFirstDocTemplatePosition();
|
||||
// ... Should have at least one template
|
||||
ASSERT(pos != 0);
|
||||
pDocTemplate = AfxGetApp()->GetNextDocTemplate(pos);
|
||||
ASSERT(pDocTemplate != 0);
|
||||
// ... Should have exactly one template
|
||||
ASSERT(pos == 0);
|
||||
|
||||
// Iterate all the documents
|
||||
pos = pDocTemplate->GetFirstDocPosition();
|
||||
while (pos != NULL)
|
||||
{
|
||||
pComDoc = (CCommunicatorDoc*)pDocTemplate->GetNextDoc(pos);
|
||||
ASSERT(pComDoc != 0);
|
||||
ASSERT(pComDoc->IsKindOf(RUNTIME_CLASS(CCommunicatorDoc)));
|
||||
if (pComDoc->IsBlocking())
|
||||
{
|
||||
bBlocking = TRUE;
|
||||
pComDoc->CancelBlocking();
|
||||
}
|
||||
}
|
||||
|
||||
// If blocking abort close and repost message
|
||||
if (bBlocking)
|
||||
{
|
||||
TRACE(_T("CMainFrame::OnClose : Detected communicators that are still blocking, cancelling blocking and reposting WM_CLOSE\n"));
|
||||
PostMessage(WM_CLOSE);
|
||||
}
|
||||
else
|
||||
CMDIFrameWnd::OnClose();
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
// MainFrm.h : interface of the CMainFrame class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CMainFrame : public CMDIFrameWnd
|
||||
{
|
||||
DECLARE_DYNAMIC(CMainFrame)
|
||||
public:
|
||||
CMainFrame();
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CMainFrame)
|
||||
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CMainFrame();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected: // control bar embedded members
|
||||
CStatusBar m_wndStatusBar;
|
||||
CToolBar m_wndToolBar;
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CMainFrame)
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
afx_msg void OnClose();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@ -0,0 +1,87 @@
|
||||
// ==========================================================================
|
||||
// Class Implementation : COXDataCommunicator
|
||||
// ==========================================================================
|
||||
|
||||
// Source file : OXDataCommunicator.cpp
|
||||
|
||||
//----------------- Dundas Software ----------------------------------------
|
||||
//========================================================================
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "OXDataCommunicator.h"
|
||||
#include "CommunicatorDoc.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char BASED_CODE THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
IMPLEMENT_DYNAMIC(COXDataCommunicator, COXCommunicator)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Definition of static members
|
||||
|
||||
// Data members -------------------------------------------------------------
|
||||
// protected:
|
||||
|
||||
// private:
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
// public:
|
||||
COXDataCommunicator::COXDataCommunicator(CCommunicatorDoc* pCommunicatorDoc, UINT nStreamBufferSize /* = 4096 */)
|
||||
:
|
||||
COXCommunicator(nStreamBufferSize),
|
||||
m_pCommunicatorDoc(pCommunicatorDoc)
|
||||
{
|
||||
ASSERT_VALID(this);
|
||||
ASSERT(pCommunicatorDoc != NULL);
|
||||
}
|
||||
|
||||
void COXDataCommunicator::OnClientCreate(HCLIENT_COMMUNICATOR hClient, COXCommunicator* pClientCommunicator)
|
||||
{
|
||||
m_pCommunicatorDoc->OnClientCreate(hClient, pClientCommunicator);
|
||||
}
|
||||
|
||||
void COXDataCommunicator::OnClientReceive(HCLIENT_COMMUNICATOR hClient, COXCommunicator* pClientCommunicator, DWORD nSize, int nErrorCode)
|
||||
{
|
||||
m_pCommunicatorDoc->OnClientReceive(hClient, pClientCommunicator, nSize, nErrorCode);
|
||||
}
|
||||
|
||||
void COXDataCommunicator::OnClientClose(HCLIENT_COMMUNICATOR hClient, COXCommunicator* pClientCommunicator, int nErrorCode)
|
||||
{
|
||||
m_pCommunicatorDoc->OnClientClose(hClient, pClientCommunicator, nErrorCode);
|
||||
}
|
||||
|
||||
void COXDataCommunicator::OnServerReceive(DWORD nSize, int nErrorCode)
|
||||
{
|
||||
m_pCommunicatorDoc->OnServerReceive(nSize, nErrorCode);
|
||||
}
|
||||
|
||||
void COXDataCommunicator::OnServerClose(int nErrorCode)
|
||||
{
|
||||
m_pCommunicatorDoc->OnServerClose(nErrorCode);
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
void COXDataCommunicator::AssertValid() const
|
||||
{
|
||||
COXCommunicator::AssertValid();
|
||||
}
|
||||
|
||||
void COXDataCommunicator::Dump(CDumpContext& dc) const
|
||||
{
|
||||
COXCommunicator::Dump(dc);
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
COXDataCommunicator::~COXDataCommunicator()
|
||||
{
|
||||
}
|
||||
|
||||
// protected:
|
||||
|
||||
// private:
|
||||
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,102 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : COXDataCommunicator
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : OXDataCommunicator.h
|
||||
|
||||
//----------------- Dundas Software ----------------------------------------
|
||||
//========================================================================
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from COXCommunicator
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// NO Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
|
||||
// Remark:
|
||||
|
||||
// Prerequisites (necessary conditions):
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __OXDATACOMMUNICATOR_H__
|
||||
#define __OXDATACOMMUNICATOR_H__
|
||||
|
||||
#include "OXCommunicator.h"
|
||||
|
||||
class CCommunicatorDoc;
|
||||
|
||||
class COXDataCommunicator : public COXCommunicator
|
||||
{
|
||||
DECLARE_DYNAMIC(COXDataCommunicator)
|
||||
|
||||
// Data members -------------------------------------------------------------
|
||||
public:
|
||||
|
||||
protected:
|
||||
CCommunicatorDoc* m_pCommunicatorDoc;
|
||||
|
||||
private:
|
||||
|
||||
// Member functions ---------------------------------------------------------
|
||||
public:
|
||||
|
||||
COXDataCommunicator(CCommunicatorDoc* pCommunicatorDoc, UINT nStreamBufferSize = 4096);
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Constructs the object
|
||||
|
||||
virtual void OnClientCreate(HCLIENT_COMMUNICATOR hClient, COXCommunicator* pClientCommunicator);
|
||||
virtual void OnClientReceive(HCLIENT_COMMUNICATOR hClient, COXCommunicator* pClientCommunicator, DWORD nSize, int nErrorCode);
|
||||
virtual void OnClientClose(HCLIENT_COMMUNICATOR hClient, COXCommunicator* pClientCommunicator, int nErrorCode);
|
||||
|
||||
virtual void OnServerReceive(DWORD nSize, int nErrorCode);
|
||||
virtual void OnServerClose(int nErrorCode);
|
||||
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : AssertValid performs a validity check on this object
|
||||
// by checking its internal state.
|
||||
// In the Debug version of the library, AssertValid may assert and
|
||||
// thus terminate the program.
|
||||
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
// --- In : dc : The diagnostic dump context for dumping, usually afxDump.
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Dumps the contents of the object to a CDumpContext object.
|
||||
// It provides diagnostic services for yourself and
|
||||
// other users of your class.
|
||||
// Note The Dump function does not print a newline character
|
||||
// at the end of its output.
|
||||
#endif
|
||||
|
||||
virtual ~COXDataCommunicator();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of the object
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif // __OXDATACOMMUNICATOR_H__
|
||||
// ==========================================================================
|
||||
@ -0,0 +1,42 @@
|
||||
// SendDataDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSendDataDlg dialog
|
||||
|
||||
#include "OXCommMsg.h"
|
||||
|
||||
class CSendDataDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CSendDataDlg(COXCommMsg* pCommMsg, CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CSendDataDlg)
|
||||
enum { IDD = IDD_SEND_DATA };
|
||||
CButton m_wndBrowse;
|
||||
CListBox m_wndList;
|
||||
CString m_sValue;
|
||||
int m_nType;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CSendDataDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
COXCommMsg* m_pCommMsg;
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CSendDataDlg)
|
||||
afx_msg void OnAdd();
|
||||
afx_msg void OnBrowse();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
@ -0,0 +1,6 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// Communicator.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include <afxwin.h> // MFC core and standard components
|
||||
#include <afxext.h> // MFC extensions
|
||||
#include <afxdisp.h> // MFC OLE automation classes
|
||||
#ifndef _AFX_NO_AFXCMN_SUPPORT
|
||||
#include <afxcmn.h> // MFC support for Windows 95 Common Controls
|
||||
#endif // _AFX_NO_AFXCMN_SUPPORT
|
||||
|
||||
#include <afxsock.h> // MFC socket extensions
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,13 @@
|
||||
//
|
||||
// COMMUNICATOR.RC2 - resources Microsoft Visual C++ does not edit directly
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#error this file is not editable by Microsoft Visual C++
|
||||
#endif //APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Add manually edited resources here...
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,66 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by Communicator.rc
|
||||
//
|
||||
#define IDD_ABOUTBOX 100
|
||||
#define IDP_OLE_INIT_FAILED 100
|
||||
#define IDD_COMMUNICATOR_FORM 101
|
||||
#define IDP_SOCKETS_INIT_FAILED 104
|
||||
#define IDR_MAINFRAME 128
|
||||
#define IDR_COMMTYPE 129
|
||||
#define IDD_SEND_DATA 130
|
||||
#define IDS_INVALID_VALUE 130
|
||||
#define IDS_FAILED_LISTEN 131
|
||||
#define IDS_FAILED_CONNECT 132
|
||||
#define IDC_LOCAL_ADDRESS 1000
|
||||
#define IDC_LOCAL_PORT 1001
|
||||
#define IDC_CLIENT_ADDRESSES 1002
|
||||
#define IDC_SEND_CLIENT 1003
|
||||
#define IDC_DISCONNECT_CLIENT 1004
|
||||
#define IDC_RECEIVED_DATA 1005
|
||||
#define IDC_LISTEN 1006
|
||||
#define IDC_CANCEL 1007
|
||||
#define IDC_SHUTDOWN 1008
|
||||
#define IDC_EMPTY 1009
|
||||
#define IDC_LOCAL_ADDRESS_LABEL 1009
|
||||
#define IDC_NULL 1010
|
||||
#define IDC_LOCAL_PORT_LABEL 1010
|
||||
#define IDC_BOOL 1011
|
||||
#define IDC_CLIENT_ADDRESSES_LABEL 1011
|
||||
#define IDC_UI1 1012
|
||||
#define IDC_REMOTE_PORT 1012
|
||||
#define IDC_I2 1013
|
||||
#define IDC_CONNECT_SERVER 1013
|
||||
#define IDC_I4 1014
|
||||
#define IDC_DISCONNECT_SERVER 1014
|
||||
#define IDC_CY 1015
|
||||
#define IDC_SEND_SERVER 1015
|
||||
#define IDC_R4 1016
|
||||
#define IDC_REMOTE_ADDRESS 1016
|
||||
#define IDC_R8 1017
|
||||
#define IDC_SPY 1017
|
||||
#define IDC_BSTR 1018
|
||||
#define IDC_REMOTE_ADDRESS_LABEL 1018
|
||||
#define IDC_DATE 1019
|
||||
#define IDC_REMOTE_PORT_LABEL 1019
|
||||
#define IDC_ERROR 1020
|
||||
#define IDC_SERVER_GROUP 1020
|
||||
#define IDC_VALUE 1021
|
||||
#define IDC_CLIENT_GROUP 1021
|
||||
#define IDC_ADD 1022
|
||||
#define IDC_LIST 1023
|
||||
#define IDC_BINARY 1024
|
||||
#define IDC_BROWSE 1025
|
||||
#define ID_DESCRIPTION_FILE 61216
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_3D_CONTROLS 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 132
|
||||
#define _APS_NEXT_COMMAND_VALUE 32772
|
||||
#define _APS_NEXT_CONTROL_VALUE 1022
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
@ -0,0 +1,142 @@
|
||||
// SendDataDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Communicator.h"
|
||||
#include "SendDataDlg.h"
|
||||
#include "OXBlob.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSendDataDlg dialog
|
||||
|
||||
|
||||
CSendDataDlg::CSendDataDlg(COXCommMsg* pCommMsg, CWnd* pParent /*=NULL*/)
|
||||
:
|
||||
CDialog(CSendDataDlg::IDD, pParent),
|
||||
m_pCommMsg(pCommMsg)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CSendDataDlg)
|
||||
m_sValue = _T("");
|
||||
m_nType = 9;
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void CSendDataDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CSendDataDlg)
|
||||
DDX_Control(pDX, IDC_BROWSE, m_wndBrowse);
|
||||
DDX_Control(pDX, IDC_LIST, m_wndList);
|
||||
DDX_Text(pDX, IDC_VALUE, m_sValue);
|
||||
DDX_Radio(pDX, IDC_EMPTY, m_nType);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CSendDataDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CSendDataDlg)
|
||||
ON_BN_CLICKED(IDC_ADD, OnAdd)
|
||||
ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSendDataDlg message handlers
|
||||
|
||||
void CSendDataDlg::OnAdd()
|
||||
{
|
||||
UINT nOleType = 0;
|
||||
COXVariant oleVariant;
|
||||
BOOL bSuccess = FALSE;
|
||||
CString sValue;
|
||||
|
||||
UpdateData(TRUE);
|
||||
ASSERT((0 <= m_nType) && (m_nType < COXCommMsg::m_nArgumentTypesCount));
|
||||
nOleType = COXCommMsg::m_types[m_nType];
|
||||
|
||||
// Assign as string and then let OLE convert it
|
||||
oleVariant = m_sValue;
|
||||
long nFileLength = 0;
|
||||
TRY
|
||||
{
|
||||
if (nOleType == COXCommMsg::ATBlob)
|
||||
{
|
||||
COXBlob blob;
|
||||
bSuccess = blob.ReadRaw(m_sValue);
|
||||
nFileLength = blob.GetSize();
|
||||
oleVariant = blob;
|
||||
}
|
||||
else if (nOleType != COXCommMsg::ATError)
|
||||
{
|
||||
oleVariant.ChangeType((VARTYPE)nOleType);
|
||||
bSuccess = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Conversions to and from VT_ERROR is not available from OLE
|
||||
// Use a VT_I4 instead
|
||||
oleVariant.ChangeType(COXCommMsg::ATI4);
|
||||
// ... Variant is a union, just change the type
|
||||
// oleVariant.scode = oleVariant.lVal;
|
||||
V_VT(&oleVariant) = (VARTYPE)nOleType;
|
||||
bSuccess = TRUE;
|
||||
}
|
||||
}
|
||||
END_TRY
|
||||
|
||||
if (bSuccess)
|
||||
{
|
||||
m_pCommMsg->Add(oleVariant);
|
||||
// Convert back to string to visualize
|
||||
CString sText;
|
||||
TRY
|
||||
{
|
||||
if (nOleType == COXCommMsg::ATBlob)
|
||||
sText.Format(_T("<binary of length %i>"), nFileLength);
|
||||
else
|
||||
{
|
||||
if (V_VT(&oleVariant) == COXCommMsg::ATError)
|
||||
// ... Variant is a union, just change the type
|
||||
// oleVariant.lVal= oleVariant.scode ;
|
||||
V_VT(&oleVariant) = COXCommMsg::ATI4;
|
||||
oleVariant.ChangeType(COXCommMsg::ATStr);
|
||||
sText = V_BSTR(&oleVariant);
|
||||
}
|
||||
}
|
||||
END_TRY
|
||||
sValue.Format(_T("%i. (%s) %s"),
|
||||
m_wndList.GetCount() + 1,
|
||||
(LPCTSTR)COXCommMsg::m_typeNames[m_nType],
|
||||
(LPCTSTR)sText);
|
||||
m_wndList.AddString(sValue);
|
||||
m_wndList.SetTopIndex(m_wndList.GetCount() - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
AfxMessageBox(IDS_INVALID_VALUE, MB_ICONEXCLAMATION);
|
||||
}
|
||||
}
|
||||
|
||||
void CSendDataDlg::OnBrowse()
|
||||
{
|
||||
UpdateData(TRUE);
|
||||
static TCHAR szFilter[] = _T("All Files (*.*) | *.* ||");
|
||||
CFileDialog fileDlg(TRUE, NULL, _T("*.*"), NULL, szFilter);
|
||||
|
||||
if (fileDlg.DoModal() == IDOK)
|
||||
{
|
||||
m_sValue = fileDlg.GetPathName();
|
||||
// ... Set to Blob type by default
|
||||
m_nType = 12;
|
||||
UpdateData(FALSE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,162 @@
|
||||
// CgiHandler.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "CgiHandler.h"
|
||||
#include "CgiToOleDrv.h"
|
||||
#include "MailEngine.h"
|
||||
#include "XString.h"
|
||||
|
||||
#define MR_PROFILE _T("Profile")
|
||||
#define MR_PASSWORD _T("Password")
|
||||
#define MR_TO _T("To")
|
||||
#define MR_SUBJECT _T("Subject")
|
||||
#define MR_CONTENT _T("Content")
|
||||
#define MR_ATTCOUNT _T("AttCount")
|
||||
#define MR_ATTACHMENT _T("Attachment")
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCgiHandler
|
||||
|
||||
IMPLEMENT_DYNCREATE(CCgiHandler, COXOwnThreadCmdTarget)
|
||||
|
||||
CCgiHandler::CCgiHandler()
|
||||
{
|
||||
EnableAutomation();
|
||||
EnableOwnThread();
|
||||
|
||||
AfxOleLockApp();
|
||||
}
|
||||
|
||||
CCgiHandler::~CCgiHandler()
|
||||
{
|
||||
// To terminate the application when all objects created with
|
||||
// with OLE automation, the destructor calls AfxOleUnlockApp.
|
||||
|
||||
AfxOleUnlockApp();
|
||||
}
|
||||
|
||||
|
||||
void CCgiHandler::OnFinalRelease()
|
||||
{
|
||||
// When the last reference for an automation object is released
|
||||
// OnFinalRelease is called. The base class will automatically
|
||||
// deletes the object. Add additional cleanup required for your
|
||||
// object before calling the base class.
|
||||
|
||||
COXOwnThreadCmdTarget::OnFinalRelease();
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CCgiHandler, COXOwnThreadCmdTarget)
|
||||
//{{AFX_MSG_MAP(CCgiHandler)
|
||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
BEGIN_DISPATCH_MAP(CCgiHandler, COXOwnThreadCmdTarget)
|
||||
//{{AFX_DISPATCH_MAP(CCgiHandler)
|
||||
DISP_FUNCTION(CCgiHandler, "OnGet", OnGet, VT_EMPTY, VTS_DISPATCH VTS_BSTR)
|
||||
DISP_FUNCTION(CCgiHandler, "OnPost", OnPost, VT_EMPTY, VTS_DISPATCH VTS_BSTR VTS_BSTR)
|
||||
//}}AFX_DISPATCH_MAP
|
||||
END_DISPATCH_MAP()
|
||||
|
||||
// Note: we add support for IID_ICgiHandler to support typesafe binding
|
||||
// from VBA. This IID must match the GUID that is attached to the
|
||||
// dispinterface in the .ODL file.
|
||||
|
||||
// {48452B96-D40F-11CF-AA2E-00AA00489A36}
|
||||
static const IID IID_ICgiHandler =
|
||||
{ 0x48452b96, 0xd40f, 0x11cf, { 0xaa, 0x2e, 0x0, 0xaa, 0x0, 0x48, 0x9a, 0x36 } };
|
||||
|
||||
BEGIN_INTERFACE_MAP(CCgiHandler, CCmdTarget)
|
||||
INTERFACE_PART(CCgiHandler, IID_ICgiHandler, Dispatch)
|
||||
END_INTERFACE_MAP()
|
||||
|
||||
// {48452B97-D40F-11CF-AA2E-00AA00489A36}
|
||||
IMPLEMENT_OLECREATE(CCgiHandler, "OXSENDMAIL.CGIHANDLER", 0x48452b97, 0xd40f, 0x11cf, 0xaa, 0x2e, 0x0, 0xaa, 0x0, 0x48, 0x9a, 0x36)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCgiHandler message handlers
|
||||
|
||||
#include "MailEngine.h"
|
||||
|
||||
void CCgiHandler::OnGet(LPDISPATCH pCgiObj, LPCTSTR sCommand)
|
||||
{
|
||||
UNUSED(sCommand);
|
||||
CCgiDispatchDrv cgiObj;
|
||||
|
||||
cgiObj.AttachDispatch(pCgiObj, FALSE);
|
||||
cgiObj.SetOutput(_T("<HTML>\n<BODY>\n"));
|
||||
cgiObj.SetOutput(_T("<H2>CGI Get Method is not supported !!</H2>\n"));
|
||||
cgiObj.SetOutput(_T("</BODY>\n</HTML>\n"));
|
||||
}
|
||||
|
||||
|
||||
void CCgiHandler::OnPost(LPDISPATCH pCgiObj, LPCTSTR sInputType, LPCTSTR sInputBuffer)
|
||||
{
|
||||
UNUSED(sInputType);
|
||||
UNUSED(sInputBuffer);
|
||||
|
||||
CCgiDispatchDrv cgiObj;
|
||||
CString sProfile;
|
||||
CString sPassword;
|
||||
CString sTo;
|
||||
CString sSubject;
|
||||
CString sContent;
|
||||
COXString sAttCount;
|
||||
int nAttCount;
|
||||
CStringArray sAttachments;
|
||||
short nLastError;
|
||||
CString sOutputString;
|
||||
COleVariant sInputPar;
|
||||
|
||||
cgiObj.AttachDispatch(pCgiObj, FALSE);
|
||||
|
||||
sInputPar = MR_PROFILE;
|
||||
sProfile = cgiObj.GetInput(sInputPar);
|
||||
sInputPar = MR_PASSWORD;
|
||||
sPassword = cgiObj.GetInput(sInputPar);
|
||||
sInputPar = MR_TO;
|
||||
sTo = cgiObj.GetInput(sInputPar);
|
||||
sInputPar = MR_SUBJECT;
|
||||
sSubject = cgiObj.GetInput(sInputPar);
|
||||
sInputPar = MR_CONTENT;
|
||||
sContent = cgiObj.GetInput(sInputPar);
|
||||
sInputPar = MR_ATTCOUNT;
|
||||
sAttCount = cgiObj.GetInput(sInputPar);
|
||||
nAttCount = sAttCount.GetInt();
|
||||
sInputPar = MR_ATTACHMENT;
|
||||
for (int i=0 ; i<nAttCount ; i++)
|
||||
sAttachments.Add(cgiObj.GetInput(sInputPar));
|
||||
|
||||
cgiObj.SetOutput(_T("<HTML><BODY>"));
|
||||
|
||||
BOOL bResult = theMailEngine.Send(
|
||||
sProfile,
|
||||
sPassword,
|
||||
sTo,
|
||||
sSubject,
|
||||
sContent,
|
||||
sAttachments,
|
||||
nLastError);
|
||||
|
||||
if (bResult)
|
||||
{
|
||||
sOutputString.Format(_T("<P><H2>Mail sent successfully !!</H2></P>\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
sOutputString.Format(_T("<P><H2>Mail failed !!</H2></P>\n"));
|
||||
}
|
||||
cgiObj.SetOutput(sOutputString);
|
||||
|
||||
cgiObj.SetOutput(_T("</BODY></HTML>"));
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
// CgiHandler.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// HTML of the implementation of this sendmail utility
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// <FORM METHOD="POST" ACTION="CGI/CgiToOle.exe/OXSENDMAIL.CGIHANDLER">
|
||||
// <INPUT NAME="Profile" TYPE="HIDDEN" VALUE="Kris" ALIGN=left>
|
||||
// <INPUT NAME="To" TYPE="HIDDEN" VALUE="Kris" ALIGN=left>
|
||||
// <INPUT NAME="Subject" TYPE="HIDDEN" VALUE="Testje" ALIGN=left>
|
||||
// <INPUT NAME="Content" TYPE="HIDDEN" VALUE="Fuck You" ALIGN=left>
|
||||
// <INPUT NAME="AttCount" TYPE="HIDDEN" VALUE="1" ALIGN=left>
|
||||
// <INPUT NAME="Attachment" TYPE="HIDDEN" VALUE="C:\test.bmp" ALIGN=left>
|
||||
// <INPUT TYPE="SUBMIT" VALUE="OXSendMail">
|
||||
// </FORM>
|
||||
//
|
||||
// In stead of CgiToOle.exe you can use IsapiOle.dll in case of an ISAPI compliant HTTP server
|
||||
|
||||
#include "OXOwnThreadCmdTarget.h"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCgiHandler command target
|
||||
|
||||
class CCgiHandler : public COXOwnThreadCmdTarget
|
||||
{
|
||||
DECLARE_DYNCREATE(CCgiHandler)
|
||||
|
||||
CCgiHandler(); // protected constructor used by dynamic creation
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CCgiHandler)
|
||||
public:
|
||||
virtual void OnFinalRelease();
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
virtual ~CCgiHandler();
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CCgiHandler)
|
||||
// NOTE - the ClassWizard will add and remove member functions here.
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
DECLARE_OLECREATE(CCgiHandler)
|
||||
|
||||
// Generated OLE dispatch map functions
|
||||
//{{AFX_DISPATCH(CCgiHandler)
|
||||
afx_msg void OnGet(LPDISPATCH pCgiObj, LPCTSTR sCommand);
|
||||
afx_msg void OnPost(LPDISPATCH pCgiObj, LPCTSTR sInputType, LPCTSTR sInputBuffer);
|
||||
//}}AFX_DISPATCH
|
||||
DECLARE_DISPATCH_MAP()
|
||||
DECLARE_INTERFACE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@ -0,0 +1,89 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Desciption :
|
||||
// CMailCmd class
|
||||
|
||||
// Remark:
|
||||
//
|
||||
// Prerequisites (necessary conditions):
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __MAILCMD_H_
|
||||
#define __MAILCMD_H_
|
||||
|
||||
enum EMailCmd
|
||||
{
|
||||
mcNothing = 0,
|
||||
mcLogOn,
|
||||
mcLogOff,
|
||||
mcSend
|
||||
};
|
||||
|
||||
class CMailCmd : public COXEngineCmd
|
||||
{
|
||||
// Data Members
|
||||
public:
|
||||
EMailCmd eCmd;
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
// Member Functions
|
||||
public:
|
||||
CMailCmd(EMailCmd eC = mcNothing, BOOL bSynchrone = TRUE, COXDoneNotifier* pDoneNotifier = NULL) :
|
||||
COXEngineCmd(bSynchrone, pDoneNotifier),
|
||||
eCmd(eC) {}
|
||||
virtual ~CMailCmd() {}
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
class CMCLogOn: public CMailCmd
|
||||
{
|
||||
public:
|
||||
CString sProfile;
|
||||
CString sPassword;
|
||||
BOOL bResult;
|
||||
|
||||
CMCLogOn(CString sProf, CString sPassw) :
|
||||
CMailCmd(mcLogOn),
|
||||
sProfile(sProf),
|
||||
sPassword(sPassw),
|
||||
bResult(FALSE) {}
|
||||
};
|
||||
|
||||
class CMCLogOff: public CMailCmd
|
||||
{
|
||||
public:
|
||||
CMCLogOff() :
|
||||
CMailCmd(mcLogOff) {}
|
||||
};
|
||||
|
||||
class CMCSend: public CMailCmd
|
||||
{
|
||||
public:
|
||||
CString sRecipient;
|
||||
CString sSubject;
|
||||
CString sContent;
|
||||
CStringArray sAttachments;
|
||||
short nError;
|
||||
|
||||
CMCSend(CString sRecip,
|
||||
CString sSubj,
|
||||
CString sCont,
|
||||
const CStringArray& sAttatchs) :
|
||||
CMailCmd(mcSend),
|
||||
sSubject(sSubj),
|
||||
sContent(sCont),
|
||||
sRecipient(sRecip),
|
||||
nError(0) {
|
||||
sAttachments.Copy(sAttatchs);}
|
||||
};
|
||||
|
||||
|
||||
#endif // __MAILCMD_H_
|
||||
@ -0,0 +1,185 @@
|
||||
// MailEngine.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "MailEngine.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
short CMailEngine::defError = 0;
|
||||
|
||||
CMailEngine theMailEngine;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMailEngine
|
||||
|
||||
CMailEngine::CMailEngine()
|
||||
{
|
||||
}
|
||||
|
||||
CMailEngine::~CMailEngine()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL CMailEngine::LogOn(CString sProfile, CString sPassword)
|
||||
{
|
||||
BOOL bResult;
|
||||
|
||||
CMCLogOn* pCmd = new CMCLogOn(sProfile, sPassword);
|
||||
PostCommand(pCmd);
|
||||
bResult = pCmd->bResult;
|
||||
pCmd->Release();
|
||||
return bResult;
|
||||
}
|
||||
|
||||
void CMailEngine::LogOff()
|
||||
{
|
||||
CMailCmd* pCmd = new CMCLogOff();
|
||||
PostCommand(pCmd);
|
||||
pCmd->Release();
|
||||
}
|
||||
|
||||
BOOL CMailEngine::IsLoggedOn()
|
||||
{
|
||||
return m_sendMail.IsInitialized();
|
||||
}
|
||||
|
||||
BOOL CMailEngine::Send(CString sProfile,
|
||||
CString sPassword,
|
||||
CString sRecipient,
|
||||
CString sSubject,
|
||||
CString sContent,
|
||||
const CStringArray& sAttachments,
|
||||
short& nError)
|
||||
{
|
||||
CMailCmd* pCmd;
|
||||
|
||||
pCmd = new CMCLogOn(sProfile, sPassword);
|
||||
PostCommand(pCmd);
|
||||
pCmd->Release();
|
||||
|
||||
pCmd = new CMCSend(sRecipient,
|
||||
sSubject,
|
||||
sContent,
|
||||
sAttachments);
|
||||
PostCommand(pCmd);
|
||||
nError = ((CMCSend*)pCmd)->nError;
|
||||
pCmd->Release();
|
||||
|
||||
return (nError == 0);
|
||||
}
|
||||
|
||||
|
||||
// protected:
|
||||
|
||||
void CMailEngine::OnExecuteCmd(COXEngineCmd* pCmd)
|
||||
{
|
||||
switch (((CMailCmd*) pCmd)->eCmd)
|
||||
{
|
||||
case mcLogOn:
|
||||
OnLogOn(*((CMCLogOn*) pCmd));
|
||||
break;
|
||||
case mcLogOff:
|
||||
OnLogOff(*((CMCLogOff*) pCmd));
|
||||
break;
|
||||
case mcSend:
|
||||
OnSend(*((CMCSend*) pCmd));
|
||||
break;
|
||||
default:
|
||||
TRACE(_T("'CMailEngine::OnThreadEvent' Unknown command ! \n"));
|
||||
ASSERT(FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CMailEngine::OnThreadDestruction()
|
||||
{
|
||||
COXThreadEngine::OnThreadDestruction();
|
||||
if (m_sendMail.IsInitialized())
|
||||
m_sendMail.Uninitialize();
|
||||
}
|
||||
|
||||
void CMailEngine::OnLogOn(CMCLogOn& cmd)
|
||||
{
|
||||
CString sProfile;
|
||||
// HANDLE hToken;
|
||||
|
||||
sProfile = m_sendMail.GetProfile();
|
||||
|
||||
if (sProfile != cmd.sProfile)
|
||||
{
|
||||
if (m_sendMail.IsInitialized())
|
||||
m_sendMail.Uninitialize();
|
||||
}
|
||||
else if (m_sendMail.IsInitialized())
|
||||
{
|
||||
cmd.bResult = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//LOGON32_LOGON_BATCH
|
||||
//LOGON32_LOGON_INTERACTIVE
|
||||
//LOGON32_LOGON_SERVICE
|
||||
|
||||
/* if (!::LogonUser(_T("Kris"), _T("PERIDEV"), _T("poke725"), LOGON32_LOGON_BATCH, LOGON32_PROVIDER_DEFAULT, &hToken))
|
||||
{
|
||||
DWORD dwResult = GetLastError();
|
||||
if (dwResult == ERROR_PRIVILEGE_NOT_HELD)
|
||||
{
|
||||
cmd.bResult = FALSE;
|
||||
}
|
||||
cmd.bResult = FALSE;
|
||||
return;
|
||||
}
|
||||
if (!ImpersonateLoggedOnUser(hToken))
|
||||
{
|
||||
cmd.bResult = FALSE;
|
||||
return;
|
||||
}
|
||||
*/
|
||||
if (m_sendMail.Initialize(cmd.sProfile, cmd.sPassword)==FALSE)
|
||||
{
|
||||
cmd.bResult = FALSE;
|
||||
return;
|
||||
}
|
||||
cmd.bResult = TRUE;
|
||||
}
|
||||
|
||||
void CMailEngine::OnLogOff(CMCLogOff& cmd)
|
||||
{
|
||||
UNUSED(cmd);
|
||||
if (m_sendMail.IsInitialized())
|
||||
m_sendMail.Uninitialize();
|
||||
}
|
||||
|
||||
void CMailEngine::OnSend(CMCSend& cmd)
|
||||
{
|
||||
CString sAttachments;
|
||||
|
||||
if (m_sendMail.IsInitialized() == FALSE)
|
||||
{
|
||||
cmd.nError = MR_MMERR_LOGON;
|
||||
return;
|
||||
}
|
||||
|
||||
COXSendMail::CMessage message;
|
||||
|
||||
message.m_sSubject = cmd.sSubject;
|
||||
message.m_sContent = cmd.sContent;
|
||||
message.AddRecipient(cmd.sRecipient, COXSendMail::rtTO);
|
||||
for (int i=0 ; i<cmd.sAttachments.GetSize() ; i++)
|
||||
message.AddAttachment(cmd.sAttachments[i], COXSendMail::atFileData);
|
||||
|
||||
|
||||
if (m_sendMail.SendMessage(message) == FALSE)
|
||||
{
|
||||
cmd.nError = MR_MMERR_RECIPIENT;
|
||||
return;
|
||||
}
|
||||
cmd.nError = MR_MMERR_SUCCESS;
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
#ifndef __MAILENGINE_H_
|
||||
#define __MAILENGINE_H_
|
||||
|
||||
#include "OXThreadEngine.h"
|
||||
#include "OXSendMail.h"
|
||||
#include "MailCmd.h"
|
||||
|
||||
#define MR_MMERR_SUCCESS 0x0000
|
||||
#define MR_MMERR_LOGON 0x0101
|
||||
#define MR_MMERR_RECIPIENT 0x0102
|
||||
#define MR_MMERR_SENT 0x0103
|
||||
#define MR_MMERR_HOMEID 0x0104
|
||||
|
||||
|
||||
class CMailEngine : public COXThreadEngine
|
||||
{
|
||||
// Data Members
|
||||
public:
|
||||
|
||||
protected:
|
||||
COXSendMail m_sendMail;
|
||||
|
||||
private:
|
||||
static short defError;
|
||||
|
||||
// Member Functions
|
||||
public:
|
||||
CMailEngine();
|
||||
virtual ~CMailEngine();
|
||||
|
||||
BOOL LogOn(CString sProfile, CString sPassword);
|
||||
void LogOff();
|
||||
BOOL IsLoggedOn();
|
||||
BOOL Send(CString sMAPIProfile,
|
||||
CString sMAPIPassword,
|
||||
CString sRecipient,
|
||||
CString sSubject,
|
||||
CString sContent,
|
||||
const CStringArray& sAttachments,
|
||||
short& nError = defError);
|
||||
|
||||
|
||||
protected:
|
||||
virtual void OnExecuteCmd(COXEngineCmd* pCmd);
|
||||
virtual void OnThreadDestruction();
|
||||
|
||||
void OnLogOn(CMCLogOn& cmd);
|
||||
void OnLogOff(CMCLogOff& cmd);
|
||||
void OnSend(CMCSend& cmd);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
extern CMailEngine theMailEngine;
|
||||
|
||||
#endif // __MAILENGINE_H_
|
||||
@ -0,0 +1,144 @@
|
||||
// MailMessage.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "MailEngine.h"
|
||||
#include "MailMessage.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMailMessage
|
||||
|
||||
IMPLEMENT_DYNCREATE(CMailMessage, COXOwnThreadCmdTarget)
|
||||
|
||||
CMailMessage::CMailMessage() :
|
||||
m_nLastError(MR_MMERR_SUCCESS)
|
||||
{
|
||||
EnableAutomation();
|
||||
EnableOwnThread();
|
||||
|
||||
AfxOleLockApp();
|
||||
}
|
||||
|
||||
CMailMessage::~CMailMessage()
|
||||
{
|
||||
// To terminate the application when all objects created with
|
||||
// with OLE automation, the destructor calls AfxOleUnlockApp.
|
||||
|
||||
AfxOleUnlockApp();
|
||||
}
|
||||
|
||||
|
||||
void CMailMessage::OnFinalRelease()
|
||||
{
|
||||
// When the last reference for an automation object is released
|
||||
// OnFinalRelease is called. The base class will automatically
|
||||
// deletes the object. Add additional cleanup required for your
|
||||
// object before calling the base class.
|
||||
|
||||
COXOwnThreadCmdTarget::OnFinalRelease();
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMailMessage, COXOwnThreadCmdTarget)
|
||||
//{{AFX_MSG_MAP(CMailMessage)
|
||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
BEGIN_DISPATCH_MAP(CMailMessage, COXOwnThreadCmdTarget)
|
||||
//{{AFX_DISPATCH_MAP(CMailMessage)
|
||||
DISP_PROPERTY_NOTIFY(CMailMessage, "Subject", m_sSubject, OnSubjectChanged, VT_BSTR)
|
||||
DISP_PROPERTY_NOTIFY(CMailMessage, "Content", m_sContent, OnContentChanged, VT_BSTR)
|
||||
DISP_PROPERTY_NOTIFY(CMailMessage, "AttachmentCount", m_nAttachmentCount, OnAttachmentCountChanged, VT_I2)
|
||||
DISP_PROPERTY_NOTIFY(CMailMessage, "LastError", m_nLastError, OnLastErrorChanged, VT_I2)
|
||||
DISP_PROPERTY_NOTIFY(CMailMessage, "To", m_sTo, OnToChanged, VT_BSTR)
|
||||
DISP_PROPERTY_NOTIFY(CMailMessage, "Profile", m_sProfile, OnProfileChanged, VT_BSTR)
|
||||
DISP_PROPERTY_NOTIFY(CMailMessage, "Password", m_sPassword, OnPasswordChanged, VT_BSTR)
|
||||
DISP_FUNCTION(CMailMessage, "AddAttachment", AddAttachment, VT_BOOL, VTS_BSTR)
|
||||
DISP_FUNCTION(CMailMessage, "GetAttachment", GetAttachment, VT_BSTR, VTS_I2)
|
||||
DISP_FUNCTION(CMailMessage, "RemoveAttachment", RemoveAttachment, VT_BOOL, VTS_I2)
|
||||
DISP_FUNCTION(CMailMessage, "Send", Send, VT_BOOL, VTS_NONE)
|
||||
//}}AFX_DISPATCH_MAP
|
||||
END_DISPATCH_MAP()
|
||||
|
||||
// Note: we add support for IID_IMailMessage to support typesafe binding
|
||||
// from VBA. This IID must match the GUID that is attached to the
|
||||
// dispinterface in the .ODL file.
|
||||
|
||||
// {48452B86-D40F-11CF-AA2E-00AA00489A36}
|
||||
static const IID IID_IMailMessage =
|
||||
{ 0x48452b86, 0xd40f, 0x11cf, { 0xaa, 0x2e, 0x0, 0xaa, 0x0, 0x48, 0x9a, 0x36 } };
|
||||
|
||||
BEGIN_INTERFACE_MAP(CMailMessage, CCmdTarget)
|
||||
INTERFACE_PART(CMailMessage, IID_IMailMessage, Dispatch)
|
||||
END_INTERFACE_MAP()
|
||||
|
||||
// {48452B86-D40F-11CF-AA2E-00AA00489A36}
|
||||
IMPLEMENT_OLECREATE(CMailMessage, "OXSENDMAIL.MESSAGE", 0x48452b87, 0xd40f, 0x11cf, 0xaa, 0x2e, 0x0, 0xaa, 0x0, 0x48, 0x9a, 0x36)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMailMessage message handlers
|
||||
|
||||
BOOL CMailMessage::Send()
|
||||
{
|
||||
BOOL bResult = FALSE;
|
||||
CString sProfile;
|
||||
CString sPassword;
|
||||
|
||||
bResult = theMailEngine.Send(
|
||||
m_sProfile,
|
||||
m_sPassword,
|
||||
m_sTo,
|
||||
m_sSubject,
|
||||
m_sContent,
|
||||
m_sAttachments,
|
||||
m_nLastError);
|
||||
if (!bResult)
|
||||
m_nLastError = MR_MMERR_HOMEID;
|
||||
return bResult;
|
||||
}
|
||||
|
||||
BOOL CMailMessage::AddAttachment(LPCTSTR sFilePath)
|
||||
{
|
||||
CFileStatus status;
|
||||
|
||||
if (!CFile::GetStatus(sFilePath, status))
|
||||
return FALSE;
|
||||
m_sAttachments.Add(sFilePath);
|
||||
m_nAttachmentCount = (short)m_sAttachments.GetSize();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BSTR CMailMessage::GetAttachment(short nIndex)
|
||||
{
|
||||
CString strResult;
|
||||
|
||||
if (nIndex >= m_sAttachments.GetSize())
|
||||
return FALSE;
|
||||
strResult = m_sAttachments[nIndex];
|
||||
return strResult.AllocSysString();
|
||||
}
|
||||
|
||||
BOOL CMailMessage::RemoveAttachment(short nIndex)
|
||||
{
|
||||
if (nIndex >= m_sAttachments.GetSize())
|
||||
return FALSE;
|
||||
m_sAttachments.RemoveAt(nIndex);
|
||||
m_nAttachmentCount = (short)m_sAttachments.GetSize();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void CMailMessage::OnSubjectChanged() {}
|
||||
void CMailMessage::OnContentChanged() {}
|
||||
void CMailMessage::OnAttachmentCountChanged() {GetNotSupported();}
|
||||
void CMailMessage::OnLastErrorChanged() {GetNotSupported();}
|
||||
void CMailMessage::OnToChanged() {}
|
||||
void CMailMessage::OnProfileChanged() {}
|
||||
void CMailMessage::OnPasswordChanged() {}
|
||||
@ -0,0 +1,91 @@
|
||||
// MailMessage.h : header file
|
||||
//
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Visual Basic sample of the implementation of this ole object
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Dim msg As Object
|
||||
// Dim bResult As Boolean
|
||||
//
|
||||
// Set msg = CreateObject("OXSENDMAIL.MESSAGE")
|
||||
// msg.Profile = "Kris"
|
||||
// msg.Password = ""
|
||||
// msg.To = "Kris"
|
||||
// msg.Subject = "Hello to myself"
|
||||
// msg.Content = "Hello and bye bye !!"
|
||||
// bResult = msg.AddAttachment("c:\test.bmp")
|
||||
// bResult = msg.Send()
|
||||
//
|
||||
|
||||
#include "OXOwnThreadCmdTarget.h"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMailMessage command target
|
||||
|
||||
class CMailEngine;
|
||||
|
||||
class CMailMessage : public COXOwnThreadCmdTarget
|
||||
{
|
||||
friend CMailEngine;
|
||||
|
||||
DECLARE_DYNCREATE(CMailMessage)
|
||||
|
||||
// Data Members
|
||||
public:
|
||||
|
||||
protected:
|
||||
CStringArray m_sAttachments;
|
||||
// See the OLE generated dispatch map functions in the function section below
|
||||
|
||||
private:
|
||||
|
||||
// Member Functions
|
||||
public:
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CMailMessage)
|
||||
virtual void OnFinalRelease();
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
protected:
|
||||
CMailMessage(); // protected constructor used by dynamic creation
|
||||
virtual ~CMailMessage();
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CMailMessage)
|
||||
// NOTE - the ClassWizard will add and remove member functions here.
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
DECLARE_OLECREATE(CMailMessage)
|
||||
|
||||
// Generated OLE dispatch map functions
|
||||
//{{AFX_DISPATCH(CMailMessage)
|
||||
CString m_sSubject;
|
||||
afx_msg void OnSubjectChanged();
|
||||
CString m_sContent;
|
||||
afx_msg void OnContentChanged();
|
||||
short m_nAttachmentCount;
|
||||
afx_msg void OnAttachmentCountChanged();
|
||||
short m_nLastError;
|
||||
afx_msg void OnLastErrorChanged();
|
||||
CString m_sTo;
|
||||
afx_msg void OnToChanged();
|
||||
CString m_sProfile;
|
||||
afx_msg void OnProfileChanged();
|
||||
CString m_sPassword;
|
||||
afx_msg void OnPasswordChanged();
|
||||
afx_msg BOOL AddAttachment(LPCTSTR sFilePatch);
|
||||
afx_msg BSTR GetAttachment(short nIndex);
|
||||
afx_msg BOOL RemoveAttachment(short nIndex);
|
||||
afx_msg BOOL Send();
|
||||
//}}AFX_DISPATCH
|
||||
DECLARE_DISPATCH_MAP()
|
||||
DECLARE_INTERFACE_MAP()
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@ -0,0 +1,6 @@
|
||||
//SUPPRESSIONPROJ:MailSend
|
||||
//VERSION:5.00
|
||||
//ENABLE:Yes
|
||||
!include Mfc.sup
|
||||
!include Rtl.sup
|
||||
|
||||
@ -0,0 +1,124 @@
|
||||
; CLW file contains information for the MFC ClassWizard
|
||||
|
||||
[General Info]
|
||||
Version=1
|
||||
LastClass=CMailSendDlg
|
||||
LastTemplate=CDialog
|
||||
NewFileInclude1=#include "stdafx.h"
|
||||
NewFileInclude2=#include "mailsend.h"
|
||||
LastPage=0
|
||||
|
||||
ClassCount=5
|
||||
Class1=CCgiHandler
|
||||
Class2=CMailMessage
|
||||
Class3=CMailSendApp
|
||||
Class4=CAboutDlg
|
||||
Class5=CMailSendDlg
|
||||
|
||||
ResourceCount=4
|
||||
Resource1=IDD_ABOUTBOX (English (U.S.))
|
||||
Resource2=IDD_MAILSEND_DIALOG
|
||||
Resource3=IDD_ABOUTBOX
|
||||
Resource4=IDD_MAILSEND_DIALOG (English (Canada))
|
||||
|
||||
[CLS:CCgiHandler]
|
||||
Type=0
|
||||
BaseClass=COXOwnThreadCmdTarget
|
||||
HeaderFile=CgiHandler.h
|
||||
ImplementationFile=CgiHandler.cpp
|
||||
|
||||
[CLS:CMailMessage]
|
||||
Type=0
|
||||
BaseClass=COXOwnThreadCmdTarget
|
||||
HeaderFile=MailMessage.h
|
||||
ImplementationFile=MailMessage.cpp
|
||||
|
||||
[CLS:CMailSendApp]
|
||||
Type=0
|
||||
BaseClass=CWinApp
|
||||
HeaderFile=MailSend.h
|
||||
ImplementationFile=MailSendDlg.cpp
|
||||
|
||||
[CLS:CAboutDlg]
|
||||
Type=0
|
||||
BaseClass=CDialog
|
||||
HeaderFile=MailSendDlg.cpp
|
||||
ImplementationFile=MailSendDlg.cpp
|
||||
|
||||
[CLS:CMailSendDlg]
|
||||
Type=0
|
||||
BaseClass=CDialog
|
||||
HeaderFile=MailSendDlg.h
|
||||
ImplementationFile=MailSendDlg.cpp
|
||||
Filter=D
|
||||
VirtualFilter=dWC
|
||||
LastObject=IDC_BUTTON_REMOVEATTACHMENT
|
||||
|
||||
[DLG:IDD_ABOUTBOX]
|
||||
Type=1
|
||||
Class=CAboutDlg
|
||||
ControlCount=8
|
||||
Control1=IDC_STATIC,static,1342177283
|
||||
Control2=IDC_STATIC,static,1342308480
|
||||
Control3=IDC_STATIC,static,1342308352
|
||||
Control4=IDOK,button,1342373889
|
||||
Control5=IDC_STATIC,static,1342308352
|
||||
Control6=IDC_STATIC,static,1342308352
|
||||
Control7=IDC_STATIC,static,1342308352
|
||||
Control8=IDC_STATIC,static,1342308352
|
||||
|
||||
[DLG:IDD_MAILSEND_DIALOG]
|
||||
Type=1
|
||||
Class=CMailSendDlg
|
||||
ControlCount=15
|
||||
Control1=IDC_PROFILE,edit,1350631552
|
||||
Control2=IDC_PASSWORD,edit,1350631552
|
||||
Control3=IDC_ADDRESS,edit,1350631552
|
||||
Control4=IDC_SUBJECT,edit,1350631552
|
||||
Control5=IDC_CONTENT,edit,1352728580
|
||||
Control6=IDC_ATTACHMENT,edit,1350631552
|
||||
Control7=IDC_SEND_MAIL,button,1342242816
|
||||
Control8=IDC_ABOUT,button,1342242816
|
||||
Control9=IDCANCEL,button,1342242816
|
||||
Control10=IDC_STATIC,static,1342308352
|
||||
Control11=IDC_STATIC,static,1342308352
|
||||
Control12=IDC_STATIC,static,1342308352
|
||||
Control13=IDC_STATIC,static,1342308352
|
||||
Control14=IDC_STATIC,static,1342308352
|
||||
Control15=IDC_STATIC,static,1342308352
|
||||
|
||||
[DLG:IDD_ABOUTBOX (English (U.S.))]
|
||||
Type=1
|
||||
Class=?
|
||||
ControlCount=8
|
||||
Control1=IDC_STATIC,static,1342177283
|
||||
Control2=IDC_STATIC,static,1342308480
|
||||
Control3=IDC_STATIC,static,1342308352
|
||||
Control4=IDOK,button,1342373889
|
||||
Control5=IDC_STATIC,static,1342308352
|
||||
Control6=IDC_STATIC,static,1342308352
|
||||
Control7=IDC_STATIC,static,1342308352
|
||||
Control8=IDC_STATIC,static,1342308352
|
||||
|
||||
[DLG:IDD_MAILSEND_DIALOG (English (Canada))]
|
||||
Type=1
|
||||
Class=CMailSendDlg
|
||||
ControlCount=17
|
||||
Control1=IDC_PROFILE,edit,1350631552
|
||||
Control2=IDC_PASSWORD,edit,1350631552
|
||||
Control3=IDC_ADDRESS,edit,1350631552
|
||||
Control4=IDC_SUBJECT,edit,1350631552
|
||||
Control5=IDC_CONTENT,edit,1352728580
|
||||
Control6=IDC_SEND_MAIL,button,1342242816
|
||||
Control7=IDC_ABOUT,button,1342242816
|
||||
Control8=IDCANCEL,button,1342242816
|
||||
Control9=IDC_STATIC,static,1342308352
|
||||
Control10=IDC_STATIC,static,1342308352
|
||||
Control11=IDC_STATIC,static,1342308352
|
||||
Control12=IDC_STATIC,static,1342308352
|
||||
Control13=IDC_STATIC,static,1342308352
|
||||
Control14=IDC_STATIC,static,1342308352
|
||||
Control15=IDC_LIST_ATTACHMENTS,listbox,1352728833
|
||||
Control16=IDC_BUTTON_ADDATTACHMENT,button,1342242816
|
||||
Control17=IDC_BUTTON_REMOVEATTACHMENT,button,1342242816
|
||||
|
||||
@ -0,0 +1,83 @@
|
||||
// MailSend.cpp : Defines the class behaviors for the application.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "MailSend.h"
|
||||
#include "MailSendDlg.h"
|
||||
#include "MailEngine.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMailSendApp construction
|
||||
|
||||
CMailSendApp::CMailSendApp()
|
||||
{
|
||||
// TODO: add construction code here,
|
||||
// Place all significant initialization in InitInstance
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// The one and only CMailSendApp object
|
||||
CMailSendApp theApp;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMailSendApp initialization
|
||||
|
||||
BOOL CMailSendApp::InitInstance()
|
||||
{
|
||||
// Initialize OLE libraries
|
||||
if (!AfxOleInit())
|
||||
{
|
||||
AfxMessageBox(IDP_OLE_INIT_FAILED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Standard initialization
|
||||
// If you are not using these features and wish to reduce the size
|
||||
// of your final executable, you should remove from the following
|
||||
// the specific initialization routines you do not need.
|
||||
|
||||
#ifdef _AFXDLL
|
||||
Enable3dControls(); // Call this when using MFC in a shared DLL
|
||||
#else
|
||||
Enable3dControlsStatic(); // Call this when linking to MFC statically
|
||||
#endif
|
||||
|
||||
// Register all OLE server (factories) as running. This enables the
|
||||
// OLE libraries to create objects from other applications.
|
||||
COleTemplateServer::RegisterAll();
|
||||
|
||||
theMailEngine.Initialize();
|
||||
|
||||
// Parse the command line to see if launched as OLE server
|
||||
if (RunEmbedded() || RunAutomated())
|
||||
{
|
||||
// Application was run with /Embedding or /Automation. Don't show the
|
||||
// main window in this case.
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// When a server application is launched stand-alone, it is a good idea
|
||||
// to update the system registry in case it has been damaged.
|
||||
COleObjectFactory::UpdateRegistryAll();
|
||||
|
||||
CMailSendDlg dlg;
|
||||
m_pMainWnd = &dlg;
|
||||
dlg.DoModal();
|
||||
|
||||
// Since the dialog has been closed, return FALSE so that we exit the
|
||||
// application, rather than start the application's message pump.
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int CMailSendApp::ExitInstance()
|
||||
{
|
||||
theMailEngine.Terminate();
|
||||
|
||||
return CWinApp::ExitInstance();
|
||||
}
|
||||
@ -0,0 +1,337 @@
|
||||
# Microsoft Developer Studio Project File - Name="MailSend" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=MailSend - Win32 Unicode_Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "MailSend.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "MailSend.mak" CFG="MailSend - Win32 Unicode_Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "MailSend - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "MailSend - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "MailSend - Win32 Release_Shared" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "MailSend - Win32 Unicode_Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "MailSend - Win32 Unicode_Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "MailSend - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 6
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\Release"
|
||||
# PROP BASE Intermediate_Dir ".\Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 5
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
|
||||
# ADD CPP /nologo /MT /W4 /GX /O2 /I "..\..\include" /I "..\..\..\Include" /I "..\..\..\Source\UTSampleAbout" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "NOT_REGISTERED" /Yu"stdafx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x813 /d "NDEBUG" /d "_AFXDLL"
|
||||
# ADD RSC /l 0x813 /i "..\..\..\Include" /i "..\..\..\Source\UTSampleAbout" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 mapi32.lib /nologo /subsystem:windows /machine:I386 /out:"MailSend.exe"
|
||||
|
||||
!ELSEIF "$(CFG)" == "MailSend - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 6
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\Debug"
|
||||
# PROP BASE Intermediate_Dir ".\Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 5
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\Debug"
|
||||
# PROP Intermediate_Dir ".\Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\include" /I "..\..\..\Include" /I "..\..\..\Source\UTSampleAbout" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "NOT_REGISTERED" /Yu"stdafx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x813 /d "_DEBUG" /d "_AFXDLL"
|
||||
# ADD RSC /l 0x813 /i "..\..\..\Include" /i "..\..\..\Source\UTSampleAbout" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386
|
||||
# ADD LINK32 mapi32.lib /nologo /subsystem:windows /debug /machine:I386 /out:"MailSend.exe"
|
||||
|
||||
!ELSEIF "$(CFG)" == "MailSend - Win32 Release_Shared"
|
||||
|
||||
# PROP BASE Use_MFC 5
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "MailSend"
|
||||
# PROP BASE Intermediate_Dir "MailSend"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 6
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release_Shared"
|
||||
# PROP Intermediate_Dir "Release_Shared"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W4 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "NOT_REGISTERED" /Yu"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /GX /O2 /I "..\..\include" /I "..\..\..\Include" /I "..\..\..\Source\UTSampleAbout" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "NOT_REGISTERED" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x813 /d "NDEBUG"
|
||||
# ADD RSC /l 0x813 /i "..\..\..\Include" /i "..\..\..\Source\UTSampleAbout" /d "NDEBUG" /d "_AFXDLL"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 mapi32.lib /nologo /subsystem:windows /machine:I386 /out:"MailSend.exe"
|
||||
# ADD LINK32 mapi32.lib /nologo /subsystem:windows /machine:I386 /out:"MailSend.exe"
|
||||
|
||||
!ELSEIF "$(CFG)" == "MailSend - Win32 Unicode_Debug"
|
||||
|
||||
# PROP BASE Use_MFC 6
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "MailSen0"
|
||||
# PROP BASE Intermediate_Dir "MailSen0"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 6
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Unicode_Debug"
|
||||
# PROP Intermediate_Dir "Unicode_Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\Include" /I "..\..\..\Source\UTSampleAbout" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /D "NOT_REGISTERED" /Yu"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /I "..\..\..\Include" /I "..\..\..\Source\UTSampleAbout" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /D "NOT_REGISTERED" /D "_UNICODE" /Yu"stdafx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x813 /i "..\..\..\Include" /i "..\..\..\Source\UTSampleAbout" /d "_DEBUG" /d "_AFXDLL"
|
||||
# ADD RSC /l 0x813 /i "..\..\..\Include" /i "..\..\..\Source\UTSampleAbout" /d "_DEBUG" /d "_AFXDLL"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 mapi32.lib /nologo /subsystem:windows /debug /machine:I386 /out:"MailSend.exe"
|
||||
# ADD LINK32 mapi32.lib /nologo /entry:"wWinMainCRTStartup" /subsystem:windows /debug /machine:I386 /out:"MailSend.exe"
|
||||
|
||||
!ELSEIF "$(CFG)" == "MailSend - Win32 Unicode_Release"
|
||||
|
||||
# PROP BASE Use_MFC 5
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "MailSen1"
|
||||
# PROP BASE Intermediate_Dir "MailSen1"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 5
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Unicode_Release"
|
||||
# PROP Intermediate_Dir "Unicode_Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W4 /GX /O2 /I "..\..\..\Include" /I "..\..\..\Source\UTSampleAbout" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "NOT_REGISTERED" /Yu"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /MT /W4 /GX /O2 /I "..\..\include" /I "..\..\..\Include" /I "..\..\..\Source\UTSampleAbout" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "NOT_REGISTERED" /D "_UNICODE" /Yu"stdafx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x813 /i "..\..\..\Include" /i "..\..\..\Source\UTSampleAbout" /d "NDEBUG"
|
||||
# ADD RSC /l 0x813 /i "..\..\..\Include" /i "..\..\..\Source\UTSampleAbout" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 mapi32.lib /nologo /subsystem:windows /machine:I386 /out:"MailSend.exe"
|
||||
# ADD LINK32 mapi32.lib /nologo /entry:"wWinMainCRTStartup" /subsystem:windows /machine:I386 /out:"MailSend.exe"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "MailSend - Win32 Release"
|
||||
# Name "MailSend - Win32 Debug"
|
||||
# Name "MailSend - Win32 Release_Shared"
|
||||
# Name "MailSend - Win32 Unicode_Debug"
|
||||
# Name "MailSend - Win32 Unicode_Release"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
|
||||
# Begin Group "UTSource"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\source\OXDispatchMarshaller.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\source\OXFinalReleaseWnd.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\source\oxmdisp.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\source\OXOwnThread.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\source\OXOwnThreadCmdTarget.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\source\OXSendMail.CPP
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\source\OXThreadEngine.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Source\Xstring.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CgiHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cgitooledrv.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MailEngine.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MailMessage.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MailSend.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MailSend.odl
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MailSend.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MailSendDlg.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ReadMe.txt
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
# ADD CPP /Yc"stdafx.h"
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CgiHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CgiToOleDrv.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MailCmd.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MailEngine.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MailMessage.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MailSend.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MailSendDlg.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Include\OXDispatchMarshaller.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Include\OXFinalReleaseWnd.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Include\oxmdisp.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Include\OXOwnThread.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Include\OXOwnThreadCmdTarget.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Include\OXSendMail.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Include\OXThreadEngine.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\XString.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\res\MailSend.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\res\MailSend.rc2
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "MailSend"=".\MailSend.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
// MailSend.h : main header file for the MAILSEND application
|
||||
//
|
||||
|
||||
#ifndef __AFXWIN_H__
|
||||
#error include 'stdafx.h' before including this file for PCH
|
||||
#endif
|
||||
|
||||
#include "resource.h" // main symbols
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMailSendApp:
|
||||
// See MailSend.cpp for the implementation of this class
|
||||
//
|
||||
|
||||
class CMailSendApp : public CWinApp
|
||||
{
|
||||
public:
|
||||
CMailSendApp();
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CMailSendApp)
|
||||
public:
|
||||
virtual BOOL InitInstance();
|
||||
virtual int ExitInstance();
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
|
||||
//{{AFX_MSG(CMailSendApp)
|
||||
// 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()
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@ -0,0 +1,108 @@
|
||||
// MailSend.odl : type library source for MailSend.exe
|
||||
|
||||
// This file will be processed by the Make Type Library (mktyplib) tool to
|
||||
// produce the type library (MailSend.tlb).
|
||||
|
||||
[ uuid(48452B61-D40F-11CF-AA2E-00AA00489A36), version(1.0) ]
|
||||
library MailSend
|
||||
{
|
||||
importlib("stdole32.tlb");
|
||||
|
||||
|
||||
// Primary dispatch interface for CMail
|
||||
|
||||
[ uuid(48452B66-D40F-11CF-AA2E-00AA00489A36) ]
|
||||
dispinterface IMail
|
||||
{
|
||||
properties:
|
||||
// NOTE - ClassWizard will maintain property information here.
|
||||
// Use extreme caution when editing this section.
|
||||
//{{AFX_ODL_PROP(CMail)
|
||||
//}}AFX_ODL_PROP
|
||||
|
||||
methods:
|
||||
// NOTE - ClassWizard will maintain method information here.
|
||||
// Use extreme caution when editing this section.
|
||||
//{{AFX_ODL_METHOD(CMail)
|
||||
//}}AFX_ODL_METHOD
|
||||
|
||||
};
|
||||
|
||||
// Class information for CMail
|
||||
|
||||
[ uuid(48452B67-D40F-11CF-AA2E-00AA00489A36) ]
|
||||
coclass MAIL
|
||||
{
|
||||
[default] dispinterface IMail;
|
||||
};
|
||||
|
||||
// Primary dispatch interface for CMailMessage
|
||||
|
||||
[ uuid(48452B86-D40F-11CF-AA2E-00AA00489A36) ]
|
||||
dispinterface IMailMessage
|
||||
{
|
||||
properties:
|
||||
// NOTE - ClassWizard will maintain property information here.
|
||||
// Use extreme caution when editing this section.
|
||||
//{{AFX_ODL_PROP(CMailMessage)
|
||||
[id(1)] BSTR Subject;
|
||||
[id(2)] BSTR Content;
|
||||
[id(3)] short AttachmentCount;
|
||||
[id(4)] short LastError;
|
||||
[id(5)] BSTR To;
|
||||
[id(6)] BSTR Profile;
|
||||
[id(7)] BSTR Password;
|
||||
//}}AFX_ODL_PROP
|
||||
|
||||
methods:
|
||||
// NOTE - ClassWizard will maintain method information here.
|
||||
// Use extreme caution when editing this section.
|
||||
//{{AFX_ODL_METHOD(CMailMessage)
|
||||
[id(8)] boolean AddAttachment(BSTR sFilePath);
|
||||
[id(9)] BSTR GetAttachment(short nIndex);
|
||||
[id(10)] boolean RemoveAttachment(short nIndex);
|
||||
[id(11)] boolean Send();
|
||||
//}}AFX_ODL_METHOD
|
||||
|
||||
};
|
||||
|
||||
// Class information for CMailMessage
|
||||
|
||||
[ uuid(48452B87-D40F-11CF-AA2E-00AA00489A36) ]
|
||||
coclass CMailMessage
|
||||
{
|
||||
[default] dispinterface IMailMessage;
|
||||
};
|
||||
|
||||
// Primary dispatch interface for CCgiHandler
|
||||
|
||||
[ uuid(48452B96-D40F-11CF-AA2E-00AA00489A36) ]
|
||||
dispinterface ICgiHandler
|
||||
{
|
||||
properties:
|
||||
// NOTE - ClassWizard will maintain property information here.
|
||||
// Use extreme caution when editing this section.
|
||||
//{{AFX_ODL_PROP(CCgiHandler)
|
||||
//}}AFX_ODL_PROP
|
||||
|
||||
methods:
|
||||
// NOTE - ClassWizard will maintain method information here.
|
||||
// Use extreme caution when editing this section.
|
||||
//{{AFX_ODL_METHOD(CCgiHandler)
|
||||
[id(1)] void OnGet(IDispatch* pCgiObj, BSTR sCommand);
|
||||
[id(2)] void OnPost(IDispatch* pCgiObj, BSTR sInputType, BSTR sInputBuffer);
|
||||
//}}AFX_ODL_METHOD
|
||||
|
||||
};
|
||||
|
||||
// Class information for CCgiHandler
|
||||
|
||||
[ uuid(48452B97-D40F-11CF-AA2E-00AA00489A36) ]
|
||||
coclass CCgiHandler
|
||||
{
|
||||
[default] dispinterface ICgiHandler;
|
||||
}
|
||||
|
||||
|
||||
//{{AFX_APPEND_ODL}}
|
||||
};
|
||||
@ -0,0 +1,269 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 253, 214
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "About SendMail"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
ICON IDR_MAINFRAME,IDC_STATIC,13,18,20,20
|
||||
LTEXT "SendMail Version 1.0",IDC_STATIC,40,10,119,8,
|
||||
SS_NOPREFIX
|
||||
LTEXT "Copyright © The Code Project 1997",IDC_STATIC,40,25,119,
|
||||
8
|
||||
DEFPUSHBUTTON "OK",IDOK,214,7,32,14,WS_GROUP
|
||||
LTEXT "This application is an OLE server which offers a Message object that you can call (even from within NT services) to send a mail message via a MAPI compliant system.\nMessage OLE object: (OXSENDMAIL.MESSAGE)",
|
||||
IDC_STATIC,37,45,189,34
|
||||
LTEXT "Properties:\n\tFrom \t\t\tstring\n\tTo\t\t\tstring\n\tSubject\t\t\tstring\n\tContent\t\t\tstring\n\tAttachmentCount\tinteger\n\tLastError\t\tlong",
|
||||
IDC_STATIC,37,81,171,57
|
||||
LTEXT "Methods:\n\tBOOL AddAttachment ( path ) path is string\n\tstring GetAttachment ( index ) index is integer\n\tRemoveAttachment ( index )\n\tBOOL Send ()",
|
||||
IDC_STATIC,37,138,188,43
|
||||
LTEXT "ALSO ACCESSIBLE WITH CGI AND ISAPI\nCheck the Readme.txt file.",
|
||||
IDC_STATIC,37,185,189,19
|
||||
END
|
||||
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,1
|
||||
PRODUCTVERSION 1,0,0,1
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904B0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "\0"
|
||||
VALUE "FileDescription", "MAILSEND MFC Application\0"
|
||||
VALUE "FileVersion", "1, 0, 0, 1\0"
|
||||
VALUE "InternalName", "MAILSEND\0"
|
||||
VALUE "LegalCopyright", "Copyright © 1996\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename", "MAILSEND.EXE\0"
|
||||
VALUE "ProductName", "MAILSEND Application\0"
|
||||
VALUE "ProductVersion", "1, 0, 0, 1\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // !_MAC
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_ABOUTBOX, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 246
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 207
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDP_OLE_INIT_FAILED "OLE initialization failed. Make sure that the OLE libraries are the correct version."
|
||||
IDS_ABOUTBOX "&About MailSend..."
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Dutch (Belgium) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NLB)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_DUTCH, SUBLANG_DUTCH_BELGIAN
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
|
||||
"#define _AFX_NO_OLE_RESOURCES\r\n"
|
||||
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
|
||||
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
|
||||
"\r\n"
|
||||
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
|
||||
"#ifdef _WIN32\r\n"
|
||||
"LANGUAGE 9, 1\r\n"
|
||||
"#pragma code_page(1252)\r\n"
|
||||
"#endif\r\n"
|
||||
"#include ""res\\MailSend.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
|
||||
"#include ""afxres.rc"" // Standard components\r\n"
|
||||
"#endif\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDR_MAINFRAME ICON DISCARDABLE "res\\MailSend.ico"
|
||||
#endif // Dutch (Belgium) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (Canada) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENC)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_CAN
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_MAILSEND_DIALOG DIALOG DISCARDABLE 0, 0, 214, 252
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "MailSend sample"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
EDITTEXT IDC_PROFILE,57,7,150,12,ES_AUTOHSCROLL
|
||||
EDITTEXT IDC_PASSWORD,57,24,150,12,ES_AUTOHSCROLL
|
||||
EDITTEXT IDC_ADDRESS,57,49,150,12,ES_AUTOHSCROLL
|
||||
EDITTEXT IDC_SUBJECT,57,65,150,12,ES_AUTOHSCROLL
|
||||
EDITTEXT IDC_CONTENT,57,82,150,39,ES_MULTILINE | WS_VSCROLL
|
||||
PUSHBUTTON "Send message",IDC_SEND_MAIL,7,228,57,17
|
||||
PUSHBUTTON "About...",IDC_ABOUT,78,228,57,17
|
||||
PUSHBUTTON "Close",IDCANCEL,149,228,57,17
|
||||
LTEXT "Profile Name: ",IDC_STATIC,7,9,45,8
|
||||
LTEXT "Password: ",IDC_STATIC,7,26,36,8
|
||||
LTEXT "Address: ",IDC_STATIC,8,51,30,8
|
||||
LTEXT "Subject: ",IDC_STATIC,7,67,30,8
|
||||
LTEXT "Attachment: ",IDC_STATIC,7,130,41,8
|
||||
LTEXT "Content: ",IDC_STATIC,7,84,30,8
|
||||
LISTBOX IDC_LIST_ATTACHMENTS,56,131,151,87,LBS_NOINTEGRALHEIGHT |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "Add",IDC_BUTTON_ADDATTACHMENT,7,145,37,15
|
||||
PUSHBUTTON "Remove",IDC_BUTTON_REMOVEATTACHMENT,7,167,37,15
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_MAILSEND_DIALOG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 207
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 245
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // English (Canada) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
#define _AFX_NO_SPLITTER_RESOURCES
|
||||
#define _AFX_NO_OLE_RESOURCES
|
||||
#define _AFX_NO_TRACKER_RESOURCES
|
||||
#define _AFX_NO_PROPERTY_RESOURCES
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE 9, 1
|
||||
#pragma code_page(1252)
|
||||
#endif
|
||||
#include "res\MailSend.rc2" // non-Microsoft Visual C++ edited resources
|
||||
#include "afxres.rc" // Standard components
|
||||
#endif
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@ -0,0 +1,255 @@
|
||||
// MailSendDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "MailSend.h"
|
||||
#include "MailSendDlg.h"
|
||||
#include "MailEngine.h"
|
||||
|
||||
#include "oxmdisp.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CAboutDlg dialog used for App About
|
||||
|
||||
class CAboutDlg : public CDialog
|
||||
{
|
||||
public:
|
||||
CAboutDlg();
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CAboutDlg)
|
||||
enum { IDD = IDD_ABOUTBOX };
|
||||
//}}AFX_DATA
|
||||
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CAboutDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
//{{AFX_MSG(CAboutDlg)
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CAboutDlg)
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CAboutDlg)
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CAboutDlg)
|
||||
// No message handlers
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMailSendApp
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMailSendApp, CWinApp)
|
||||
//{{AFX_MSG_MAP(CMailSendApp)
|
||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code!
|
||||
//}}AFX_MSG
|
||||
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMailSendDlg dialog
|
||||
|
||||
CMailSendDlg::CMailSendDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CMailSendDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CMailSendDlg)
|
||||
m_sAddress = _T("");
|
||||
m_sContent = _T("");
|
||||
m_sPassword = _T("");
|
||||
m_sProfile = _T("");
|
||||
m_sSubject = _T("");
|
||||
//}}AFX_DATA_INIT
|
||||
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
|
||||
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
||||
}
|
||||
|
||||
void CMailSendDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CMailSendDlg)
|
||||
DDX_Control(pDX, IDC_LIST_ATTACHMENTS, m_lbAttachments);
|
||||
DDX_Text(pDX, IDC_ADDRESS, m_sAddress);
|
||||
DDX_Text(pDX, IDC_CONTENT, m_sContent);
|
||||
DDX_Text(pDX, IDC_PASSWORD, m_sPassword);
|
||||
DDX_Text(pDX, IDC_PROFILE, m_sProfile);
|
||||
DDX_Text(pDX, IDC_SUBJECT, m_sSubject);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMailSendDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CMailSendDlg)
|
||||
ON_WM_SYSCOMMAND()
|
||||
ON_WM_PAINT()
|
||||
ON_WM_QUERYDRAGICON()
|
||||
ON_BN_CLICKED(IDC_SEND_MAIL, OnSendMail)
|
||||
ON_BN_CLICKED(IDC_ABOUT, OnAbout)
|
||||
ON_BN_CLICKED(IDC_BUTTON_ADDATTACHMENT, OnButtonAddattachment)
|
||||
ON_BN_CLICKED(IDC_BUTTON_REMOVEATTACHMENT, OnButtonRemoveattachment)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMailSendDlg message handlers
|
||||
|
||||
BOOL CMailSendDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
// Add "About..." menu item to system menu.
|
||||
|
||||
// IDM_ABOUTBOX must be in the system command range.
|
||||
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
|
||||
ASSERT(IDM_ABOUTBOX < 0xF000);
|
||||
|
||||
CMenu* pSysMenu = GetSystemMenu(FALSE);
|
||||
CString strAboutMenu;
|
||||
strAboutMenu.LoadString(IDS_ABOUTBOX);
|
||||
if (!strAboutMenu.IsEmpty())
|
||||
{
|
||||
pSysMenu->AppendMenu(MF_SEPARATOR);
|
||||
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
|
||||
}
|
||||
|
||||
// Set the icon for this dialog. The framework does this automatically
|
||||
// when the application's main window is not a dialog
|
||||
SetIcon(m_hIcon, TRUE); // Set big icon
|
||||
SetIcon(m_hIcon, FALSE); // Set small icon
|
||||
|
||||
// TODO: Add extra initialization here
|
||||
m_sProfile=_T("Microsoft Outlook");
|
||||
m_sAddress=_T("info@theUltimateToolBox.com");
|
||||
m_sSubject=_T("Test Mail Send");
|
||||
m_sContent=_T("This is a message sent to check the MailSend sample functionality");
|
||||
|
||||
UpdateData(FALSE);
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
}
|
||||
|
||||
void CMailSendDlg::OnSysCommand(UINT nID, LPARAM lParam)
|
||||
{
|
||||
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
|
||||
{
|
||||
CAboutDlg dlgAbout;
|
||||
dlgAbout.DoModal();
|
||||
}
|
||||
else
|
||||
{
|
||||
CDialog::OnSysCommand(nID, lParam);
|
||||
}
|
||||
}
|
||||
|
||||
// If you add a minimize button to your dialog, you will need the code below
|
||||
// to draw the icon. For MFC applications using the document/view model,
|
||||
// this is automatically done for you by the framework.
|
||||
|
||||
void CMailSendDlg::OnPaint()
|
||||
{
|
||||
if (IsIconic())
|
||||
{
|
||||
CPaintDC dc(this); // device context for painting
|
||||
|
||||
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
|
||||
|
||||
// Center icon in client rectangle
|
||||
int cxIcon = GetSystemMetrics(SM_CXICON);
|
||||
int cyIcon = GetSystemMetrics(SM_CYICON);
|
||||
CRect rect;
|
||||
GetClientRect(&rect);
|
||||
int x = (rect.Width() - cxIcon + 1) / 2;
|
||||
int y = (rect.Height() - cyIcon + 1) / 2;
|
||||
|
||||
// Draw the icon
|
||||
dc.DrawIcon(x, y, m_hIcon);
|
||||
}
|
||||
else
|
||||
{
|
||||
CDialog::OnPaint();
|
||||
}
|
||||
}
|
||||
|
||||
// The system calls this to obtain the cursor to display while the user drags
|
||||
// the minimized window.
|
||||
HCURSOR CMailSendDlg::OnQueryDragIcon()
|
||||
{
|
||||
return (HCURSOR) m_hIcon;
|
||||
}
|
||||
|
||||
void CMailSendDlg::OnSendMail()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
|
||||
UpdateData();
|
||||
|
||||
CStringArray sAttachments;
|
||||
for(int nIndex=0; nIndex<m_lbAttachments.GetCount(); nIndex++)
|
||||
{
|
||||
CString sAttachment;
|
||||
m_lbAttachments.GetText(nIndex,sAttachment);
|
||||
sAttachments.Add(sAttachment);
|
||||
}
|
||||
|
||||
BOOL bResult=theMailEngine.Send(m_sProfile,m_sPassword,
|
||||
m_sAddress,m_sSubject,m_sContent,sAttachments);
|
||||
|
||||
if(bResult)
|
||||
AfxMessageBox(_T("Message was successfully sent"));
|
||||
else
|
||||
AfxMessageBox(_T("Failed to send a message"));
|
||||
}
|
||||
|
||||
void CMailSendDlg::OnAbout()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
|
||||
CAboutDlg dlgAbout;
|
||||
dlgAbout.DoModal();
|
||||
}
|
||||
|
||||
void CMailSendDlg::OnButtonAddattachment()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
|
||||
// Ask the user to select a directory
|
||||
CFileDialog fileDlg(TRUE);
|
||||
if (fileDlg.DoModal()==IDOK)
|
||||
{
|
||||
CString sAttachment=fileDlg.GetPathName();
|
||||
m_lbAttachments.AddString(sAttachment);
|
||||
UpdateData(FALSE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CMailSendDlg::OnButtonRemoveattachment()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
int nSelItem=m_lbAttachments.GetCurSel();
|
||||
if(nSelItem!=LB_ERR)
|
||||
m_lbAttachments.DeleteString(nSelItem);
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
// MailSendDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMailSendDlg dialog
|
||||
|
||||
class CMailSendDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CMailSendDlg(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CMailSendDlg)
|
||||
enum { IDD = IDD_MAILSEND_DIALOG };
|
||||
CListBox m_lbAttachments;
|
||||
CString m_sAddress;
|
||||
CString m_sContent;
|
||||
CString m_sPassword;
|
||||
CString m_sProfile;
|
||||
CString m_sSubject;
|
||||
//}}AFX_DATA
|
||||
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CMailSendDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
HICON m_hIcon;
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CMailSendDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
|
||||
afx_msg void OnPaint();
|
||||
afx_msg HCURSOR OnQueryDragIcon();
|
||||
afx_msg void OnSendMail();
|
||||
afx_msg void OnAbout();
|
||||
afx_msg void OnButtonAddattachment();
|
||||
afx_msg void OnButtonRemoveattachment();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
@ -0,0 +1,63 @@
|
||||
This sample application is part of the Ultimate Toolbox library.
|
||||
In the first place it serves as a demonstration of how to implement some of the classes in our library.
|
||||
Classes:
|
||||
+ COXSendMail
|
||||
+ COXMapi framework (14 classes)
|
||||
+ COXThreadEngine
|
||||
+ COXOwnThreadCmdTarget
|
||||
(for documentation on these classes, check the manual or our website: www.dundas.com)
|
||||
|
||||
This application is an OLE automation server which implement two OLE objects:
|
||||
+ OXSENDMAIL.MESSAGE
|
||||
+ OXSENDMAIL.CGIHANDLER
|
||||
|
||||
It allows you to send a mail message via a MAPI compliant mail system (even from within NT services).
|
||||
|
||||
Dispatch interface of the OXSENDMAIL.MESSAGE object
|
||||
Properties:
|
||||
From string
|
||||
To string
|
||||
Subject string
|
||||
Content string
|
||||
AttachmentCount integer
|
||||
LastError long
|
||||
|
||||
Methods:
|
||||
BOOL AddAttachment ( path ) path is string
|
||||
string GetAttachment ( index ) index is integer
|
||||
RemoveAttachment ( index )
|
||||
BOOL Send ()
|
||||
|
||||
Visual Basic sample of the implementation of this ole object:
|
||||
|
||||
Dim msg As Object
|
||||
Dim bResult As Boolean
|
||||
|
||||
Set msg = CreateObject("OXSENDMAIL.MESSAGE")
|
||||
msg.Profile = "John"
|
||||
msg.Password = ""
|
||||
msg.To = "John Doe"
|
||||
msg.Subject = "Test"
|
||||
msg.Content = "This is the content body"
|
||||
bResult = msg.AddAttachment("c:\test.bmp")
|
||||
bResult = msg.Send()
|
||||
|
||||
|
||||
HTML interface via the CgiToOle.exe or IsapiOle.dll utility:
|
||||
|
||||
<FORM METHOD="POST" ACTION="CGI/CgiToOle.exe/OXSENDMAIL.CGIHANDLER">
|
||||
<INPUT NAME="Profile" TYPE="HIDDEN" VALUE="John" ALIGN=left>
|
||||
<INPUT NAME="To" TYPE="HIDDEN" VALUE="John Doe" ALIGN=left>
|
||||
<INPUT NAME="Subject" TYPE="HIDDEN" VALUE="Test" ALIGN=left>
|
||||
<INPUT NAME="Content" TYPE="HIDDEN" VALUE="This is the content body" ALIGN=left>
|
||||
<INPUT NAME="AttCount" TYPE="HIDDEN" VALUE="1" ALIGN=left>
|
||||
<INPUT NAME="Attachment" TYPE="HIDDEN" VALUE="C:\test.bmp" ALIGN=left>
|
||||
<INPUT TYPE="SUBMIT" VALUE="OXSendMail">
|
||||
</FORM>
|
||||
|
||||
|
||||
Info:
|
||||
|
||||
HTTP: www.theUltimateToolbox.com
|
||||
|
||||
|
||||
@ -0,0 +1,606 @@
|
||||
// ==========================================================================
|
||||
// Class Implementation : CSendMail
|
||||
// ==========================================================================
|
||||
|
||||
// Source file : SendMail.cpp
|
||||
|
||||
//----------------- Dundas Software ----------------------------------------
|
||||
//========================================================================
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "stdafx.h" // standard MFC include
|
||||
#include "SendMail.h"
|
||||
|
||||
#pragma warning(disable: 4228)
|
||||
#include <mapi.h>
|
||||
#include <mapix.h>
|
||||
#include <mapiwin.h>
|
||||
#include <mapiutil.h>
|
||||
|
||||
#define USES_IID_IMAPIFolder
|
||||
#define INITGUID
|
||||
#include <initguid.h>
|
||||
#include <mapiguid.h>
|
||||
#pragma warning(default: 4228)
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
#define _countof(array) (sizeof(array)/sizeof(array[0]))
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// MAPI implementation helpers and globals
|
||||
|
||||
static BOOL IsMailAvail = (BOOL)-1; // start out not determined
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// _AFX_MAIL_STATE
|
||||
|
||||
class _AFX_MAIL_STATE : public CNoTrackObject
|
||||
{
|
||||
public:
|
||||
HINSTANCE m_hInstMail; // handle to MAPI32.DLL
|
||||
virtual ~_AFX_MAIL_STATE();
|
||||
};
|
||||
|
||||
_AFX_MAIL_STATE::~_AFX_MAIL_STATE()
|
||||
{
|
||||
if (m_hInstMail != NULL)
|
||||
::FreeLibrary(m_hInstMail);
|
||||
}
|
||||
|
||||
_AFX_MAIL_STATE* _afxMailState;
|
||||
int nCount = 0;
|
||||
|
||||
CSendMail::CSendMail() :
|
||||
m_pMAPISession(NULL),
|
||||
m_pAddressBook(NULL),
|
||||
m_peidDefaultMDB(NULL),
|
||||
m_cbeidDefaultMDB(0),
|
||||
m_pDefaultMDB(NULL),
|
||||
m_pRootFolder(NULL),
|
||||
m_szRecipient(NULL),
|
||||
m_uLogoffFlags(LOGOFF_ORDERLY),
|
||||
m_szAttachData(NULL)
|
||||
{
|
||||
if (nCount==0)
|
||||
_afxMailState = new _AFX_MAIL_STATE;
|
||||
nCount++;
|
||||
}
|
||||
|
||||
|
||||
CSendMail::~CSendMail()
|
||||
{
|
||||
nCount--;
|
||||
if (nCount==0)
|
||||
delete _afxMailState;
|
||||
}
|
||||
|
||||
|
||||
CString CSendMail::GetReturnMsg(int nErr)
|
||||
{
|
||||
CString sErrorMsg;
|
||||
switch(nErr)
|
||||
{
|
||||
case SUCCESS_SUCCESS:
|
||||
sErrorMsg = _T("Sending of Mail was succesful");
|
||||
break;
|
||||
case MAPI_E_USER_ABORT:
|
||||
sErrorMsg = _T("Sending of Mail has been aborted by user");
|
||||
break;
|
||||
case MAPI_E_FAILURE:
|
||||
sErrorMsg = _T("Sending of Mail was not succesful");
|
||||
break;
|
||||
case MAPI_E_LOGIN_FAILURE:
|
||||
sErrorMsg = _T("login failure");
|
||||
break;
|
||||
case MAPI_E_DISK_FULL:
|
||||
sErrorMsg = _T("Disk full");
|
||||
break;
|
||||
case MAPI_E_INSUFFICIENT_MEMORY:
|
||||
sErrorMsg = _T("not enough memory");
|
||||
break;
|
||||
case MAPI_E_ACCESS_DENIED:
|
||||
sErrorMsg = _T("access denied");
|
||||
break;
|
||||
case MAPI_E_TOO_MANY_SESSIONS:
|
||||
sErrorMsg = _T("too many sessions open");
|
||||
break;
|
||||
case MAPI_E_TOO_MANY_FILES:
|
||||
sErrorMsg = _T("too many open files");
|
||||
break;
|
||||
case MAPI_E_TOO_MANY_RECIPIENTS:
|
||||
sErrorMsg = _T("too many recipients specified");
|
||||
break;
|
||||
case MAPI_E_ATTACHMENT_NOT_FOUND:
|
||||
sErrorMsg = _T("attachment not found");
|
||||
break;
|
||||
case MAPI_E_ATTACHMENT_OPEN_FAILURE:
|
||||
sErrorMsg = _T("could not open attachment");
|
||||
break;
|
||||
case MAPI_E_ATTACHMENT_WRITE_FAILURE:
|
||||
sErrorMsg = _T("could not write attachment");
|
||||
break;
|
||||
case MAPI_E_UNKNOWN_RECIPIENT:
|
||||
sErrorMsg = _T("unknown recipient");
|
||||
break;
|
||||
case MAPI_E_BAD_RECIPTYPE:
|
||||
sErrorMsg = _T("unknown reciptype");
|
||||
break;
|
||||
case MAPI_E_NO_MESSAGES:
|
||||
sErrorMsg = _T("no messages");
|
||||
break;
|
||||
case MAPI_E_INVALID_MESSAGE:
|
||||
sErrorMsg = _T("invalid message");
|
||||
break;
|
||||
case MAPI_E_TEXT_TOO_LARGE:
|
||||
sErrorMsg = _T("text too large");
|
||||
break;
|
||||
case MAPI_E_INVALID_SESSION:
|
||||
sErrorMsg = _T("invalid session");
|
||||
break;
|
||||
case MAPI_E_TYPE_NOT_SUPPORTED:
|
||||
sErrorMsg = _T("type not supported");
|
||||
break;
|
||||
case MAPI_E_AMBIG_RECIP:
|
||||
sErrorMsg = _T("ambiguous recipiebt");
|
||||
break;
|
||||
case MAPI_E_MESSAGE_IN_USE:
|
||||
sErrorMsg = _T("message in use");
|
||||
break;
|
||||
case MAPI_E_NETWORK_FAILURE:
|
||||
sErrorMsg = _T("network failure");
|
||||
break;
|
||||
case MAPI_E_INVALID_EDITFIELDS:
|
||||
sErrorMsg = _T("invalid editfields");
|
||||
break;
|
||||
case MAPI_E_INVALID_RECIPS:
|
||||
sErrorMsg = _T("invalid recipients");
|
||||
break;
|
||||
case MAPI_E_NOT_SUPPORTED:
|
||||
sErrorMsg = _T("not supported request");
|
||||
break;
|
||||
default:
|
||||
sErrorMsg = _T("unknown error");
|
||||
break;
|
||||
}
|
||||
|
||||
return sErrorMsg;
|
||||
}
|
||||
|
||||
BOOL CSendMail::Initialize(CString sProfileName, CString sPassword)
|
||||
{
|
||||
ASSERT_VALID(this);
|
||||
HRESULT hResult;
|
||||
|
||||
if (IsInitialized())
|
||||
Uninitialize();
|
||||
|
||||
// Initialize the MAPI libraries before calling ANY MAPI function
|
||||
MAPIINIT_0 MAPIINIT = { 0, MAPI_NT_SERVICE | MAPI_MULTITHREAD_NOTIFICATIONS };
|
||||
hResult = MAPIInitialize(&MAPIINIT);
|
||||
if (!FAILED (hResult))
|
||||
{
|
||||
// Logon onto the message subsystem. We are going to ask the user to
|
||||
// select a profile to log into. The UI for this will be provided by MAPI.
|
||||
hResult = MAPILogonEx((ULONG)NULL,
|
||||
sProfileName.GetBuffer(256),
|
||||
sPassword.GetBuffer(256),
|
||||
MAPI_NO_MAIL | MAPI_EXTENDED | MAPI_EXPLICIT_PROFILE /*| MAPI_USE_DEFAULT */| MAPI_NEW_SESSION,
|
||||
&m_pMAPISession);
|
||||
|
||||
sProfileName.ReleaseBuffer();
|
||||
sPassword.ReleaseBuffer();
|
||||
|
||||
if (!FAILED (hResult))
|
||||
{
|
||||
// get the address book
|
||||
// be sure to have the correct address book set as the default
|
||||
// see the Addressing tab in the profile config control panel applet
|
||||
hResult = m_pMAPISession->OpenAddressBook(NULL, NULL, 0, &m_pAddressBook);
|
||||
if (!FAILED(hResult))
|
||||
{
|
||||
if (InitializeMessageStore())
|
||||
{
|
||||
// get the root folder
|
||||
ULONG uObjType;
|
||||
hResult = m_pDefaultMDB->OpenEntry(0,
|
||||
NULL,
|
||||
(LPIID)&IID_IMAPIFolder,
|
||||
MAPI_MODIFY,
|
||||
&uObjType,
|
||||
(LPUNKNOWN *)&m_pRootFolder);
|
||||
|
||||
if (!FAILED(hResult))
|
||||
{
|
||||
m_sMAPIProfile = sProfileName;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Uninitialize();
|
||||
}
|
||||
else
|
||||
MAPIUninitialize();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL CSendMail::IsInitialized() const
|
||||
{
|
||||
return (m_pMAPISession!=NULL);
|
||||
}
|
||||
|
||||
void CSendMail::Uninitialize()
|
||||
{
|
||||
if (m_pRootFolder != NULL)
|
||||
{
|
||||
m_pRootFolder->Release();
|
||||
m_pRootFolder = NULL;
|
||||
}
|
||||
|
||||
if (m_pDefaultMDB != NULL)
|
||||
{
|
||||
m_pDefaultMDB->StoreLogoff(&m_uLogoffFlags);
|
||||
m_pDefaultMDB->Release();
|
||||
m_pDefaultMDB = NULL;
|
||||
}
|
||||
|
||||
if (m_peidDefaultMDB != NULL)
|
||||
{
|
||||
MAPIFreeBuffer(m_peidDefaultMDB);
|
||||
m_peidDefaultMDB = NULL;
|
||||
}
|
||||
|
||||
if (m_pAddressBook != NULL)
|
||||
{
|
||||
m_pAddressBook->Release();
|
||||
m_pAddressBook = NULL;
|
||||
}
|
||||
|
||||
if (m_pMAPISession!=NULL)
|
||||
{
|
||||
ULONG ulUIParam = (ULONG)NULL; // null window handle
|
||||
ULONG ulFlags = 0;
|
||||
ULONG ulReserved = 0;
|
||||
|
||||
m_pMAPISession->Logoff(ulUIParam, ulFlags, ulReserved);
|
||||
m_pMAPISession->Release();
|
||||
m_pMAPISession = NULL;
|
||||
MAPIUninitialize();
|
||||
}
|
||||
}
|
||||
|
||||
CString CSendMail::GetProfile() const
|
||||
{
|
||||
CString sProfile;
|
||||
|
||||
if (IsInitialized())
|
||||
sProfile = m_sMAPIProfile;
|
||||
return sProfile;
|
||||
}
|
||||
|
||||
BOOL CSendMail::InitializeMessageStore()
|
||||
{
|
||||
LPSRowSet pRow = NULL;
|
||||
ULONG ulRow;
|
||||
ULONG uRowCount;
|
||||
HRESULT hResult;
|
||||
LPMAPITABLE pStoresTable;
|
||||
LPSPropValue pProps;
|
||||
BOOL bFound;
|
||||
|
||||
|
||||
// The order for this enumaration must match the order of the properties
|
||||
// in the tag array below
|
||||
enum
|
||||
{
|
||||
DEFAULT_STORE,
|
||||
STORE_EID,
|
||||
MSG_STORES_TABLE_PROPS // number columns in the proptagarray
|
||||
};
|
||||
|
||||
SizedSPropTagArray (MSG_STORES_TABLE_PROPS, sptMsgStores) =
|
||||
{
|
||||
MSG_STORES_TABLE_PROPS,
|
||||
{
|
||||
PR_DEFAULT_STORE,
|
||||
PR_ENTRYID,
|
||||
}
|
||||
};
|
||||
|
||||
///// end of local declarations
|
||||
|
||||
m_cbeidDefaultMDB = 0;
|
||||
m_peidDefaultMDB = NULL;
|
||||
|
||||
|
||||
// first get a table of the message stores available
|
||||
hResult = m_pMAPISession->GetMsgStoresTable (0, &pStoresTable);
|
||||
if (FAILED(hResult))
|
||||
return FALSE;
|
||||
|
||||
|
||||
// we only want the default store flag and the entry id
|
||||
hResult = pStoresTable->SetColumns((LPSPropTagArray)&sptMsgStores, 0);
|
||||
if (FAILED(hResult))
|
||||
return FALSE;
|
||||
|
||||
pStoresTable->GetRowCount(0, &uRowCount); // one row corresponds to one MDB provider
|
||||
// typically no one should have more than
|
||||
// 6 or 7 MDB providers.
|
||||
|
||||
// Get row(s) from the message stores table
|
||||
hResult = pStoresTable->QueryRows(uRowCount, 0, &pRow);
|
||||
if (FAILED(hResult))
|
||||
return FALSE;
|
||||
|
||||
bFound = FALSE;
|
||||
// loop through each row -- each row represents the properties of a message store
|
||||
for (ulRow=0; ulRow<pRow->cRows; ulRow++)
|
||||
{
|
||||
pProps = pRow->aRow[ulRow].lpProps;
|
||||
|
||||
if (pProps[DEFAULT_STORE].Value.b == 1) // we found it!
|
||||
{
|
||||
|
||||
m_cbeidDefaultMDB = pProps[STORE_EID].Value.bin.cb;
|
||||
hResult = MAPIAllocateBuffer(m_cbeidDefaultMDB, (LPVOID *)&m_peidDefaultMDB);
|
||||
if (FAILED(hResult))
|
||||
return FALSE;
|
||||
|
||||
memcpy(m_peidDefaultMDB, pProps[STORE_EID].Value.bin.lpb, m_cbeidDefaultMDB);
|
||||
|
||||
bFound = TRUE;
|
||||
}
|
||||
/// else ignore the non-defaults
|
||||
}
|
||||
|
||||
if (bFound)
|
||||
hResult = S_OK;
|
||||
else
|
||||
hResult = MAPI_E_NOT_FOUND;
|
||||
|
||||
|
||||
|
||||
// clean up if neccessary
|
||||
if (pRow != NULL)
|
||||
FreeProws(pRow);
|
||||
|
||||
if (pStoresTable != NULL)
|
||||
pStoresTable->Release();
|
||||
|
||||
|
||||
if (FAILED(hResult)) // there was an error
|
||||
return FALSE;
|
||||
|
||||
// open the default message store
|
||||
m_pDefaultMDB = NULL;
|
||||
hResult = m_pMAPISession->OpenMsgStore ((ULONG)NULL,
|
||||
m_cbeidDefaultMDB,
|
||||
m_peidDefaultMDB,
|
||||
NULL,
|
||||
MDB_WRITE,
|
||||
&m_pDefaultMDB);
|
||||
if (FAILED(hResult))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CSendMail::SendMapiMail(CString sTo, CString sSubject, CString sDescription, CString sAtt)
|
||||
{
|
||||
LPMESSAGE pMessage;
|
||||
HRESULT hResult;
|
||||
|
||||
pMessage = ComposeMessage(sTo,
|
||||
sSubject,
|
||||
sDescription,
|
||||
sAtt);
|
||||
if (pMessage == NULL)
|
||||
return FALSE;
|
||||
|
||||
hResult = pMessage->SubmitMessage(FORCE_SUBMIT);
|
||||
|
||||
if (pMessage != NULL)
|
||||
pMessage->Release();
|
||||
|
||||
if (FAILED(hResult))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
//*************************************************************
|
||||
|
||||
|
||||
LPMESSAGE CSendMail::ComposeMessage(LPCTSTR szRecipient,
|
||||
LPCTSTR szSubject,
|
||||
LPCTSTR szDescription,
|
||||
LPCTSTR szAtt)
|
||||
{
|
||||
HRESULT hrRet = 0;
|
||||
LPMESSAGE pMessage = NULL;
|
||||
SPropValue pMessageProps[5];
|
||||
LPADRLIST pAddressList = NULL;
|
||||
LPSPropProblemArray pPropProblems;
|
||||
|
||||
// create the message
|
||||
hrRet = m_pRootFolder->CreateMessage(NULL, 0, &pMessage);
|
||||
if (FAILED(hrRet))
|
||||
return NULL;
|
||||
|
||||
// setup the properties
|
||||
pMessageProps[0].ulPropTag = PR_MESSAGE_CLASS;
|
||||
pMessageProps[0].Value.lpszA = "IPM.NOTE";
|
||||
|
||||
pMessageProps[1].ulPropTag = PR_PRIORITY;
|
||||
pMessageProps[1].Value.l = 0;
|
||||
|
||||
pMessageProps[2].ulPropTag = PR_SUBJECT;
|
||||
pMessageProps[2].Value.lpszA = (LPTSTR) szSubject;
|
||||
|
||||
pMessageProps[3].ulPropTag = PR_BODY;
|
||||
pMessageProps[3].Value.lpszA = (LPTSTR) szDescription;
|
||||
|
||||
// set the message submission time
|
||||
SYSTEMTIME tSysTime;
|
||||
FILETIME tSubmitTime;
|
||||
GetSystemTime(&tSysTime);
|
||||
SystemTimeToFileTime(&tSysTime, &tSubmitTime); // convert to file time
|
||||
|
||||
pMessageProps[4].ulPropTag = PR_CLIENT_SUBMIT_TIME;
|
||||
pMessageProps[4].Value.ft = tSubmitTime;
|
||||
|
||||
|
||||
// build the recipients list
|
||||
pAddressList = GetRecipient(szRecipient);
|
||||
if (pAddressList)
|
||||
{
|
||||
// set the properties
|
||||
hrRet = pMessage->SetProps(5, pMessageProps, &pPropProblems);
|
||||
if (!FAILED(hrRet))
|
||||
{
|
||||
// set the recipients to the message
|
||||
hrRet = pMessage->ModifyRecipients(MODRECIP_ADD, pAddressList);
|
||||
if (!FAILED(hrRet))
|
||||
{
|
||||
// Create the attachment
|
||||
AddAttachments(pMessage, szAtt);
|
||||
hrRet = pMessage->SaveChanges(KEEP_OPEN_READWRITE);
|
||||
}
|
||||
}
|
||||
|
||||
// GetRecipient allocates memory pointed to by pAddressList.
|
||||
// use MAPIFreeBuffer to free memory after using it
|
||||
// for modifying the recipients
|
||||
MAPIFreeBuffer(pAddressList);
|
||||
|
||||
if (!FAILED(hrRet))
|
||||
return pMessage;
|
||||
}
|
||||
|
||||
if (pMessage != NULL)
|
||||
pMessage->Release();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
LPADRLIST CSendMail::GetRecipient(LPCTSTR szRecipient)
|
||||
{
|
||||
HRESULT hrRet;
|
||||
LPADRLIST pAddressList;
|
||||
|
||||
// allocate address list for one recipient
|
||||
MAPIAllocateBuffer(sizeof(ADRLIST) + sizeof(ADRENTRY) * 1,
|
||||
(LPVOID *) &pAddressList);
|
||||
// allocate space for properties
|
||||
MAPIAllocateBuffer(sizeof(SPropValue) * 2,
|
||||
(LPVOID *) &(pAddressList->aEntries[0].rgPropVals) );
|
||||
|
||||
// set properties for address list
|
||||
pAddressList->cEntries = 1;
|
||||
pAddressList->aEntries[0].cValues = 2;
|
||||
pAddressList->aEntries[0].rgPropVals[0].ulPropTag = PR_DISPLAY_NAME;
|
||||
pAddressList->aEntries[0].rgPropVals[0].Value.lpszA = (LPTSTR) szRecipient;
|
||||
pAddressList->aEntries[0].rgPropVals[1].ulPropTag = PR_RECIPIENT_TYPE;
|
||||
pAddressList->aEntries[0].rgPropVals[1].Value.l = MAPI_TO;
|
||||
|
||||
|
||||
// resolve the address
|
||||
hrRet = m_pAddressBook->ResolveName(0, 0, NULL, pAddressList);
|
||||
if (FAILED(hrRet))
|
||||
{
|
||||
MAPIFreeBuffer(pAddressList);
|
||||
pAddressList = NULL;
|
||||
}
|
||||
|
||||
return pAddressList;
|
||||
}
|
||||
|
||||
HRESULT CSendMail::AddAttachments(LPMESSAGE pMessage, LPCTSTR szAttachData)
|
||||
{
|
||||
HRESULT hrRet;
|
||||
UINT idx;
|
||||
LPSTR szAttachment;
|
||||
|
||||
// if there are no attachments, just return
|
||||
if (szAttachData == NULL || _tcslen(szAttachData) == 0)
|
||||
return 0;
|
||||
|
||||
enum { REND_POS, PATH_NAME, ATT_METHOD, DISP_NAME, ATT_FILENAME, ATT_DIM};
|
||||
|
||||
SizedSPropTagArray(ATT_DIM , sptAttachTags) =
|
||||
{ ATT_DIM,
|
||||
{ PR_RENDERING_POSITION, PR_ATTACH_PATHNAME,
|
||||
PR_ATTACH_METHOD, PR_DISPLAY_NAME, PR_ATTACH_FILENAME }
|
||||
};
|
||||
SPropValue spvAttachProps[ATT_DIM];
|
||||
|
||||
|
||||
// Count the number of attachments in the AttachmentData
|
||||
CString sAttachment;
|
||||
int nIndex = 0;
|
||||
if (!AfxExtractSubString(sAttachment, szAttachData, nIndex++, _T('|')))
|
||||
return 0;
|
||||
while (!sAttachment.IsEmpty())
|
||||
{
|
||||
|
||||
LPATTACH lpAttach = NULL;
|
||||
ULONG ulAttachNum = 0;
|
||||
szAttachment = sAttachment.GetBuffer(_MAX_PATH);
|
||||
|
||||
hrRet = pMessage->CreateAttach(NULL, 0, &ulAttachNum, &lpAttach);
|
||||
if (FAILED(hrRet))
|
||||
return hrRet;
|
||||
|
||||
for(idx = 0; idx < ATT_DIM; ++idx)
|
||||
{
|
||||
spvAttachProps[idx].ulPropTag = sptAttachTags.aulPropTag[idx];
|
||||
spvAttachProps[idx].dwAlignPad = 0;
|
||||
}
|
||||
|
||||
|
||||
// Split the path of the attachment, so we can extract the filename
|
||||
// to display under the attachment
|
||||
TCHAR pszDrive[_MAX_DRIVE];
|
||||
TCHAR pszSubdir[_MAX_DIR];
|
||||
TCHAR pszBaseName[_MAX_FNAME];
|
||||
TCHAR pszExtender[_MAX_EXT];
|
||||
TCHAR pszFileName[_MAX_FNAME + _MAX_EXT];
|
||||
|
||||
_tsplitpath(szAttachment, pszDrive, pszSubdir, pszBaseName, pszExtender);
|
||||
_tmakepath(pszFileName, NULL, NULL, pszBaseName, pszExtender);
|
||||
|
||||
spvAttachProps[REND_POS].Value.l = -1;
|
||||
spvAttachProps[PATH_NAME].Value.LPSZ = szAttachment;
|
||||
/*
|
||||
ATTACH_BY_REF_RESOLVE means the spooler will resolve the attachment into ATTACH_BY_VALUE
|
||||
and place the attachment data in PR_ATTACH_DATA_BIN
|
||||
*/
|
||||
spvAttachProps[ATT_METHOD].Value.l = ATTACH_BY_REF_RESOLVE;
|
||||
spvAttachProps[DISP_NAME].Value.LPSZ = pszFileName;
|
||||
spvAttachProps[ATT_FILENAME].Value.LPSZ = pszFileName;
|
||||
|
||||
hrRet = lpAttach->SetProps(ATT_DIM, spvAttachProps, NULL);
|
||||
if (FAILED(hrRet))
|
||||
return hrRet;
|
||||
|
||||
hrRet = lpAttach->SaveChanges(KEEP_OPEN_READWRITE);
|
||||
if (FAILED(hrRet))
|
||||
return hrRet;
|
||||
|
||||
sAttachment.ReleaseBuffer();
|
||||
szAttachment = NULL;
|
||||
UlRelease(lpAttach);
|
||||
|
||||
sAttachment.Empty();
|
||||
AfxExtractSubString(sAttachment, szAttachData, nIndex++, _T('|'));
|
||||
}
|
||||
|
||||
return hrRet;
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
// ==========================================================================
|
||||
// Class Specification : CSendMail
|
||||
// ==========================================================================
|
||||
|
||||
// Header file : SendMail.h
|
||||
|
||||
//----------------- Dundas Software ----------------------------------------
|
||||
//========================================================================
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// YES Derived from CObject
|
||||
|
||||
// NO Is a Cwnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
|
||||
// NO Persistent objects (saveable on disk)
|
||||
// NO Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
//
|
||||
//
|
||||
|
||||
// Remark:
|
||||
// ***
|
||||
// Prerequisites (necessary conditions):
|
||||
// ***
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __SENDMAIL_H__
|
||||
#define __SENDMAIL_H__
|
||||
|
||||
#include <mapix.h>
|
||||
|
||||
class CSendMail : public CObject
|
||||
{
|
||||
protected:
|
||||
|
||||
LPMAPISESSION m_pMAPISession;
|
||||
LPADRBOOK m_pAddressBook;
|
||||
LPENTRYID m_peidDefaultMDB;
|
||||
ULONG m_cbeidDefaultMDB;
|
||||
LPMDB m_pDefaultMDB;
|
||||
LPMAPIFOLDER m_pRootFolder;
|
||||
LPSTR m_szRecipient;
|
||||
ULONG m_uLogoffFlags;
|
||||
LPSTR m_szAttachData;
|
||||
CString m_sMAPIProfile;
|
||||
|
||||
public:
|
||||
CSendMail();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Contructor of object
|
||||
// It will initialize the internal state
|
||||
|
||||
~CSendMail();
|
||||
// --- In :
|
||||
// --- Out :
|
||||
// --- Returns :
|
||||
// --- Effect : Destructor of object
|
||||
|
||||
|
||||
BOOL Initialize(CString sProfileName, CString sPassword = NULL);
|
||||
BOOL IsInitialized() const;
|
||||
void Uninitialize();
|
||||
CString GetProfile() const;
|
||||
BOOL SendMapiMail(CString sTo, CString sSubject, CString sDescription, CString sAtt);
|
||||
|
||||
protected:
|
||||
CString GetReturnMsg(int nErr);
|
||||
BOOL InitializeMessageStore();
|
||||
|
||||
|
||||
LPMESSAGE ComposeMessage(LPCTSTR szRecipient, LPCTSTR szSubject, LPCTSTR szDescription, LPCTSTR szAtt);
|
||||
LPADRLIST GetRecipient(LPCTSTR szRecipient);
|
||||
HRESULT AddAttachments(LPMESSAGE pMessage, LPCTSTR szAttachData);
|
||||
};
|
||||
|
||||
#endif // __MAILTO_H__
|
||||
// ==========================================================================
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// MailSend.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include <afxwin.h> // MFC core and standard components
|
||||
#include <afxext.h> // MFC extensions
|
||||
#include <afxdisp.h> // MFC OLE automation classes
|
||||
#ifndef _AFX_NO_AFXCMN_SUPPORT
|
||||
#include <afxcmn.h> // MFC support for Windows 95 Common Controls
|
||||
#endif // _AFX_NO_AFXCMN_SUPPORT
|
||||
#include <afxtempl.h> // MFC support for standard templates
|
||||
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user