gpt4 book ai didi

winapi - Windows 10 中的 Win32 工具提示灰线错误

转载 作者:行者123 更新时间:2023-12-01 16:15:40 29 4
gpt4 key购买 nike

自 Windows XP 时代以来,我们多年来一直在使用旧版 VB6 组件中创建经典 Win32 多行工具提示的代码。它在除 Windows 10 之外的所有最新版本的 MS Windows(7、8.1)中运行良好。此操作系统的工具提示中会出现一条寄生水平灰线。此问题的最佳演示是包含多行文本的工具提示窗口(主要提示文本是多行和/或工具提示具有粗体标题):

enter image description here

正确的工具提示应如下所示(Windows 8.1 的屏幕):

enter image description here

下面是当工具提示窗口没有图 block /图标但仅包含多行文本时同一问题的另一个示例:

enter image description here

这条寄生灰线也出现在单行工具提示中 - 尽管乍一看并不明显:

enter image description here

可能是什么?这是 Windows 10 中的错误,还是工具提示 API 中发生了某些变化?

<小时/>

下面是用于初始化工具提示的方法的代码:

Public Function Create(ByVal ParentHwnd As Long) As Boolean
Dim lWinStyle As Long

If m_lTTHwnd <> 0 Then
DestroyWindow m_lTTHwnd
End If

m_lParentHwnd = ParentHwnd

lWinStyle = TTS_ALWAYSTIP Or TTS_NOPREFIX

m_lTTHwnd = CreateWindowExA(0&, _
TOOLTIPS_CLASS, _
vbNullString, _
lWinStyle, _
CW_USEDEFAULT, _
CW_USEDEFAULT, _
CW_USEDEFAULT, _
CW_USEDEFAULT, _
0&, _
0&, _
App.hInstance, _
0&)

'now set our tooltip info structure
Dim tiA As TOOLINFOA
Dim tiW As TOOLINFOW
If g_bIsNt Then
With tiW
.lSize = Len(tiW)
.lFlags = TTF_SUBCLASS Or TTF_IDISHWND
.hWnd = m_lParentHwnd
.lId = m_lParentHwnd '0
.hInstance = App.hInstance
.lpStr = StrPtr(mvarTipText)
End With
Else
With tiA
.lSize = Len(tiA)
.lFlags = TTF_SUBCLASS Or TTF_IDISHWND
.hWnd = m_lParentHwnd
.lId = m_lParentHwnd
.hInstance = App.hInstance
.lpStr = mvarTipText
End With
End If

'add the tooltip structure
If g_bIsNt Then
SendMessage m_lTTHwnd, TTM_ADDTOOLW, 0&, tiW
Else
SendMessage m_lTTHwnd, TTM_ADDTOOLA, 0&, tiA
End If

'if we want a title or we want an icon
If mvarTitle <> vbNullString Or mvarIcon <> igToolTipIconNone Then
If g_bIsNt Then
SendMessage m_lTTHwnd, TTM_SETTITLEW, mvarIcon, ByVal StrPtr(mvarTitle)
Else
SendMessage m_lTTHwnd, TTM_SETTITLEA, mvarIcon, ByVal mvarTitle
End If
End If

' set the time parameters
SendMessageByLongA m_lTTHwnd, TTM_SETDELAYTIME, TTDT_AUTOPOP, mvarVisibleTime
SendMessageByLongA m_lTTHwnd, TTM_SETDELAYTIME, TTDT_INITIAL, mvarDelayTime

'according to MSDN, we should set TTM_SETMAXTIPWIDTH to a positive value
'to enable multiline tooltips
SendMessageByLongA m_lTTHwnd, TTM_SETMAXTIPWIDTH, 0, 100000
End Function

最佳答案

为了解决这个问题,我们不应该设置TOOLINFO结构的hwnd字段。相应的代码部分应如下所示:

'now set our tooltip info structure
Dim tiA As TOOLINFOA
Dim tiW As TOOLINFOW
If g_bIsNt Then
With tiW
.lSize = Len(tiW)
.lFlags = TTF_SUBCLASS Or TTF_IDISHWND
.lId = m_lParentHwnd
.hInstance = App.hInstance
.lpStr = StrPtr(mvarTipText)
End With
Else
With tiA
.lSize = Len(tiA)
.lFlags = TTF_SUBCLASS Or TTF_IDISHWND
.lId = m_lParentHwnd
.hInstance = App.hInstance
.lpStr = mvarTipText
End With
End If

关于winapi - Windows 10 中的 Win32 工具提示灰线错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33300349/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com