//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // 设置或取消窗口 ClassXP BOOL CXPSet(HWND hWnd, BOOL bClassXP) { PCLASSXP pCxp; pCxp = (PCLASSXP) GetProp(hWnd, TEXT("ClassXP")); if (bClassXP && (pCxp == NULL)) { pCxp = (PCLASSXP) _HeapAlloc(sizeof(CLASSXP)); pCxp->hWnd = hWnd; pCxp->lStyle = GetWindowLong(hWnd, GWL_STYLE); if (CXPGetClass(pCxp) && CXPGetState(pCxp)) { SetProp(hWnd, TEXT("ClassXP"), (HANDLE) pCxp); pCxp->wpPrev = (WNDPROC) SetWindowLongPtr(hWnd, GWL_WNDPROC, (LONG_PTR) pCxp->wpProc); RedrawWindow(hWnd, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ERASENOW | RDW_UPDATENOW); return TRUE; } _HeapFree(pCxp); } else if ((bClassXP == FALSE) && pCxp) { SetWindowLong(hWnd, GWL_WNDPROC, (LONG_PTR) pCxp->wpPrev); RemoveProp(hWnd, TEXT("ClassXP")); _HeapFree(pCxp); RedrawWindow(hWnd, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ERASENOW | RDW_UPDATENOW); return TRUE; } return FALSE; }
DWORD R0HeapFreeCB(DWORD dwRef) { ULONG *pul = (ULONG *)dwRef; // _HeapFree(ULONG hAddress, ULONG flags); return _HeapFree((void *)(pul[0]), pul[1]); }
TREE_STATIC TREE_ERR FreeRTNode(sRT_CTX* pRTCtx, DNODE* pRTNode) { RT_NODES_POOL* pPool = pRTCtx->pRTNodesPool; if (pPool != NULL && (uint8_t*)pRTNode >= (uint8_t*)pPool && (uint8_t*)pRTNode < (uint8_t*)pPool + sizeof(RT_NODES_POOL)*TEMP_NODES_CACHE_SIZE) { pRTNode->N.NodeType.NodeTypeFields.NodeType = NT_Dynamic; pRTNode->N.NodeType.NodeTypeFields.NodeDataType = NDT_Empty; return TREE_OK; } _HeapFree(pRTCtx->pHeapCtx, pRTNode); return TREE_OK; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // 绘制旋转控件 VOID CXPDrawSpinBox(PCCLASSXP pCxp) { UINT x; UINT y; UINT i; UINT j; HDC hDC; RECT rtRect; PBYTE pbDib; BITMAPINFOHEADER biCmb; // 开始绘制 _CXPBeginDraw(hDC, FALSE, TRUE); // 绘制外框 if (pCxp->lParam) { _FrameRect(_CXPGetState(CXPS_DISABLED) ? CXPR_DFRAME : CXPR_FRAME); InflateRect(&rtRect, -1, -1); x = (_CXPGetState(CXPS_LEFTSPIN)) ? rtRect.right : 0; i = (((PCLASSXP) pCxp->lParam)->lState & (CXPS_DISABLED | CXPS_READONLY)) ? CXPR_DWINDOW : CXPR_WINDOW; _DrawLine(x, rtRect.top, x, rtRect.bottom, i); } // 绘制内框 _FillRect(GetSysColor(COLOR_WINDOW)); InflateRect(&rtRect, -1, -1); // 选择图像 if (_CXPGetState(CXPS_DISABLED)) { i = 0; j = 0; } else { if (_CXPGetState(CXPS_PRESSED)) { i = 1; } else if (_CXPGetState(CXPS_HOTLIGHT)) { i = 2; } else { i = 3; } if (_CXPGetState(CXPS_FIRSTPART)) { j = 3; } else { j = i; i = 3; } } // 绘制图象 biCmb = c_biCXPCheck; if (_CXPGetState(CXPS_HORIZON)) { x = _RectWidth(rtRect); biCmb.biWidth = x / 2; biCmb.biHeight = _RectHeight(rtRect); x = rtRect.left + biCmb.biWidth + (x & 1); y = rtRect.top; } else { y = _RectHeight(rtRect); biCmb.biWidth = _RectWidth(rtRect); biCmb.biHeight = y / 2; x = rtRect.left; y = rtRect.top + biCmb.biHeight + (y & 1); } biCmb.biSizeImage = biCmb.biWidth * biCmb.biHeight * 4; pbDib = (PBYTE) _HeapAlloc(biCmb.biSizeImage); if (pbDib) { CXPDibBlendExt((PBYTE) pbDib, biCmb.biWidth, biCmb.biHeight, (PBYTE) c_crCXPComboBox[i], CXPW_CMB, CXPH_CMB); _DrawDIB(rtRect.left, rtRect.top, biCmb.biWidth, biCmb.biHeight, pbDib, &biCmb); CXPDibBlendExt((PBYTE) pbDib, biCmb.biWidth, biCmb.biHeight, (PBYTE) c_crCXPComboBox[j], CXPW_CMB, CXPH_CMB); _DrawDIB(x, y, biCmb.biWidth, biCmb.biHeight, pbDib, &biCmb); _HeapFree(pbDib); } // 绘制箭头 i = _CXPGetState(CXPS_DISABLED) ? CXPR_DARROW : CXPR_ARROW; x = rtRect.left + (biCmb.biWidth / 2); y = rtRect.top + (biCmb.biHeight / 2); if (_CXPGetState(CXPS_HORIZON)) { CXPDrawArrow(hDC, x, y, CXPA_SMALLLEFT, i); x += biCmb.biWidth; CXPDrawArrow(hDC, x, y, CXPA_SMALLRIGHT, i); } else { CXPDrawArrow(hDC, x, y, CXPA_SMALLUP, i); y += biCmb.biHeight; CXPDrawArrow(hDC, x, y, CXPA_SMALLDOWN, i); } // 结束绘制 _CXPEndDraw(hDC); }
void _cdecl DebugDeleteHelper(void *p) { static char msg[kHugeStringSize]; // don't waste stack space! static PGPUInt32 numDelete = 0; if (NULL!=(int)(p)) { PGPBoolean firstGuardWasValid, secondGuardWasValid; PGPUInt8 *freeMe, *temp; PGPUInt32 dataSize, firstGuard, secondGuard, totalSize; numDelete++; temp = freeMe = (PGPUInt8 *) p - 2*sizeof(PGPUInt32); dataSize = ((PGPUInt32 *) temp)[0]; totalSize = dataSize + 3*sizeof(PGPUInt32); firstGuard = ((PGPUInt32 *) temp)[1]; firstGuardWasValid = (firstGuard == kGuardDWord); if (!firstGuardWasValid) { sprintf(msg, "Beginning guard dword trashed on memory block at " "pointer address %x delete number %d", p, numDelete); pgpDebugMsg(msg); } else { temp += 2*sizeof(PGPUInt32) + dataSize; secondGuard = ((PGPUInt32 *) temp)[0]; secondGuardWasValid = (secondGuard == kGuardDWord); if (!secondGuardWasValid) { sprintf(msg, "Ending guard dword trashed on memory block with " "size %d and pointer address %x delete number %d", dataSize, p, numDelete); pgpDebugMsg(msg); } } // Don't whack unless we are sure of the correct size. if (firstGuardWasValid) pgpDebugWhackMemory(freeMe, totalSize); // upside the head _HeapFree((void *) freeMe, 0); #if PGPDISK_DEBUGMEMORYLEAKS totalBytesAllocated -= dataSize; DebugOut("PGPdisk Delete: Freed %d bytes, have %d total allocated\n", dataSize, totalBytesAllocated); #endif // PGPDISK_DEBUGMEMORYLEAKS } }