class CSeparaString
{
public:
CSeparaString() { m_strBuffer.Empty(); }
~CSeparaString() {}
VOID (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;
近期评论