Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#737 closed Bug (No Bug)

GuiCtrlCreateTabItem with Tooltips: not all tabs send WM_NOTIFY; wrong tooltips

Reported by: wraithdu Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Cc:


In the below example tabs 5-7 do not send the WM_NOTIFY message and display the wrong tooltips.

#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GUITab.au3>
#include <GUITooltip.au3>

$Form2 = GUICreate("Programs", 472, 348, 226, 125)
$Tab1 = GUICtrlCreateTab(0, 0, 465, 321)

; Create Tooltiop control
Global Const $TABHANDLE = GUICtrlGetHandle($Tab1)
$hToolTip = _GUIToolTip_Create($TABHANDLE)
; end create

$TabSheet1 = GUICtrlCreateTabItem("Main")
_GUIToolTip_AddTool($hToolTip,$TABHANDLE,"tab1", $TabSheet1)
$TabSheet2 = GUICtrlCreateTabItem("Black Listed")
_GUIToolTip_AddTool($hToolTip,$TABHANDLE,"tab2", $TabSheet2)
$TabSheet3 = GUICtrlCreateTabItem("StartUp Items")
_GUIToolTip_AddTool($hToolTip,$TABHANDLE,"tab3", $TabSheet3)
$TabSheet4 = GUICtrlCreateTabItem("Task Manager")
_GUIToolTip_AddTool($hToolTip,$TABHANDLE,"tab4", $TabSheet4)
$TabSheet5 = GUICtrlCreateTabItem("Scan USB")
_GUIToolTip_AddTool($hToolTip,$TABHANDLE,"tab5", $TabSheet5)
$TabSheet6 = GUICtrlCreateTabItem("Pc Info")
_GUIToolTip_AddTool($hToolTip,$TABHANDLE,"tab6", $TabSheet6)
$TabSheet7 = GUICtrlCreateTabItem("About")
_GUIToolTip_AddTool($hToolTip,$TABHANDLE,"tab7", $TabSheet7)


;End Define Tooltips


While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE

; Prog@ndy
Func TOOL_WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam)
    Local $tagNMTTDISPINFOA = "hwnd hWndFrom;int IDFrom;int Code;ptr lpszText;char szText[80];hwnd hinst;uint uFlags;"
    Local $tagNMTTDISPINFOW = "hwnd hWndFrom;int IDFrom;int Code;ptr lpszText;wchar szText[80];hwnd hinst;uint uFlags;"
    Local $NMHDR = DllStructCreate($tagNMTTDISPINFOW, $lParam)
    Local $hWndFrom = DllStructGetData($NMHDR, 1)
    Local $IdFrom = DllStructGetData($NMHDR, 2)
    Local $Event = DllStructGetData($NMHDR, 3)
    Switch $Event
            If $TTN_GETDISPINFO == $Event Then $NMHDR = DllStructCreate($tagNMTTDISPINFOA, $lParam) ; For ANSI
            If $hwndFrom == $hToolTip Then
                Local $param = _GUICtrlTab_GetItemParam($TABHANDLE, $IdFrom)
		Local $text = _GUIToolTip_GetText($hwndFrom, $TABHANDLE, $param)
                ConsoleWrite("tab: " & $IdFrom & ",  param: " & $param & @CRLF)
                ConsoleWrite("text: " & $text & @CRLF)
                DllStructSetData($NMHDR, "szText", $text & Chr(0))
            Return 0
EndFunc   ;==>TOOL_WM_NOTIFY

Attachments (0)

Change History (4)

comment:1 Changed 15 years ago by Valik

  • Resolution set to No Bug
  • Status changed from new to closed

You don't really understand what's going on here. The whole point of the ToolTip stuff is so you don't have to handle TTN_GETDISPINFO. When working correctly, it won't be called. The tab items you claim are broken are actually the only ones working right.

You first issue is that you are mixing AutoIt native and UDF GUI functionality. The second issue is you are trying to treat the value returned from GUICtrlCreateTabItem() as the control identifier. That is plain wrong. Tab items are referenced by index. The value AutoIt returns is not the index. The third issue is you are trying to use TTN_GETDISPINFO but are also trying to use tool registration.

Go back to the drawing board and re-design the code. It's wrong. I can't quite get it working correctly (I can't add a tool with an ID of 0 for some reason). But what you have is not how this is done and doesn't demonstrate any bugs in AutoIt or in any of the UDF's you are using.

comment:2 Changed 15 years ago by anonymous

Would you mind posting an example of what you have using non-UDF code? I can't seem to get anything like this to work -

$tab1 = GUICtrlCreateTabItem("tab1")
GUICtrlSetTip(-1, "tip text")

I've successfully done a full UDF version, but would like to see how it's supposed to be done without it. I can set a tooltip for the whole tab control, but that's not exactly what I'm after. Thanks again.

comment:3 Changed 15 years ago by wraithdu

That above was me. Here's the topic where this is being discussed, if you'd rather post a small example there. Again, thanks for the time and help, we all appreciate it.

comment:4 Changed 15 years ago by Valik

You can't do it with native AutoIt functions. That's why ticket #582 exists.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as closed The ticket will remain with no owner.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.