#include "StdAfx.h"
#include "UIDlgBuilder.h"
/////////////////////////////////////////////////////////////////////////////////////
CStdPtrArray::CStdPtrArray(int iPreallocSize) : m_ppVoid(NULL), m_nCount(0), m_nAllocated(iPreallocSize)
{
ASSERT(iPreallocSize>=0);
if( iPreallocSize > 0 ) m_ppVoid = static_cast<LPVOID*>(malloc(iPreallocSize * sizeof(LPVOID)));
}
CStdPtrArray::~CStdPtrArray()
{
if( m_ppVoid != NULL ) free(m_ppVoid);
}
void CStdPtrArray::Empty()
{
if( m_ppVoid != NULL ) free(m_ppVoid);
m_ppVoid = NULL;
m_nCount = m_nAllocated = 0;
}
void CStdPtrArray::Resize(int iSize)
{
Empty();
m_ppVoid = static_cast<LPVOID*>(malloc(iSize * sizeof(LPVOID)));
::ZeroMemory(m_ppVoid, iSize * sizeof(LPVOID));
m_nAllocated = iSize;
m_nCount = iSize;
}
bool CStdPtrArray::IsEmpty() const
{
return m_nCount == 0;
}
bool CStdPtrArray::Add(LPVOID pData)
{
if( ++m_nCount >= m_nAllocated) {
m_nAllocated *= 2;
if( m_nAllocated == 0 ) m_nAllocated = 11;
m_ppVoid = static_cast<LPVOID*>(realloc(m_ppVoid, m_nAllocated * sizeof(LPVOID)));
if( m_ppVoid == NULL ) return false;
}
m_ppVoid[m_nCount - 1] = pData;
return true;
}
bool CStdPtrArray::InsertAt(int iIndex, LPVOID pData)
{
if( iIndex == m_nCount ) return Add(pData);
if( iIndex < 0 || iIndex > m_nCount ) return false;
if( ++m_nCount >= m_nAllocated) {
m_nAllocated *= 2;
if( m_nAllocated == 0 ) m_nAllocated = 11;
m_ppVoid = static_cast<LPVOID*>(realloc(m_ppVoid, m_nAllocated * sizeof(LPVOID)));
if( m_ppVoid == NULL ) return false;
}
memmove(&m_ppVoid[iIndex + 1], &m_ppVoid[iIndex], (m_nCount - iIndex - 1) * sizeof(LPVOID));
m_ppVoid[iIndex] = pData;
return true;
}
bool CStdPtrArray::SetAt(int iIndex, LPVOID pData)
{
if( iIndex < 0 || iIndex >= m_nCount ) return false;
m_ppVoid[iIndex] = pData;
return true;
}
bool CStdPtrArray::Remove(int iIndex)
{
if( iIndex < 0 || iIndex >= m_nCount ) return false;
if( iIndex < --m_nCount ) ::CopyMemory(m_ppVoid + iIndex, m_ppVoid + iIndex + 1, (m_nCount - iIndex) * sizeof(LPVOID));
return true;
}
int CStdPtrArray::Find(LPVOID pData) const
{
for( int i = 0; i < m_nCount; i++ ) if( m_ppVoid[i] == pData ) return i;
return -1;
}
int CStdPtrArray::GetSize() const
{
return m_nCount;
}
LPVOID* CStdPtrArray::GetData()
{
return m_ppVoid;
}
LPVOID CStdPtrArray::GetAt(int iIndex) const
{
if( iIndex < 0 || iIndex >= m_nCount ) return NULL;
return m_ppVoid[iIndex];
}
LPVOID CStdPtrArray::operator[] (int iIndex) const
{
ASSERT(iIndex>=0 && iIndex<m_nCount);
return m_ppVoid[iIndex];
}
/////////////////////////////////////////////////////////////////////////////////////
//
//
CStdString::CStdString() : m_pstr(m_szBuffer)
{
m_szBuffer[0] = '\0';
}
CStdString::CStdString(const TCHAR ch) : m_pstr(m_szBuffer)
{
m_szBuffer[0] = ch;
m_szBuffer[1] = '\0';
}
CStdString::CStdString(LPCTSTR lpsz, int nLen) : m_pstr(m_szBuffer)
{
ASSERT(!::IsBadStringPtr(lpsz,-1) || lpsz==NULL);
Assign(lpsz, nLen);
}
CStdString::CStdString(const CStdString& src) : m_pstr(m_szBuffer)
{
Assign(src.m_pstr);
}
CStdString::~CStdString()
{
if( m_pstr != m_szBuffer ) free(m_pstr);
}
int CStdString::GetLength() const
{
return (int) _tcslen(m_pstr);
}
CStdString::operator LPCTSTR() const
{
return m_pstr;
}
void CStdString::Append(LPCTSTR pstr)
{
int nNewLength = GetLength() + (int) _tcslen(pstr);
if( nNewLength >= MAX_LOCAL_STRING_LEN ) {
if( m_pstr == m_szBuffer ) {
m_pstr = static_cast<LPTSTR>(malloc((nNewLength + 1) * sizeof(TCHAR)));
_tcscpy(m_pstr, m_szBuffer);
_tcscat(m_pstr, pstr);
}
else {
m_pstr = static_cast<LPTSTR>(realloc(m_pstr, (nNewLength + 1) * sizeof(TCHAR)));
_tcscat(m_pstr, pstr);
}
}
else {
if( m_pstr != m_szBuffer ) {
free(m_pstr);
m_pstr = m_szBuffer;
}
_tcscat(m_szBuffer, pstr);
}
}
void CStdString::Assign(LPCTSTR pstr, int cchMax)
{
if( pstr == NULL ) pstr = _T("");
cchMax = (cchMax < 0 ? (int) _tcslen(pstr) : cchMax);
if( cchMax < MAX_LOCAL_STRING_LEN ) {
if( m_pstr != m_szBuffer ) {
free(m_pstr);
m_pstr = m_szBuffer;
}
}
else if( cchMax > GetLength() || m_pstr == m_szBuffer ) {
if( m_pstr == m_szBuffer ) m_pstr = NULL;
m_pstr = static_cast<LPTSTR>(realloc(m_pstr, (cchMax + 1) * sizeof(TCHAR)));
}
_tcsncpy(m_pstr, pstr, cchMax);
m_pstr[cchMax] = '\0';
}
bool CStdString::IsEmpty() const
{
return m_pstr[0] == '\0';
}
void CStdString::Empty()
{
if( m_pstr != m_szBuffer ) free(m_pstr);
m_pstr = m_szBuffer;
m_szBuffer[0] = '\0';
}
LPCTSTR CStdString::GetData()
{
return m_pstr;
}
TCHAR CStdString::GetAt(int nIndex) const
{
return m_pstr[nIndex];
}
TCHAR CStdString::operator[] (int nIndex) const
{
return m_pstr[nIndex];
}
const CStdString& CStdString::operator=(const CStdString& src)
{
Assign(src);
return *this;
}
const CStdString& CStdString::operator=(LPCTSTR lpStr)
{
ASSERT(!::IsBadStringPtr(lpStr,-1));
Assign(lpStr);
return *this;
}
#ifndef _UNICODE
const CStdString& CStdString::operator=(LPCWSTR lpwStr)
{
ASSERT(!::IsBadStringPtrW(lpwStr,-1));
int cchStr = ((int) wcslen(lpwStr) * 2) + 1;
LPSTR pstr = (LPSTR) _alloca(cchStr);
if( pstr != NULL ) ::WideCharToMultiByte(::GetACP(), 0, lpwStr, -1, pstr, cchStr, NULL, NULL);
Assign(pstr);
return *this;
}
#endif // _UNICODE
const CStdString& CStdString::operator=(const TCHAR ch)
{
Empty();
m_szBuffer[0] = ch;
m_szBuffer[1] = '\0';
return *this;
}
CStdString CStdString::operator+(const CStdString& src)
{
Append(src);
return *this;
}
CStdString CStdString::operator+(LPCTSTR lpStr)
{
ASSERT(!::IsBadStringPtr(lpStr,-1));
Append(lpStr);
return *this;
}
const CStdString& CStdString::operator+=(const CStdString& src)
{
Append(src);
return *this;
}
const CStdString& CStdString::operator+=(LPCTSTR lpStr)
{
ASSERT(!::IsBadStringPtr(lpStr,-1));
Append(lpStr);
return *this;
}
const CStdString& CStdString::operator+=(const TCHAR ch)
{
TCHAR str[] = { ch, '\0' };
Append(str);
return *this;
}
bool CStdString::operator == (LPCTSTR str) const { return (Compare(str) == 0); };
bool CStdString::operator != (LPCTSTR str) const { return (Compare(str) != 0); };
bool CStdString::operator <= (LPCTSTR str) const { return (Compare(str) <= 0); };
bool CStdString::operator < (LPCTSTR str) const { return (Compare(str) < 0); };
bool CStdString::operator >= (LPCTSTR str) const { return (Compare(str) >= 0); };
bool CStdString::operator > (LPCTSTR str) const { return (Compare(str) > 0); };
void CStdString::SetAt(int nIndex, TCHAR ch)
{
ASSERT(nIndex>=0 && nIndex<GetLength());
m_pstr[nIndex] = ch;
}
int CStdString::Compare(LPCTSTR lpsz) const
{
return _tcscmp(m_pstr, lpsz);
}
int CStdString::CompareNoCase(LPCTSTR lpsz) const
{
return _tcsicmp(m_pstr, lpsz);
}
void CStdString::MakeUpper()
{
_tcsupr(m_pstr);
}
void CStdString::MakeLower()
{
_tcslwr(m_pstr);
}
CStdString CStdString::Left(int iLength) const
{
if( iLength < 0 ) iLength = 0;
if( iLength > GetLength() ) iLength = GetLength();
return CStdString(m_pstr, iLength);
}
CStdString CStdString::Mid(int iPos, int iLength) const
{
if( iLength < 0 ) iLength = GetLength() - iPos;
if( iPos + iLength > GetLength() ) iLength = GetLength() - iPos;
if( iLength <= 0 ) return CStdString();
return CStdString(m_pstr + iPos, iLength);
}
CStdString CStdString::Right(int iLength) const
{
int iPos = GetLength() - iLength;
if( iPos < 0 ) {
iPos = 0;
iLength = GetLength();
}
return CStdString(m_pstr + iPos, iLength);
}
int CStdString::Find(TCHAR ch, int iPos /*= 0*/) const
{
ASSERT(iPos>=0 && iPos<=GetLength());
if( iPos != 0 && (iPos <
没有合适的资源?快使用搜索试试~ 我知道了~
WIN32界面开发之四:CPaintManagerUI类构建 源码
共36个文件
h:7个
obj:6个
cpp:6个
3星 · 超过75%的资源 需积分: 50 159 下载量 161 浏览量
2013-07-31
10:23:26
上传
评论 1
收藏 3.08MB RAR 举报
温馨提示
WIN32界面开发之四:CPaintManagerUI类构建 源码,对应博客地址:http://blog.csdn.net/harvic880925/article/details/9632613,转载请标明出处哦。
资源推荐
资源详情
资源评论
收起资源包目录
DUIRudiment.rar (36个子文件)
DUIRudiment
DUIRudiment
DUIRudiment.vcproj.20120612-1003.Administrator.user 1KB
Base.cpp 2KB
UIManager.h 1KB
stdafx.cpp 210B
Main.h 610B
UIMarkup.h 3KB
DUIRudiment.vcproj.20120402-1425.Administrator.user 1KB
stdafx.h 844B
Base.h 686B
DUIRudiment.vcproj 5KB
UIMarkup.cpp 14KB
UIDlgBuilder.cpp 18KB
targetver.h 1KB
UIDlgBuilder.h 7KB
UIManager.cpp 9KB
Debug
UIManager.obj 73KB
stdafx.obj 44KB
BuildLog.htm 13KB
DUIRudiment.exe.embed.manifest.res 728B
UIMarkup.obj 84KB
UIDlgBuilder.obj 185KB
vc90.pdb 452KB
vc90.idb 651KB
mt.dep 67B
DUIRudiment.exe.embed.manifest 663B
Base.obj 55KB
Main.obj 65KB
DUIRudiment.exe.intermediate.manifest 621B
Main.cpp 3KB
DUIRudiment.sln 899B
bg.png 67KB
DUIRudiment.suo 28KB
DUIRudiment.ncb 15.39MB
Debug
DUIRudiment.pdb 1.13MB
DUIRudiment.ilk 660KB
DUIRudiment.exe 93KB
共 36 条
- 1
资源评论
- yang8758909162014-05-09还行,可以参考一下。
- otox2017-09-17下错了,抱歉,少一个积分
启舰
- 粉丝: 4w+
- 资源: 197
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- apache-maven-3.6.1-bin.zip
- c593f5fc-d4a7-4b43-8ab2-51afc90f3f62
- IIR滤波器参数计算函数
- WPF树菜单拖拽功能,下级目录拖到上级目录,上级目录拖到下级目录.zip
- CDH6.3.2版本hive2.1.1修复HIVE-14706后的jar包
- 鸿蒙项目实战-天气项目(当前城市天气、温度、湿度,24h天气,未来七天天气预报,生活指数,城市选择等)
- Linux环境下oracle数据库服务器配置中文最新版本
- Linux操作系统中Oracle11g数据库安装步骤详细图解中文最新版本
- SMA中心接触件插合力量(插入力及分离力)仿真
- 变色龙记事本,有NPP功能,JSONview功能
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功