工具代码(170) 发表于 2016-08-04 | 分类于 配置 ++123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 #pragma once class CSeparaString { public: CSeparaString() { m_strBuffer.Empty(); } ~CSeparaString() {} VOID SetBuffer(LPCTSTR lpsz) { m_strBuffer = lpsz; } CString GetBuffer() const { return m_strBuffer; } VOID SetSepara(TCHAR ch) { m_chSepara = ch; } VOID AppendElement(int ne) { TCHAR buffer[10] = {0}; _itot_s(ne, buffer, 4, 10); m_strBuffer.Append(CString(m_chSepara)); m_strBuffer.Append(buffer); } VOID AppendElement(LPCTSTR lpsz) { m_strBuffer.Append(CString(m_chSepara)); m_strBuffer.Append(lpsz); } VOID GetElement(CStringArray &arry) { int npos = m_strBuffer.Find(m_chSepara); while (npos != m_strBuffer.GetLength()) { int epos = m_strBuffer.Find(m_chSepara, npos + 1); (epos == -1) && (epos = m_strBuffer.GetLength()); arry.Add(m_strBuffer.Mid(npos + 1, epos - npos - 1)); npos = epos; } } CString GetElement(int nelement) { int npos = -1; int epos = m_strBuffer.Find(m_chSepara); for (int i = 0; i < nelement; i++) { npos = epos; epos = m_strBuffer.Find(m_chSepara, npos + 1); } (epos == -1) && (epos = m_strBuffer.GetLength()); return m_strBuffer.Mid(npos + 1, epos - npos - 1); } private: TCHAR m_chSepara; public: CString m_strBuffer; }; CRect CDlgImportPicture::CalculateMaxRect(const CRect *prect, int numerator, int denominator) { CRect rtRE; if (prect) { rtRE = prect; //先算宽高度基准 if (prect->Width() * denominator > numerator * prect->Height())//宽过多,高基准 { int offset = prect->Width() - ((prect->Height() * numerator)/denominator); rtRE.left += offset/2; rtRE.right -= offset/2; } else//高过多,宽基准 { int offset = prect->Height() - ((prect->Width() * denominator)/numerator); rtRE.top += offset/2; rtRE.bottom -= offset/2; } } return rtRE; }# 时间 #define TickStart() DWORD dwstart = GetTickCount(), dwend = 0;\ TCHAR buffer[1024] = {0};\ TCHAR thisname[1024] = {0};\ _ltot_s(int(this), thisname, 1024, 10);\ #define TickOutName(str) OutputDebugString(CString(thisname) + _T(" :") + str);\ OutputDebugString(_T("\n"));\ #define TickOutPut(str) dwend = GetTickCount();\ _ltot_s(dwend - dwstart, buffer, 1024, 10);\ OutputDebugString(CString(thisname) + _T(" :") + str);\ OutputDebugString(buffer);\ OutputDebugString(_T("\n"));\ dwstart = dwend;\