获取treeview控件中项的矩形大小.



DWORD pId;
::GetWindowThreadProcessId(ParhWnd,&pId);
HANDLE Handle=::OpenProcess(PROCESS_ALL_ACCESS,FALSE,pId);
if(Handle==NULL)
return FALSE;
TVITEM lvitem;
lvitem.hItem=(HTREEITEM)::SendMessage(hWnd,TVM_GETNEXTITEM,TVGN_ROOT, 0);//根句柄
TVITEMEX  lvi, *_lvi;  
RECT rc={0}, *_rc;
_lvi=(TVITEMEX *)::VirtualAllocEx(Handle, NULL, sizeof(LVITEM),MEM_COMMIT, PAGE_READWRITE);  

_rc=(RECT *)::VirtualAllocEx(Handle, NULL, sizeof(RECT),MEM_COMMIT, PAGE_READWRITE);  

for (int i=0;i<13;i++)
{
//获取树矩形
*(HTREEITEM*)&rc = lvitem.hItem;
if(!::WriteProcessMemory(Handle, _rc, &rc, sizeof(RECT), NULL))
continue;
if(SendMessage(hWnd, TVM_GETITEMRECT, FALSE, (LPARAM)_rc))
{


if(::ReadProcessMemory(Handle, _rc,  (LPVOID)&rc,  sizeof(RECT), NULL))
{
CString rcs;
rcs.Format("bottom:%d,left:%d\nright:%d,top:%d",rc.bottom,rc.left,rc.right,rc.top);
AfxMessageBox(rcs);
}
}

你可能感兴趣的:(获取treeview控件中项的矩形大小.)