| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3418 人关注过本帖
标题:禁止鼠标指向treeview结点时显示结点文本
只看楼主 加入收藏
nhhykly9d
Rank: 1
等 级:新手上路
帖 子:30
专家分:5
注 册:2008-1-4
收藏
 问题点数:0 回复次数:11 
禁止鼠标指向treeview结点时显示结点文本
每当把鼠标放在treeview结点上时,会自动出现一个框并显示本结点的文本内容,我想关闭这一功能。
注意:我这里不是说的tooltip显示,我的ShowToolTip设置为false的。
要禁止的是它显的结点的文本。

望指点!谢谢!



[ 本帖最后由 nhhykly9d 于 2010-10-15 10:06 编辑 ]
搜索更多相关主题的帖子: 结点 鼠标 treeview 文本 
2010-10-15 09:37
W11400661
Rank: 8Rank: 8
来 自:达拉达斯
等 级:蝙蝠侠
威 望:2
帖 子:163
专家分:834
注 册:2008-10-12
收藏
得分:0 
抓个图看看,实在没明白!
2010-10-15 18:23
Artless
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:103
帖 子:4211
专家分:28888
注 册:2009-4-8
收藏
得分:0 
代码别人写的?

无知
2010-10-16 00:42
nhhykly9d
Rank: 1
等 级:新手上路
帖 子:30
专家分:5
注 册:2008-1-4
收藏
得分:0 

以下是引用W11400661在2010-10-15 18:23:27的发言:


抓个图看看,实在没明白!
图片附件: 游客没有浏览图片的权限,请 登录注册


我用的是VB2005
我又重新测试了一下,一个简单的例子:我新建一个treeview,框很狭窄,而结点文本很长,超过了treeview框的宽度。这时鼠标指向它时就会自动显示出一个小框,文本也显示出来了.我现在就是要禁止它显示出来。没有添加任何事件,也没有改属性。
如果我的鼠标指向“结点1”或指向“tttttttttttt”并点击它,只会产生变色。
但鼠标指身结点"gdgadgdddgsdgdgddgdgddgdgdgdgdgdgdgdgdgdgdgggg"时,就显示一个小框,
上面的“gdgdgddgasdgsddgdgdddasdgddsasddgdgddgsdgasddgdgd”就是我想禁止它出现的。这不是tooltip.

[ 本帖最后由 nhhykly9d 于 2010-10-17 22:33 编辑 ]
2010-10-17 22:22
bczgvip
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:66
帖 子:1310
专家分:5312
注 册:2009-2-26
收藏
得分:0 
好像是 "TVS_NOTOOLTIPS" 吧
2010-10-17 22:40
nhhykly9d
Rank: 1
等 级:新手上路
帖 子:30
专家分:5
注 册:2008-1-4
收藏
得分:0 
回复 3楼 Artless
是自己做的一个工程里遇到的问题。因为我每个结点的文本都是超长,我不想让鼠标每次划过结点时都显示一个框,并显示结点文本。只是一个另类的要求。


感觉是treeview内置了鼠标划过结点时显示结点文本内容这个功能,要改变它比较难。找不到解决方法。
2010-10-17 22:40
nhhykly9d
Rank: 1
等 级:新手上路
帖 子:30
专家分:5
注 册:2008-1-4
收藏
得分:0 
以下是引用bczgvip在2010-10-17 22:40:27的发言:

好像是 "TVS_NOTOOLTIPS" 吧
我用的是VB2005,我的属性里没有这个tvs_NOTOOLTIPS这个设置,或者我根本不知在哪里可以设置这个TVS_NOTOOLTIPS。请明示!谢谢!

是不是先用GetWindowEX得到工程中TreeView1的HWND,然后再用SetWindowLong,改变TreeView的Style为TVS_NOTOOLTIPS,在中这个我确实不会做.请给出解决方法.

下面这个附件是我做来玩的小东东,让大家分享.运行环境: .NET framework 2.0  或3.5
TXTPAD.zip (349.35 KB)




[ 本帖最后由 nhhykly9d 于 2010-10-17 23:56 编辑 ]
2010-10-17 22:43
nhhykly9d
Rank: 1
等 级:新手上路
帖 子:30
专家分:5
注 册:2008-1-4
收藏
得分:0 
网上外国人也有同样的问题,...
Treeview mouseover tooltip type textAsked by salinasj in Visual Basic Programming
Tags: treeview, tooltip
using a treeview where the nodes are wider than the width of the treeview component, when you mouseover, it displays a tooltip-type msg containing the whole text of the node, ie:

