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

望指点!谢谢!



[ 本帖最后由 nhhykly9d 于 2010-10-15 10:06 编辑 ]
搜索更多相关主题的帖子: 结点 鼠标 treeview 文本 
2010-10-15 09:37
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
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
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
nhhykly9d
Rank: 1
等 级:新手上路
帖 子:30
专家分:5
注 册:2008-1-4
收藏
得分:0 
本问题可以如上法解决,虽然并没有达到禁止tooltip显示,但避免了显示treeview结点文本引起的烦恼.

1,属性中设置:ShowNodeToolTips=True
2,必须把每个已存在的结点和动态生成的结点赋予:currentnode.ToolTipText=""

这样只显示一个很小的tooltip框,不显示结点文本。




[ 本帖最后由 nhhykly9d 于 2010-10-20 23:23 编辑 ]
2010-10-20 22:09
nhhykly9d
Rank: 1
等 级:新手上路
帖 子:30
专家分:5
注 册:2008-1-4
收藏
得分:0 
下面这个达到我理想的解决方案
在VB2005下运行
1,属性中ShowNodeTooltips=false
2,
   Private Declare Function SetWindowLong Lib "user32" _
     Alias "SetWindowLongA" (ByVal hwnd As Integer, ByVal nIndex As Integer, _
     ByVal dwNewLong As Integer) As Integer
    Private Declare Function GetWindowLong Lib "user32" _
     Alias "GetWindowLongA" (ByVal hwnd As Integer, ByVal nIndex As Integer) _
     As Integer
    Private Const TVS_NOTOOLTIPS = &H80
    Private Const GWL_STYLE = (-16)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim dwStyle As integer
        dwStyle = GetWindowLong(TreeView1.Handle.ToInt32, GWL_STYLE)
        If (dwStyle And TVS_NOTOOLTIPS) = False Then
            Call SetWindowLong(TreeView1.Handle.ToInt32, GWL_STYLE, _
            dwStyle Or TVS_NOTOOLTIPS)
        End If
   End Sub

这样完全禁止了鼠标经过treeview结点时tooltip的显示。可以结帖了!


[ 本帖最后由 nhhykly9d 于 2010-10-20 23:34 编辑 ]
2010-10-20 23:22
快速回复:禁止鼠标指向treeview结点时显示结点文本
数据加载中...
 
   



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

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