工具代码(170)

++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#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;\
// //