开发者

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."

Question: Where i开发者_开发百科s this default feature [i.e. whenever the item is cutoff, auto show tooltip of the title] of the CTreeCtrl actually implemented in the MFC code (e.g. which file)?

Thanks


The tooltip is inherent in the Win32 Tree Control. The CTreeCtrl is a simple wrapper. The only place to find the code for that is from Microsoft.


It should be relatively straightforward to implement this.

Capture mouse move in treectrl (OnMouseMove)

  1. Get current cursor position
  2. Get item under cursor (treectrl.HitTest)
  3. Get item's display rect (treectrl.GetItemRect)
  4. Get treectrl's display rect (treectrl.GetClientRect)
  5. If right side of item's display rect > treectrl's display rect --> 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)

Dunno if this helps. I do a very similar thing in an MFC app to do specialist highlighting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