#include "StdAfx.h"
#include "CoolControlsManager.h"
// If you don't want to see extra TRACE diagnostics,
// modify the line below to: #define CCM_TRACE
#define CCM_TRACE TRACE
#define CCM_TIMER_VAL 100 // 100 ms timer period seems to be good enough...
#define MAX_CLASSNAME 64 // Length of buffer for retrieving the class name
////////////////////////////////////////////////////////////////////////
// CCMControl static members initialization
HWND CCoolControlsManager::CCMControl::m_hWndOld = NULL;
CMapPtrToPtr CCoolControlsManager::m_ctrlMap = 10;
CMapPtrToPtr CCoolControlsManager::m_dlgMap = 10;
BOOL CCoolControlsManager::m_bEnabled = true;
// Changed 02.03.1999 Mike Walter
CMapWordToPtr CCoolControlsManager::m_threadMap = 10;
///////////////////////////////////////////////////////////////////////
// Here is the one and only CCoolControlsManager object
static CCoolControlsManager g_ctrlManager;
CCoolControlsManager& GetCtrlManager()
{
return g_ctrlManager;
}
//CMapPtrToPtr 的定义
class CMapPtrToPtr : public CObject
{
DECLARE_DYNAMIC(CMapPtrToPtr)
protected:
// Association
struct CAssoc
{
CAssoc* pNext;
void* key;
void* value;
};
public:
// Construction
//explicit
CMapPtrToPtr(INT_PTR nBlockSize = 10);
// Attributes
// number of elements
INT_PTR GetCount() const;
INT_PTR GetSize() const;
BOOL IsEmpty() const;
// Lookup
BOOL Lookup(void* key, void*& rValue) const;
// Operations
// Lookup and add if not there
void*& operator[](void* key);
// add a new (key, value) pair
void SetAt(void* key, void* newValue);
// removing existing (key, ?) pair
BOOL RemoveKey(void* key);
void RemoveAll();
// iterating all (key, value) pairs
POSITION GetStartPosition() const;
void GetNextAssoc(POSITION& rNextPosition, void*& rKey, void*& rValue) const;
// advanced features for derived classes
UINT GetHashTableSize() const;
void InitHashTable(UINT hashSize, BOOL bAllocNow = TRUE);
// Overridables: special non-virtual (see map implementation for details)
// Routine used to user-provided hash keys
UINT HashKey(void* key) const;
// Implementation
protected:
CAssoc** m_pHashTable;
UINT m_nHashTableSize;
INT_PTR m_nCount;
CAssoc* m_pFreeList;
struct CPlex* m_pBlocks;
INT_PTR m_nBlockSize;
CAssoc* NewAssoc();
void FreeAssoc(CAssoc*);
CAssoc* GetAssocAt(void*, UINT&, UINT&) const;
public:
~CMapPtrToPtr();
#ifdef _DEBUG
void Dump(CDumpContext&) const;
void AssertValid() const;
#endif
void* GetValueAt(void* key) const;
protected:
// local typedefs for CTypedPtrMap class template
typedef void* BASE_KEY;
typedef void* BASE_ARG_KEY;
typedef void* BASE_VALUE;
typedef void* BASE_ARG_VALUE;
};
//CMapWordToPtr的定义
class CMapWordToPtr : public CObject
{
DECLARE_DYNAMIC(CMapWordToPtr)
protected:
// Association
struct CAssoc
{
CAssoc* pNext;
void* value;
WORD key;
};
public:
// Construction
//explicit
CMapWordToPtr(INT_PTR nBlockSize = 10);
// Attributes
// number of elements
INT_PTR GetCount() const;
INT_PTR GetSize() const;
BOOL IsEmpty() const;
// Lookup
BOOL Lookup(WORD key, void*& rValue) const;
// Operations
// Lookup and add if not there
void*& operator[](WORD key);
// add a new (key, value) pair
void SetAt(WORD key, void* newValue);
// removing existing (key, ?) pair
BOOL RemoveKey(WORD key);
void RemoveAll();
// iterating all (key, value) pairs
POSITION GetStartPosition() const;
void GetNextAssoc(POSITION& rNextPosition, WORD& rKey, void*& rValue) const;
// advanced features for derived classes
UINT GetHashTableSize() const;
void InitHashTable(UINT hashSize, BOOL bAllocNow = TRUE);
// Overridables: special non-virtual (see map implementation for details)
// Routine used to user-provided hash keys
UINT HashKey(WORD key) const;
// Implementation
protected:
CAssoc** m_pHashTable;
UINT m_nHashTableSize;
INT_PTR m_nCount;
CAssoc* m_pFreeList;
struct CPlex* m_pBlocks;
INT_PTR m_nBlockSize;
CAssoc* NewAssoc();
void FreeAssoc(CAssoc*);
CAssoc* GetAssocAt(WORD, UINT&, UINT&) const;
public:
~CMapWordToPtr();
#ifdef _DEBUG
void Dump(CDumpContext&) const;
void AssertValid() const;
#endif
protected:
// local typedefs for CTypedPtrMap class template
typedef WORD BASE_KEY;
typedef WORD BASE_ARG_KEY;
typedef void* BASE_VALUE;
typedef void* BASE_ARG_VALUE;
};
错误提示:
尝试过在定义中将explicit注释掉,但是在保存的时候提示要访问的路径被拒绝,保存不了,请问还有其他的解决方法么
Please check the definition of CMapPtrToPtr.
CMapPtrToPtr CCoolControlsManager::m_ctrlMap = XXXXX;
This line allows you to assign a value to the (static) variable CCoolControlsManager::m_ctrlMap. m_ctrlMap is of type CMapPtrToPtr, so it can only be used The same data of type CMapPtrToPtr is assigned.
For example, it can be written as
CCoolControlsManager::m_ctrlMap = CMapPtrToPtr(); // Assume that CMapPtrToPtr has a default constructor.
In short, where CMapPtrToPtr is defined, generally It will also prompt how to create an instance of it. Please check it out