在一个treeview控件中有若干item,已知treeview和各个item的句柄,如何能得到所选中的item的位置坐标
解决方案 »
- EM_CHARFROMPOS的说明?
- 郁闷最近改进了一下藏拙分词,词库有400万词汇!5000字的文章完全切分居然需要 接近1秒钟的时间!
- 如何将远程数据库表的内容某条的记录写到本地数据库相同的表中?
- 散分,送源码,郁闷~~~
- 关于设置DATAGRID空间单元格里的内容的问题,搞不懂,郁闷中……
- 我用excel连接两个外部数据生成报表,当地一个外部数据引入的时候第二个要紧接着它插入数据,那么destination怎么动态的得到呢?
- 一运行就保错误“5003”,是什么原因呀?
- 请教response.wrie输出的格式问题,拜托了!!1
- VB下的控件开发,很急!!!很急!! 200分送上
- SHELL的一个小问题,希望回答,谢谢大家!
- 请教写可以返回集合的方法
- 做安装程序时,想将excel表打进包,我用的是setup factory,问怎么能安装成功?
TVM_GETITEMRECT
wParam = (WPARAM) (BOOL) fItemRect;
lParam = (LPARAM) (LPRECT) prc; Retrieves the bounding rectangle for a tree view item and indicates whether the item is visible. You can send this message explicitly or by using the TreeView_GetItemRect macro. If the item is visible and the bounding rectangle was successfully retrieved, the return value is TRUE. Otherwise, the message returns FALSE and does not retrieve the bounding rectangle.
fItemRect
Value specifying the portion of the item for which to retrieve the bounding rectangle. If this parameter is TRUE, the bounding rectangle includes only the text of the item. Otherwise, it includes the entire line that the item occupies in the tree view control.
prc
Address of aRECT structure that, when sending the message, contains the handle of the item to retrieve the rectangle for. See the example below for more information on how to place the item handle in this parameter. After returning from the message, this parameter contains the bounding rectangle. The coordinates are relative to the upper-left corner of the tree view control.
When sending this message, the prc parameter contains the handle of the item that the rectangle is being retrieved for. The handle is placed in prc as shown in the following example: RECT rc;
*(HTREEITEM*)&rc = hTreeItem;
SendMessage(hwndTreeView, TVM_GETITEMRECT, FALSE, (LPARAM)&rc);
dim rc as RECTrc.Left=item的句柄
call SendMessage(hwndTreeView, TVM_GETITEMRECT, FALSE, rc)
Messages
TVM_CREATEDRAGIMAGE
TVM_DELETEITEM
TVM_EDITLABEL
TVM_ENDEDITLABELNOW
TVM_ENSUREVISIBLE
TVM_EXPAND
TVM_GETBKCOLOR
TVM_GETCOUNT
TVM_GETEDITCONTROL
TVM_GETIMAGELIST
TVM_GETINDENT
TVM_GETINSERTMARKCOLOR
TVM_GETISEARCHSTRING
TVM_GETITEM
TVM_GETITEMHEIGHT
TVM_GETITEMRECT
TVM_GETNEXTITEM
TVM_GETSCROLLTIME
TVM_GETTEXTCOLOR
TVM_GETTOOLTIPS
TVM_GETUNICODEFORMAT
TVM_GETVISIBLECOUNT
TVM_HITTEST
TVM_INSERTITEM
TVM_SELECTITEM
TVM_SETBKCOLOR
TVM_SETIMAGELIST
TVM_SETINDENT
TVM_SETINSERTMARK
TVM_SETINSERTMARKCOLOR
TVM_SETITEM
TVM_SETITEMHEIGHT
TVM_SETSCROLLTIME
TVM_SETTEXTCOLOR
TVM_SETTOOLTIPS
TVM_SETUNICODEFORMAT
TVM_SORTCHILDREN
TVM_SORTCHILDRENCB
Utility Macros
TreeView_CreateDragImage
TreeView_DeleteAllItems
TreeView_DeleteItem
TreeView_EditLabel
TreeView_EndEditLabelNow
TreeView_EnsureVisible
TreeView_Expand
TreeView_GetBkColor
TreeView_GetChild
TreeView_GetCount
TreeView_GetDropHilight
TreeView_GetEditControl
TreeView_GetFirstVisible
TreeView_GetImageList
TreeView_GetIndent
TreeView_GetInsertMarkColor
TreeView_GetISearchString
TreeView_GetItem
TreeView_GetItemHeight
TreeView_GetItemRect
TreeView_GetLastVisible
TreeView_GetNextItem
TreeView_GetNextSibling
TreeView_GetNextVisible
TreeView_GetParent
TreeView_GetPrevSibling
TreeView_GetPrevVisible
TreeView_GetRoot
TreeView_GetScrollTime
TreeView_GetSelection
TreeView_GetTextColor
TreeView_GetToolTips
TreeView_GetUnicodeFormat
TreeView_GetVisibleCount
TreeView_HitTest
TreeView_InsertItem
TreeView_Select
TreeView_SelectDropTarget
TreeView_SelectItem
TreeView_SelectSetFirstVisible
TreeView_SetBkColor
TreeView_SetImageList
TreeView_SetIndent
TreeView_SetInsertMark
TreeView_SetInsertMarkColor
TreeView_SetItem
TreeView_SetItemHeight
TreeView_SetScrollTime
TreeView_SetTextColor
TreeView_SetToolTips
TreeView_SetUnicodeFormat
TreeView_SortChildren
TreeView_SortChildrenCB
wParam = 0;
lParam = (LPARAM) (LPTVITEM) pitem; Retrieves some or all of a tree view item's attributes. You can send this message explicitly or by using the TreeView_GetItem macro. Returns TRUE if successful, or FALSE otherwise.
pitem
Address of a TVITEM structure that specifies the information to retrieve and receives information about the item. When the message is sent, the hItem member identifies the item to retrieve information about and the mask member specifies the attributes to retrieve.
If the mask member specifies the TVIF_TEXT value, the pszText member must contain the address of the buffer that receives the item text and the cchTextMax member must specify the size of the buffer.
If the mask member specifies the TVIF_STATE value, the stateMask member must specify the item state bits to retrieve. On output, the state member contains the values of the specified state bits. TVITEM
typedef struct tagTVITEM{
UINT mask;
HTREEITEM hItem;
UINT state;
UINT stateMask;
LPTSTR pszText;
int cchTextMax;
int iImage;
int iSelectedImage;
int cChildren;
LPARAM lParam;
} TVITEM, FAR *LPTVITEM;Specifies or receives attributes of a tree view item. This structure is identical to the TV_ITEM structure, but it has been renamed to follow current naming conventions. New applications should use this structure. mask
Array of flags that indicate which of the other structure members contain valid data. When this structure is used with the TVM_GETITEM message, the mask member indicates the item attributes to retrieve. This member can be one or more of the following values: TVIF_CHILDREN The cChildren member is valid.
TVIF_HANDLE The hItem member is valid.
TVIF_IMAGE The iImage member is valid.
TVIF_PARAM The lParam member is valid.
TVIF_SELECTEDIMAGE The iSelectedImage member is valid.
TVIF_STATE The state and stateMask members are valid.
TVIF_TEXT The pszText and cchTextMax members are valid. hItem
Identifies the item to which this structure refers.
state
A set of bit flags and image list indexes that indicate the item's state. When setting the state of an item, the stateMask member indicates the bits of this member that are valid. When retrieving the state of an item, this member returns the current state for the bits indicated in the stateMask member.
Bits 0 through 7 of this member contain the item state flags. For a list of possible item state flags, see Tree View Control Item States. Bits 8 through 11 of this member specify the one-based overlay image index. The overlay image is superimposed over the item's icon image. If these bits are zero, the item has no overlay image. To isolate these bits, use the TVIS_OVERLAYMASK mask. To set the overlay image index in this member, you should use the INDEXTOOVERLAYMASK macro. The image list's overlay images are set with the ImageList_SetOverlayImage function. Bits 12 through 15 of this member specify the state image index. The state image is displayed next to an item's icon to indicate an application-defined state. If these bits are zero, the item has no state image. To isolate these bits, use the TVIS_STATEIMAGEMASK mask. To set the state image index, you should use the INDEXTOSTATEIMAGEMASK macro. The state image index specifies the index of the image in the state image list that should be drawn. The state image list is specified with the TVM_SETIMAGELIST message. stateMask
Bits of the state member that are valid. If you are retrieving an item's state, set the bits of the stateMask member to indicate the bits to be returned in the state member. If you are setting an item's state, set the bits of the stateMask member to indicate the bits of the state member that you want to set. To set or retrieve an item's overlay image index, set the TVIS_OVERLAYMASK bits. To set or retrieve an item's state image index, set the TVIS_STATEIMAGEMASK bits.
pszText
Address of a null-terminated string that contains the item text if the structure specifies item attributes. If this member is the LPSTR_TEXTCALLBACK value, the parent window is responsible for storing the name. In this case, the tree view control sends the parent window a TVN_GETDISPINFO notification message when it needs the item text for displaying, sorting, or editing and a TVN_SETDISPINFO notification message when the item text changes.
If the structure is receiving item attributes, this member is the address of the buffer that receives the item text.
cchTextMax
Size of the buffer pointed to by the pszText member, in characters. If this structure is being used to set item attributes, this member is ignored.
iImage
Index in the tree view control's image list of the icon image to use when the item is in the nonselected state.
If this member is the I_IMAGECALLBACK value, the parent window is responsible for storing the index. In this case, the tree view control sends the parent a TVN_GETDISPINFO notification message to get the index when it needs to display the image.
iSelectedImage
Index in the tree view control's image list of the icon image to use when the item is in the selected state.
If this member is the I_IMAGECALLBACK value, the parent window is responsible for storing the index. In this case, the tree view control sends the parent a TVN_GETDISPINFO notification message to get the index when it needs to display the image.
cChildren
Flag that indicates whether the item has associated child items. This member can be one of the following values: zero The item has no child items.
one The item has one or more child items.
I_CHILDRENCALLBACK The parent window keeps track of whether the item has child items. In this case, when the tree view control needs to display the item, the control sends the parent a TVN_GETDISPINFO notification message to determine whether the item has child items.
If the tree view control has the TVS_HASBUTTONS style, it uses this member to determine whether to display the button indicating the presence of child items. You can use this member to force the control to display the button even though the item does not have any child items inserted. This allows you to display the button while minimizing the control's memory usage by inserting child items only when the item is visible or expanded. lParam
A 32-bit value to associate with the item.
Private Sub Command1_Click()
MsgBox TreeView1.SelectedItem.Text
End Sub
http://www.mvps.org/btmtz/treeview/tvduplicateex.zip