简体   繁体   English

如果整个标题当前不可见,MFC的CTreeCtrl如何自动显示包含该标题的工具提示?

[英]How does MFC's CTreeCtrl automatically displays a tool tip, containing the title of the item, if the entire title is not currently visible?

Background http://msdn.microsoft.com/en-us/library/b17bescz(v=VS.90).aspx "The TVS_NOTOOLTIPS style disables the automatic tool tip feature of tree view controls. This feature automatically displays a tool tip, containing the title of the item under the mouse cursor, if the entire title is not currently visible." 背景http://msdn.microsoft.com/zh-cn/library/b17bescz(v=VS.90).aspx “ TVS_NOTOOLTIPS样式禁用了树状视图控件的自动工具提示功能。此功能会自动显示工具提示,如果整个标题当前不可见,则包含该项目的标题。”

Question: Where is this default feature [ie whenever the item is cutoff, auto show tooltip of the title] of the CTreeCtrl actually implemented in the MFC code (eg which file)? 问题:实际上在MFC代码(例如哪个文件)中实现的CTreeCtrl的默认功能(即,每当项目被切除时,标题的自动显示工具提示)在哪里?

Thanks 谢谢

The tooltip is inherent in the Win32 Tree Control. 该工具提示是Win32 Tree Control中固有的。 The CTreeCtrl is a simple wrapper. CTreeCtrl是一个简单的包装器。 The only place to find the code for that is from Microsoft. 唯一找到该代码的地方是从Microsoft。

It should be relatively straightforward to implement this. 实现它应该相对简单。

Capture mouse move in treectrl (OnMouseMove) 捕获鼠标在treectrl中的移动(OnMouseMove)

  1. Get current cursor position 获取当前光标位置
  2. Get item under cursor (treectrl.HitTest) 获取光标下的项目(treectrl.HitTest)
  3. Get item's display rect (treectrl.GetItemRect) 获取项目的显示矩形(treectrl.GetItemRect)
  4. Get treectrl's display rect (treectrl.GetClientRect) 获取treectrl的显示矩形(treectrl.GetClientRect)
  5. If right side of item's display rect > treectrl's display rect --> SHOW TOOLTIP AT (item.left, item.top) 如果项目的显示矩形的右侧> treectrl的显示矩形-> SHOW TOOLTIP AT(item.left,item.top)
  6. If left side of item's display rect < treectrl's display rect --> SHOW TOOLTIP AT (treectrl.left, item.top) 如果项目的显示区域rect <treectrl的显示区域-> SHOW TOOLTIP AT(treectrl.left,item.top)

Dunno if this helps. 邓诺,如果有帮助。 I do a very similar thing in an MFC app to do specialist highlighting. 我在MFC应用程序中做了非常类似的事情来进行专家突出显示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM