60 lines
1.1 KiB
C++
60 lines
1.1 KiB
C++
#ifndef _KTCADSYSVAR_H__
|
|
#define _KTCADSYSVAR_H__
|
|
|
|
#if _MSC_VER > 1000
|
|
#pragma once
|
|
#endif
|
|
|
|
template <typename T,BOOL bIsString = FALSE> class KTCADSysVar
|
|
{
|
|
public:
|
|
KTCADSysVar(LPCTSTR pszVar,T t)
|
|
{
|
|
acedGetVar(pszVar,&m_rbOld);
|
|
struct resbuf rb;
|
|
if (bIsString)
|
|
{
|
|
rb.restype = m_rbOld.restype;
|
|
acutNewString(m_rbOld.resval.rstring,rb.resval.rstring);
|
|
}
|
|
else
|
|
{
|
|
memcpy(&rb,&m_rbOld,sizeof(resbuf));
|
|
memcpy(&rb.resval,&t,sizeof(t));
|
|
}
|
|
acedSetVar(pszVar,&rb);
|
|
if (bIsString)
|
|
acutDelString(rb.resval.rstring);
|
|
m_sVarName = pszVar;
|
|
}
|
|
|
|
void ReSet(T t)
|
|
{
|
|
struct resbuf rb;
|
|
if (bIsString)
|
|
{
|
|
rb.restype = m_rbOld.restype;
|
|
acutNewString(m_rbOld.resval.rstring,rb.resval.rstring);
|
|
}
|
|
else
|
|
{
|
|
memcpy(&rb,&m_rbOld,sizeof(resbuf));
|
|
memcpy(&rb.resval,&t,sizeof(t));
|
|
}
|
|
if (bIsString)
|
|
acutDelString(rb.resval.rstring);
|
|
acedSetVar(m_sVarName,&rb);
|
|
}
|
|
|
|
~KTCADSysVar()
|
|
{
|
|
acedSetVar(m_sVarName,&m_rbOld);
|
|
}
|
|
private:
|
|
|
|
CString m_sVarName;
|
|
struct resbuf m_rbOld;
|
|
};
|
|
|
|
#endif //_KTCADSYSVAR_H__
|