|<---------->|
+--This is a

when u mouseover, it displays "This is a test line"
the problem with this, is the treeview component has at least 16 parent nodes, and when you mouseover them, that stupid little box appears as you mouseover each node.  Well, if you are moving your mouse at an average speed, it seems to temporarily erase nodes underneath the box, and then repaints them... is there any way to prevent the boxes from appearing at all or making it so that you have to hover for at least half a sec before it appears?


Hi Matthis:

Here's what I use (and works) for the Treeview:

Public Sub ResetTreeViewToolTips(TreeView1 As TreeView)
Dim dwStyle As Long

' Get the TreeView's window style
dwStyle = GetWindowLong(TreeView1.hWnd, GWL_STYLE)

' If the TreeView does not have the TVS_NOTOOLTIPS bit set,
' set it, removing and destroying the TreeView's tooltip window.
If (dwStyle And TVS_NOTOOLTIPS) = False Then
Call SetWindowLong(TreeView1.hWnd, GWL_STYLE, _
dwStyle Or TVS_NOTOOLTIPS)
End If

' Tell the TreeView to create a new tooltip window, whose parent
' window will now become the top level client app window
Call SetWindowLong(TreeView1.hWnd, GWL_STYLE, _
dwStyle And Not TVS_NOTOOLTIPS)
End Sub

Notice that the "OR" is called first, then the "And Not"; the code you
posted is reversed.

Hope that works for you.

上面这个应是在VB6下运行,能不能改写成在VB2005下运行的代码
有没有在 下的解决方案


[ 本帖最后由 nhhykly9d 于 2010-10-18 01:28 编辑 ]
2010-10-18 01:15
dhwangsun
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-3-13
收藏
得分:0 
我也遇到过类似的问题,请各位高手指教!
2010-10-18 10:44
nhhykly9d
Rank: 1
等 级:新手上路
帖 子:30
专家分:5
注 册:2008-1-4
收藏
得分:0 
Windows Forms Application Crashes When Calling ToolTip.SetToolTip Method for Associated TreeView control

You have developed a Microsoft .NET Framework 2.0 Windows Forms application which contains a ToolTip control and a Treeview control. The application calls the ToolTip control’s SetToolTip method multiple times, for example, in the MouseMove event of the TreeView Control; and passes the Treeview control as the first parameter to the SetToolTip method.

When hovering the mouse over a Node in the TreeView control, the ToolTip may not display all the text specified in the SetToolTip method. When exiting the application, you may also receive the following error:

Unhandled exception has occurred in your application. If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will close immediately.

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at System.Environment.GetResourceFromDefault(String key)
   at System.ObjectDisposedException..ctor(String objectName)
   at System.Windows.Forms.Control.DestroyHandle()
   at System.Windows.Forms.Control.Dispose(Boolean disposing)
   at System.Windows.Forms.Form.Dispose(Boolean disposing)
   at WindowsFormsApplication1.Form1.Dispose(Boolean disposing) in C:\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form1.Designer.cs:line 20
   at ()
   at System.Windows.Forms.Form.WmClose(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

If you are debugging the application in Visual Studio, you may receive the following MDA error when exiting instead of the System.AccessViolationException above.  

FatalExecutionEngineError was detected

The runtime has encountered a fatal error. The address of the error was at <address>, on thread <thread>. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

reserlution:
You can use one of the following solutions to work around this problem.

1. Set the TreeView control's ShowNodeToolTips property to False. This is the easiest solution if the intent is to use the ToolTip control for displaying ToolTips instead of the TreeView control's built-in Node ToolTips (the ToolTip control has some additional features not exposed by the TreeView control's ToolTip implementation).

2. Alternatively, you can remove the call to the ToolTip control's SetToolTip method, and use the TreeView control's built-in ToolTips. To do this, you must make sure that the TreeView control's ShowNodeToolTips property is set to True, and that you have set each TreeNode's ToolTipText property to the desired value.
2010-10-20 21:53
快速回复:禁止鼠标指向treeview结点时显示结点文本
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019596 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved