📄 classcontainer.cpp
字号:
// ClassContainer.cpp: implementation of the CClassContainer class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "mixer.h"
#include "ClassContainer.h"
#include "AbException.h"
#include "AbWinException.h"
#include <sstream>
#include <algorithm>
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
using namespace std;
static CClassContainer g_stat_cClassContainer;
CClassContainer *g_GetClassContainer() {
return &::g_stat_cClassContainer;
}
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CClassContainer::~CClassContainer()
{
for(TLstWndClass::iterator ite=m_lstWndClass.begin();ite < m_lstWndClass.end(); ite++)
{
while(ite->IsInUse()) {
#ifdef _DEBUG
stringstream stm;
stm << "Class still in Use: "<<ite->GetName()<<ends;
OutputDebugString(stm.str().c_str());
#endif
ite->UnRegisterUser();
}
::UnregisterClass((const char*)((ite->GetAtom())|NULL),ite->GetInstance());
}
}
ATOM CClassContainer::RegisterClass(const WNDCLASSEX &w)
{
string strName=w.lpszClassName;
TLstWndClass::iterator ite=find(m_lstWndClass.begin(),m_lstWndClass.end(),strName);
if(ite != m_lstWndClass.end())
{
ite->RegisterUser();
return ite->GetAtom();
}
ATOM hAtom=::RegisterClassEx(&w);
if(!hAtom)
throw CAbWinException(::GetLastError(),__FILE__,__LINE__,w);
CWindowClass wcNew(strName,hAtom,w.hInstance,1);
m_lstWndClass.push_back(wcNew);
return hAtom;
}
void CClassContainer::UnRegisterClass(const ATOM a)
{
TLstWndClass::iterator ite=find(m_lstWndClass.begin(),m_lstWndClass.end(),a);
if(ite != m_lstWndClass.end())
{
ite->UnRegisterUser();
if(!ite->IsInUse())
{
if(::UnregisterClass((const char*)((ite->GetAtom())|NULL),ite->GetInstance()) == 0)
throw CAbException(::GetLastError(),__FILE__,__LINE__);
m_lstWndClass.erase(ite);
}
}
else
throw CAbException(::GetLastError(),__FILE__,__LINE__);
}
bool CClassContainer::IsClassRegistered(const string &str) const
{
TLstWndClass::iterator ite=find(m_lstWndClass.begin(),m_lstWndClass.end(),str);
if(ite != m_lstWndClass.end())
return true;
return false;
}
bool CClassContainer::IsSystemClass(const string &str) const
{
WNDCLASSEX sWndClass;
if(::GetClassInfoEx(NULL,str.c_str(),&sWndClass)) //already registered
{
if(!IsClassRegistered(str)) //this is probably not needed since hInst=NULL
return true;
}
return false;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -