|
void CMyTracker::Construct()
{
AfxLockGlobals(CRIT_RECTTRACKER);
static BOOL bInitialized;
if (!bInitialized)
{
// sanity checks for assumptions we make in the code
ASSERT(sizeof(((RECT*)NULL)->left) == sizeof(int));
ASSERT(offsetof(RECT, top) > offsetof(RECT, left));
ASSERT(offsetof(RECT, right) > offsetof(RECT, top));
ASSERT(offsetof(RECT, bottom) > offsetof(RECT, right));
if (_afxHatchBrush == NULL)
{
// create the hatch pattern + bitmap
WORD hatchPattern[8];
WORD wPattern = 0x1111;
for (int i = 0; i < 4; i++)
{
hatchPattern = wPattern;
hatchPattern[i+4] = wPattern;
wPattern <<= 1;
}
HBITMAP hatchBitmap = CreateBitmap(8, 8, 1, 1, &hatchPattern);
if (hatchBitmap == NULL)
{
AfxUnlockGlobals(CRIT_RECTTRACKER);
AfxThrowResourceException();
}
// create black hatched brush
_afxHatchBrush = CreatePatternBrush(hatchBitmap);
DeleteObject(hatchBitmap);
if (_afxHatchBrush == NULL)
{
AfxUnlockGlobals(CRIT_RECTTRACKER);
AfxThrowResourceException();
}
}
//CreatePen for DottedLine and SolidLine
CreatePen();
// Note: all track cursors must live in same module
HINSTANCE hInst = AfxFindResourceHandle(
MAKEINTRESOURCE(AFX_IDC_TRACK4WAY), RT_GROUP_CURSOR);
// initialize the cursor array
_afxCursors[0] = ::LoadCursor(hInst, MAKEINTRESOURCE(AFX_IDC_TRACKNWSE));
_afxCursors[1] = ::LoadCursor(hInst, MAKEINTRESOURCE(AFX_IDC_TRACKNESW));
_afxCursors[2] = _afxCursors[0];
_afxCursors[3] = _afxCursors[1];
_afxCursors[4] = ::LoadCursor(hInst, MAKEINTRESOURCE(AFX_IDC_TRACKNS));
_afxCursors[5] = ::LoadCursor(hInst, MAKEINTRESOURCE(AFX_IDC_TRACKWE));
_afxCursors[6] = _afxCursors[4];
_afxCursors[7] = _afxCursors[5];
_afxCursors[8] = ::LoadCursor(hInst, MAKEINTRESOURCE(AFX_IDC_TRACK4WAY));
_afxCursors[9] = ::LoadCursor(hInst, MAKEINTRESOURCE(AFX_IDC_MOVE4WAY));
// get default handle size from Windows profile setting
static const TCHAR szWindows[] = _T("windows");
static const TCHAR szInplaceBorderWidth[] =
_T("oleinplaceborderwidth");
_afxHandleSize = GetProfileInt(szWindows, szInplaceBorderWidth, 4);
bInitialized = TRUE;
}
AfxUnlockGlobals(CRIT_RECTTRACKER);
m_nStyle = 0;
m_nHandleSize = _afxHandleSize;
m_sizeMin.cy = m_sizeMin.cx = m_nHandleSize*2;
m_rectLast.SetRectEmpty();
m_sizeLast.cx = m_sizeLast.cy = 0;
m_bErase = FALSE;
m_bFinalErase = FALSE;
}
这段是MFC基类CRectTracker中的一个函数,主要功能就是调整画的矩形框的大小,但是这里面的GetProfileInt函数看不懂,他是什么意思呢,我知道GetProfileInt函数就是从注册表里查询oleinplaceborderwidth的键值(即windows设置的ole边框宽度),如果没有查到,就用默认宽度是4。但是在这里面他是什么意思,干嘛用的呢?
|
|