如何用API选中TreeView一个目录下的一个节点(20分)

  • 主题发起人 主题发起人 全文检索
  • 开始时间 开始时间

全文检索

Unregistered / Unconfirmed
GUEST, unregistred user!
已知 TreeView的Handle<br>如何用API选中TreeView一个目录下的一个节点<br><br>E文不咋的<br><br>帮我看看用那几个API实现<br><br><br>{ Tree View }<br><br>function TreeView_InsertItem(hwnd: HWND; const lpis: TTVInsertStruct): HTreeItem;<br>begin<br> &nbsp;Result := HTreeItem( SendMessage(hwnd, TVM_INSERTITEM, 0, Longint(@lpis)) );<br>end;<br><br>function TreeView_DeleteItem(hwnd: HWND; hitem: HTreeItem): Bool;<br>begin<br> &nbsp;Result := Bool( SendMessage(hwnd, TVM_DELETEITEM, 0, Longint(hitem)) );<br>end;<br><br>function TreeView_DeleteAllItems(hwnd: HWND): Bool;<br>begin<br> &nbsp;Result := Bool( SendMessage(hwnd, TVM_DELETEITEM, 0, Longint(TVI_ROOT)) );<br>end;<br><br>function TreeView_Expand(hwnd: HWND; hitem: HTreeItem; code: Integer): Bool;<br>begin<br> &nbsp;Result := Bool( SendMessage(hwnd, TVM_EXPAND, code, Longint(hitem)) );<br>end;<br><br>function TreeView_GetItemRect(hwnd: HWND; hitem: HTreeItem;<br> &nbsp;var prc: TRect; code: Bool): Bool;<br>begin<br> &nbsp;HTreeItem(Pointer(@prc)^) := hitem;<br> &nbsp;Result := Bool( SendMessage(hwnd, TVM_GETITEMRECT, Integer(code), Longint(@prc)) );<br>end;<br><br>function TreeView_GetCount(hwnd: HWND): UINT;<br>begin<br> &nbsp;Result := SendMessage(hwnd, TVM_GETCOUNT, 0, 0);<br>end;<br><br>function TreeView_GetIndent(hwnd: HWND): UINT;<br>begin<br> &nbsp;Result := SendMessage(hwnd, TVM_GETINDENT, 0, 0);<br>end;<br><br>function TreeView_SetIndent(hwnd: HWND; indent: Integer): Bool;<br>begin<br> &nbsp;Result := Bool( SendMessage(hwnd, TVM_SETINDENT, indent, 0) );<br>end;<br><br>function TreeView_GetImageList(hwnd: HWND; iImage: Integer): HIMAGELIST;<br>begin<br> &nbsp;Result := HIMAGELIST( SendMessage(hwnd, TVM_GETIMAGELIST, iImage, 0) );<br>end;<br><br>function TreeView_SetImageList(hwnd: HWND; himl: HIMAGELIST;<br> &nbsp;iImage: Integer): HIMAGELIST;<br>begin<br> &nbsp;Result := HIMAGELIST( SendMessage(hwnd, TVM_SETIMAGELIST, iImage,<br> &nbsp; &nbsp;Longint(himl)) );<br>end;<br><br>function TreeView_GetNextItem(hwnd: HWND; hitem: HTreeItem;<br> &nbsp;code: Integer): HTreeItem;<br>begin<br> &nbsp;Result := HTreeItem( SendMessage(hwnd, TVM_GETNEXTITEM, code,<br> &nbsp; &nbsp;Longint(hitem)) );<br>end;<br><br>function TreeView_GetChild(hwnd: HWND; hitem: HTreeItem): HTreeItem;<br>begin<br> &nbsp;Result := TreeView_GetNextItem(hwnd, hitem, TVGN_CHILD);<br>end;<br><br>function TreeView_GetNextSibling(hwnd: HWND; hitem: HTreeItem): HTreeItem;<br>begin<br> &nbsp;Result := TreeView_GetNextItem(hwnd, hitem, TVGN_NEXT);<br>end;<br><br>function TreeView_GetPrevSibling(hwnd: HWND; hitem: HTreeItem): HTreeItem;<br>begin<br> &nbsp;Result := TreeView_GetNextItem(hwnd, hitem, TVGN_PREVIOUS);<br>end;<br><br>function TreeView_GetParent(hwnd: HWND; hitem: HTreeItem): HTreeItem;<br>begin<br> &nbsp;Result := TreeView_GetNextItem(hwnd, hitem, TVGN_PARENT);<br>end;<br><br>function TreeView_GetFirstVisible(hwnd: HWND): HTreeItem;<br>begin<br> &nbsp;Result := TreeView_GetNextItem(hwnd, nil, &nbsp;TVGN_FIRSTVISIBLE);<br>end;<br><br>function TreeView_GetNextVisible(hwnd: HWND; hitem: HTreeItem): HTreeItem;<br>begin<br> &nbsp;Result := TreeView_GetNextItem(hwnd, hitem, TVGN_NEXTVISIBLE);<br>end;<br><br>function TreeView_GetPrevVisible(hwnd: HWND; hitem: HTreeItem): HTreeItem;<br>begin<br> &nbsp;Result := TreeView_GetNextItem(hwnd, hitem, TVGN_PREVIOUSVISIBLE);<br>end;<br><br>function TreeView_GetSelection(hwnd: HWND): HTreeItem;<br>begin<br> &nbsp;Result := TreeView_GetNextItem(hwnd, nil, TVGN_CARET);<br>end;<br><br>function TreeView_GetDropHilite(hwnd: HWND): HTreeItem;<br>begin<br> &nbsp;Result := TreeView_GetNextItem(hwnd, nil, TVGN_DROPHILITE);<br>end;<br><br>function TreeView_GetRoot(hwnd: HWND): HTreeItem;<br>begin<br> &nbsp;Result := TreeView_GetNextItem(hwnd, nil, TVGN_ROOT);<br>end;<br><br>function TreeView_GetLastVisible(hwnd: HWND): HTreeItem;<br>begin<br> &nbsp;Result := TreeView_GetNextItem(hwnd, nil, &nbsp;TVGN_LASTVISIBLE);<br>end;<br><br>function TreeView_Select(hwnd: HWND; hitem: HTreeItem;<br> &nbsp;code: Integer): HTreeItem;<br>begin<br> &nbsp;Result := HTreeItem( SendMessage(hwnd, TVM_SELECTITEM, code,<br> &nbsp; &nbsp;Longint(hitem)) );<br>end;<br><br>function TreeView_SelectItem(hwnd: HWND; hitem: HTreeItem): HTreeItem;<br>begin<br> &nbsp;Result := TreeView_Select(hwnd, hitem, TVGN_CARET);<br>end;<br><br>function TreeView_SelectDropTarget(hwnd: HWND; hitem: HTreeItem): HTreeItem;<br>begin<br> &nbsp;Result := TreeView_Select(hwnd, hitem, TVGN_DROPHILITE);<br>end;<br><br>function TreeView_SelectSetFirstVisible(hwnd: HWND; hitem: HTreeItem): HTreeItem;<br>begin<br> &nbsp;Result := TreeView_Select(hwnd, hitem, TVGN_FIRSTVISIBLE);<br>end;<br><br>function TreeView_GetItem(hwnd: HWND; var pitem: TTVItem): Bool;<br>begin<br> &nbsp;Result := Bool( SendMessage(hwnd, TVM_GETITEM, 0, Longint(@pitem)) );<br>end;<br>function TreeView_GetItemA(hwnd: HWND; var pitem: TTVItemA): Bool;<br>begin<br> &nbsp;Result := Bool( SendMessage(hwnd, TVM_GETITEM, 0, Longint(@pitem)) );<br>end;<br>function TreeView_GetItemW(hwnd: HWND; var pitem: TTVItemW): Bool;<br>begin<br> &nbsp;Result := Bool( SendMessage(hwnd, TVM_GETITEM, 0, Longint(@pitem)) );<br>end;<br><br>function TreeView_SetItem(hwnd: HWND; const pitem: TTVItem): Bool;<br>begin<br> &nbsp;Result := Bool( SendMessage(hwnd, TVM_SETITEM, 0, Longint(@pitem)) );<br>end;<br>function TreeView_SetItemA(hwnd: HWND; const pitem: TTVItemA): Bool;<br>begin<br> &nbsp;Result := Bool( SendMessage(hwnd, TVM_SETITEM, 0, Longint(@pitem)) );<br>end;<br>function TreeView_SetItemW(hwnd: HWND; const pitem: TTVItemW): Bool;<br>begin<br> &nbsp;Result := Bool( SendMessage(hwnd, TVM_SETITEM, 0, Longint(@pitem)) );<br>end;<br><br>function TreeView_EditLabel(hwnd: HWND; hitem: HTreeItem): HWND;<br>begin<br> &nbsp;Result := Windows.HWND( SendMessage(hwnd, TVM_EDITLABEL, 0, Longint(hitem)) );<br>end;<br>function TreeView_EditLabelA(hwnd: HWND; hitem: HTreeItem): HWND;<br>begin<br> &nbsp;Result := Windows.HWND( SendMessage(hwnd, TVM_EDITLABEL, 0, Longint(hitem)) );<br>end;<br>function TreeView_EditLabelW(hwnd: HWND; hitem: HTreeItem): HWND;<br>begin<br> &nbsp;Result := Windows.HWND( SendMessage(hwnd, TVM_EDITLABEL, 0, Longint(hitem)) );<br>end;<br><br>function TreeView_GetEditControl(hwnd: HWND): HWND;<br>begin<br> &nbsp;Result := Windows.HWND( SendMessage(hwnd, TVM_GETEDITCONTROL, 0, 0) );<br>end;<br><br>function TreeView_GetVisibleCount(hwnd: HWND): UINT;<br>begin<br> &nbsp;Result := SendMessage(hwnd, TVM_GETVISIBLECOUNT, 0, 0);<br>end;<br><br>function TreeView_HitTest(hwnd: HWND; var lpht: TTVHitTestInfo): HTreeItem;<br>begin<br> &nbsp;Result := HTreeItem( SendMessage(hwnd, TVM_HITTEST, 0, Longint(@lpht)) );<br>end;<br><br>function TreeView_CreateDragImage(hwnd: HWND; hitem: HTreeItem): HIMAGELIST;<br>begin<br> &nbsp;Result := HIMAGELIST( SendMessage(hwnd, TVM_CREATEDRAGIMAGE, 0,<br> &nbsp; &nbsp;Longint(hitem)) );<br>end;<br><br>function TreeView_SortChildren(hwnd: HWND; hitem: HTreeItem;<br> &nbsp;recurse: Integer): Bool;<br>begin<br> &nbsp;Result := Bool( SendMessage(hwnd, TVM_SORTCHILDREN, recurse,<br> &nbsp; &nbsp;Longint(hitem)) );<br>end;<br><br>function TreeView_EnsureVisible(hwnd: HWND; hitem: HTreeItem): Bool;<br>begin<br> &nbsp;Result := Bool( SendMessage(hwnd, TVM_ENSUREVISIBLE, 0, Longint(hitem)) );<br>end;<br><br>function TreeView_SortChildrenCB(hwnd: HWND; const psort: TTVSortCB;<br> &nbsp;recurse: Integer): Bool;<br>begin<br> &nbsp;Result := Bool( SendMessage(hwnd, TVM_SORTCHILDRENCB, recurse,<br> &nbsp; &nbsp;Longint(@psort)) );<br>end;<br><br>function TreeView_EndEditLabelNow(hwnd: HWND; fCancel: Bool): Bool;<br>begin<br> &nbsp;Result := Bool( SendMessage(hwnd, TVM_ENDEDITLABELNOW, Integer(fCancel),<br> &nbsp; &nbsp;0) );<br>end;<br><br>function TreeView_GetISearchString(hwndTV: HWND; lpsz: PChar): Bool;<br>begin<br> &nbsp;Result := Bool( SendMessage(hwndTV, TVM_GETISEARCHSTRING, 0,<br> &nbsp; &nbsp;Longint(lpsz)) );<br>end;<br>function TreeView_GetISearchStringA(hwndTV: HWND; lpsz: PAnsiChar): Bool;<br>begin<br> &nbsp;Result := Bool( SendMessage(hwndTV, TVM_GETISEARCHSTRING, 0,<br> &nbsp; &nbsp;Longint(lpsz)) );<br>end;<br>function TreeView_GetISearchStringW(hwndTV: HWND; lpsz: PWideChar): Bool;<br>begin<br> &nbsp;Result := Bool( SendMessage(hwndTV, TVM_GETISEARCHSTRING, 0,<br> &nbsp; &nbsp;Longint(lpsz)) );<br>end;<br><br>function TreeView_SetToolTips(wnd: HWND; hwndTT: HWND): HWND;<br>begin<br> &nbsp;Result := HWND(SendMessage(wnd, TVM_SETTOOLTIPS, WPARAM(hwndTT), 0));<br>end;<br><br>function TreeView_GetToolTips(wnd: HWND): HWND;<br>begin<br> &nbsp;Result := HWND(SendMessage(wnd, TVM_GETTOOLTIPS, 0, 0));<br>end;<br><br>function TreeView_SetInsertMark(hwnd: HWND; hItem: Integer; fAfter: BOOL): BOOL;<br>begin<br> &nbsp;Result := BOOL(SendMessage(hwnd, TVM_SETINSERTMARK, WPARAM(fAfter), LPARAM(hItem)));<br>end;<br><br>function TreeView_SetUnicodeFormat(hwnd: HWND; fUnicode: BOOL): BOOL;<br>begin<br> &nbsp;Result := BOOL(SendMessage(hwnd, TVM_SETUNICODEFORMAT, WPARAM(fUnicode), 0));<br>end;<br><br>function TreeView_GetUnicodeFormat(hwnd: HWND): BOOL;<br>begin<br> &nbsp;Result := BOOL(SendMessage(hwnd, TVM_GETUNICODEFORMAT, 0, 0));<br>end;<br><br>function TreeView_SetItemHeight(hwnd: HWND; iHeight: Integer): Integer;<br>begin<br> &nbsp;Result := SendMessage(hwnd, TVM_SETITEMHEIGHT, iHeight, 0);<br>end;<br><br>function TreeView_GetItemHeight(hwnd: HWND): Integer;<br>begin<br> &nbsp;Result := SendMessage(hwnd, TVM_GETITEMHEIGHT, 0, 0);<br>end;<br><br>function TreeView_SetBkColor(hwnd: HWND; clr: COLORREF): COLORREF;<br>begin<br> &nbsp;Result := COLORREF(SendMessage(hwnd, TVM_SETBKCOLOR, 0, LPARAM(clr)));<br>end;<br><br>function TreeView_SetTextColor(hwnd: HWND; clr: COLORREF): COLORREF;<br>begin<br> &nbsp;Result := COLORREF(SendMessage(hwnd, TVM_SETTEXTCOLOR, 0, LPARAM(clr)));<br>end;<br><br>function TreeView_GetBkColor(hwnd: HWND): COLORREF;<br>begin<br> &nbsp;Result := COLORREF(SendMessage(hwnd, TVM_GETBKCOLOR, 0, 0));<br>end;<br><br>function TreeView_GetTextColor(hwnd: HWND): COLORREF;<br>begin<br> &nbsp;Result := COLORREF(SendMessage(hwnd, TVM_GETTEXTCOLOR, 0, 0));<br>end;<br><br>function TreeView_SetScrollTime(hwnd: HWND; uTime: UINT): UINT;<br>begin<br> &nbsp;Result := SendMessage(hwnd, TVM_SETSCROLLTIME, uTime, 0);<br>end;<br><br>function TreeView_GetScrollTime(hwnd: HWND): UINT;<br>begin<br> &nbsp;Result := SendMessage(hwnd, TVM_GETSCROLLTIME, 0, 0);<br>end;<br><br>function TreeView_SetInsertMarkColor(hwnd: HWND; clr: COLORREF): COLORREF;<br>begin<br> &nbsp;Result := COLORREF(SendMessage(hwnd, TVM_SETINSERTMARKCOLOR, 0, LPARAM(clr)));<br>end;<br><br>function TreeView_GetInsertMarkColor(hwnd: HWND): COLORREF;<br>begin<br> &nbsp;Result := COLORREF(SendMessage(hwnd, TVM_GETINSERTMARKCOLOR, 0, 0));<br>end;
 
这些API要怎么才能调用呀
 
function TreeView_GetNextSibling(hwnd: HWND; hitem: HTreeItem): HTreeItem;<br>begin<br> &nbsp;Result := TreeView_GetNextItem(hwnd, hitem, TVGN_NEXT);<br>end;
 
自已搞定了<br><br>zqw0117的方法没去试
 
后退
顶部