Jump to content

What's wrong with my ListView code, please?


Recommended Posts

I've been stuggling a long time trying to get a simple listview to work, but I keep failing.  After creating the list view items and setting their data to a string, the listview remans blank. There will be only one column, and each list items will contain nothing but a longish text string. Here's a runnable excerpt, and I also attached a zip file with the same contents. This seems like a very simple use of a list view, but I would like your help figuring out what's wrong. Thanks.

#AutoIt3Wrapper_UseX64=Y

;~ #include "_Dbug.au3"

#include <ButtonConstants.au3>
#include <ColorConstants.au3>
#include <FontConstants.au3>
#include <GuiButton.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>


AutoItSetOption("MustDeclareVars", 1)
AutoItSetOption("GUIOnEventMode", 1)
AutoItSetOption("WinTitleMatchMode", 1)
AutoItSetOption("GUICloseOnESC", 1 )
;
;
Const $eTitle = "Testing"
Local $iFontName = "Courier New", $iFontSize = 12, $iFontWeight = $FW_NORMAL, $iFontAttribs = $GUI_FONTNORMAL

Local $dStyle = BitOr($LVS_REPORT, $LVS_ALIGNLEFT, $LVS_SHOWSELALWAYS, $LVS_NOCOLUMNHEADER)
Local $dExStyle = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)

Local $iNumWins, $hWin, $iWinClass, $idDummy, $aPos[4], $aAcccel[3][2]
Local $iMoveThis, $iLeft, $iRight, $bMove, $iMoveTableIndex, $iNumLVItems
Local $sWinTitle, $iThisClassName, $iThisExtStyle, $iThisWinState, $iRetVal
Local $idThisID, $dExIndex, $sText, $ig_LVEindx, $hExHdl, $hLViewId

;
; Enter
;

Local $idMoveWinGUI = GUICreate("ListView Problems",647,414,-1,-1,BitOr($WS_POPUP,$WS_CAPTION, $WS_SYSMENU, _
                        $WS_DLGFRAME,$WS_POPUPWINDOW,$WS_VISIBLE),$WS_EX_TOPMOST)

Local $idAllBtn = GUICtrlCreateButton("All",188,9,60,30,-1,-1)
GUICtrlSetOnEvent(-1,"Ef_All")
GUICtrlSetFont(-1,12,400,0,"Courier New")
GUICtrlSetColor(-1,"0x008080")
Local $idNoneBtn = GUICtrlCreateButton("None",360,9,60,30,-1,-1)
GUICtrlSetOnEvent(-1,"Ef_None")
GUICtrlSetFont(-1,12,400,0,"Courier New")
GUICtrlSetColor(-1,"0x008080")
Local $idSizingLabel = GUICtrlCreateLabel("",8,60,602,253,-1,-1)
GUICtrlSetBkColor(-1,"-2")
Local $idMainRadioBtn = GUICtrlCreateRadio("To Main",208,337,83,20,$BS_CENTER,-1)
GUICtrlSetOnEvent(-1,"Ef_ToMain")
GUICtrlSetFont(-1,10,400,0,"Courier New")
GUICtrlSetColor(-1,"0x008080")
Local $idLview = GUICtrlCreateListView( "", 8, 60, 602, 253, $dStyle, $dExStyle)
GUIStartGroup()
Local $idAltRadioBtn = GUICtrlCreateRadio("To Alt",316,337,83,20,$BS_CENTER,-1)
GUICtrlSetOnEvent(-1,"Ef_ToAlt")
GUICtrlSetState(-1,BitOr($GUI_UNCHECKED,$GUI_SHOW,$GUI_ENABLE))
GUICtrlSetFont(-1,10,400,0,"Courier New")
GUICtrlSetColor(-1,"0x008080")
Local $idCancelBtn = GUICtrlCreateButton("Cancel",98,336,83,30,-1,-1)
GUICtrlSetOnEvent(-1,"Ef_Cancel")
GUICtrlSetFont(-1,10,400,0,"Courier New")
GUICtrlSetColor(-1,"0x008080")
GUICtrlSetBkColor(-1,"-2")
Local $idOkBtn = GUICtrlCreateButton("OK",459,336,83,30,-1,-1)
GUICtrlSetOnEvent(-1,"Ef_OK")
GUICtrlSetFont(-1,10,400,0,"Courier New")
GUICtrlSetColor(-1,"0x008080")
GUICtrlSetBkColor(-1,"-2")
GUIStartGroup()

GUISetState(@SW_SHOW)
GUICtrlSetState( $idMainRadioBtn, $GUI_CHECKED )
GUICtrlSetState( $idAltRadioBtn, $GUI_UNCHECKED )

$hLViewId = ControlGetHandle( $idMoveWinGUI, "", $idLview )

Local $iLViewFont = _WinAPI_CreateFont(14, 6, 0, 0, $FW_NORMAL, False, False, False, $DEFAULT_CHARSET, _
                        $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $PROOF_QUALITY, $FF_MODERN, "Courier New" )

$iRetVal = GUICtrlSetFont( $idLview, $iFontSize, $iFontWeight, $GUI_FONTNORMAL, $iFontName, $PROOF_QUALITY )

Local $aidListItem[$iMoveTableIndex +1][4]
$bMove = True

$iNumLVItems = 0
For $i = 0 To $iMoveTableIndex -1

    $sText = "This Is A Somewhat Long String (" & $i & ")"
    $idThisID = GUICtrlCreateListViewItem( $sText, $idLview )
    If ($idThisID = 0) Or ($idThisID = "") Then
        MsgBox($MB_OK + $MB_TOPMOST, $eTitle, "Error from GUICtrlCreateListViewItem()")
        Exit -1
    EndIf

    $iRetVal = _GUICtrlListView_SetColumnWidth( $idThisID, 0, 600 )     ; ALWAYS Fails. Why?

    $iRetVal = GUICtrlSetData( $idThisID, $sText )
    $iRetVal = GUICtrlSetState( $idThisID, $GUI_SHOW + $GUI_ENABLE )

    $iRetVal = GUICtrlSetBkColor( $idThisID, $COLOR_CREAM )
    $iRetVal = GUICtrlSetColor( $idThisID, $COLOR_NAVY )
    $iRetVal = GUICtrlSetOnEvent( $idThisID, "Ef_ListItemClick" )

    $iRetVal = GUICtrlSetState( $idThisID, $GUI_SHOW )

    $iNumLVItems += 1
Next

$idDummy = GUICtrlCreateDummy()
$aAcccel[0][0] = "{ENTER}"
$aAcccel[0][1] = $idDummy
GUICtrlSetOnEvent( $idDummy, "Ef_Accel_Enter" )

$idDummy = GUICtrlCreateDummy()
$aAcccel[1][0] = "{BACKSPACE}"
$aAcccel[1][1] = $idDummy
GUICtrlSetOnEvent( $idDummy, "Ef_Accel_SwitchMons" )

$idDummy = GUICtrlCreateDummy()
$aAcccel[2][0] = "{DELETE}"
$aAcccel[2][1] = $idDummy
GUICtrlSetOnEvent( $idDummy, "Ef_Accel_SwitchMons" )

GUISetState(@SW_SHOW)

$iRetVal = _GUICtrlListView_SetView( $idLview, 1 )

GUISetState( @SW_SHOWNORMAL, $idLview )

Local $aSelRow[$iNumLVItems]
For $i = 0 To $iNumLVItems -1
    $aSelRow[$i] = False
Next

GUISetState(@SW_SHOW)

While True
    Sleep( 350 )
WEnd
Exit 0


Func Ef_SwitchMons()

EndFunc


Func Ef_ListItemClick()
    Local $iSelectedRowStr, $iSelectedCtrlID, $iSelectedRowNum, $iVidListIndex, $iFound, $iPrevSelIndex
    Local $iSelectedVidPath, $iSelectedVidState, $iRetVal, $iColor, $iColorStr, $iPrevSelStr, $iRowNum

    $iSelectedCtrlID = @GUI_CtrlID

    $iRowNum = 0
    $iFound = False

    For $i = 0 To $iNumLVItems -1
        If $aidListItem[$i][0] = $iSelectedCtrlID Then
            $iFound = True
            $iRowNum = $i
            ExitLoop
        EndIf
    Next
    If Not $iFound Then
        MsgBox($MB_OK + $MB_TOPMOST, $eTitle, "Error - Ef_ListItemClick() was unable to find the list item ID in array!")
        Exit -1
    EndIf

    Local $iSelectedDispRowAra = _GUICtrlListView_GetSelectedIndices( $idLview, True )
    If $iSelectedDispRowAra[0] <> 1 Then
        MsgBox($MB_OK + $MB_TOPMOST, $eTitle, "Gi_ListItemClick(): WIERD - SELECTED ROW COUNT = " & $iSelectedDispRowAra[0])
    EndIf
    MsgBox($MB_OK + $MB_TOPMOST, $eTitle, "Gi_ListItemClick(): Selected Row Number = " & $iSelectedDispRowAra[1])

    $aSelRow[$iRowNum] = True
    GUICtrlSetBkColor( $iSelectedCtrlID, $COLOR_SKYBLUE )
    GUICtrlSetColor( $iSelectedCtrlID, $COLOR_YELLOW )

    Return 0
EndFunc

Func Ef_ToMain()
    If Not $bMove Then
        $bMove = True
        GUICtrlSetState( $idMainRadioBtn, $GUI_CHECKED )
        GUICtrlSetState( $idAltRadioBtn, $GUI_UNCHECKED )
    EndIf
EndFunc

Func Ef_ToAlt()
    If $bMove Then
        $bMove = False
        GUICtrlSetState( $idMainRadioBtn, $GUI_UNCHECKED )
        GUICtrlSetState( $idAltRadioBtn, $GUI_CHECKED )
    EndIf
EndFunc

Func Ef_All()
    Local $iD
    For $i = 0 To $iNumLVItems -1
        $iD = $aidListItem[$i][0]
        $aSelRow[$i] = True
        GUICtrlSetBkColor( $iD, $COLOR_SKYBLUE )
        GUICtrlSetColor( $iD, $COLOR_YELLOW )
    Next
EndFunc

Func Ef_None()
    Local $iD
    For $i = 0 To $iNumLVItems -1
        $iD = $aidListItem[$i][0]
        $aSelRow[$i] = False
        GUICtrlSetBkColor( $iD, $COLOR_CREAM )
        GUICtrlSetColor( $iD, $COLOR_NAVY )
    Next
EndFunc

Func Ef_Close()
    Exit 0
EndFunc

Func Ef_Minimize()
EndFunc

Func Ef_Restore()
EndFunc

Func Ef_Maximize()
EndFunc

Func Ef_Cancel()
    Exit 0
EndFunc

Func Ef_Accel_SwitchMons()
EndFunc

Func Ef_Accel_Enter()
    Ef_OK()
EndFunc

Func Ef_OK()
    MsgBox($MB_OK + $MB_TOPMOST, $eTitle, "Exiting")
    Exit 0
EndFunc

 

ListViewProblem.zip

Link to comment
Share on other sites

Hi,

Look at the $iMoveTableIndex

If you follow the code, there is no definition of how many items it shall hold.

and add at least one list view collumn:

Local $idLview = GUICtrlCreateListView( "inventory", 8, 60, 602, 253, $dStyle, $dExStyle)

and you should move the line:

_GUICtrlListView_SetColumnWidth( $idLview, 0, 600 )        ; ALWAYS Fails. Why?

before the for loop, and change $idThisID to $idLview

And remove Local $idSizingLabel = GUICtrlCreateLabel("",8,60,602,253,-1,-1)

Edited by Dan_555

Some of my script sourcecode

Link to comment
Share on other sites

Thank you, @Dan_555! Due entirely to your kind help, it's working now! 😀

I just want to add in my defense that the version I posted above was the result of dozens of changes to try to make it work.  For example, $iMoveTableIndex was defined in the larger, real code, but I forgot to assign in in the excerpt. Also, the _SetColumnWidth call used to be above the for loop and it did pass the list view ID rather than the llist view item ID, but it didn't work there either.

It looks like the stupid thing I was doing wrong was not passing actual text as the first parameter in the GUICtrlCreateListView() function call. But you caught it!

Thank you so very, very much sir!

Link to comment
Share on other sites

Kind @Dan_555, sir, if you have the time I could use a bit more help. Now, after the creation of each list view item, I call GUICtrlSetTip() so that when the user's mouse hovers over a specific list item, the appropriate tool tip is shown. But this call always fails, and I don't know why. I've added "$LVS_EX_INFOTIP" to the list view's styles, but apparently that's not enough. I'm guess some other prerequisite is necessary, but after all my reading of the help file and forum, I can't figure out what that might be.

I've seen quite a few examples of using tooltips, but they're all rather complicated and requires special message handling and/or status bars. I also tried Zedna's    _ListView_ToolTips  UDF, but I can't get that to work either. But if at all posible, I'd prefer to use the very simple GUICtrlSetTip() built-in function.

Would you be able to help, please?

Thanks

 

Link to comment
Share on other sites

I'v used the code from picaxe, from here

And modified it (with a bit of luck) so that it works with your script:

#AutoIt3Wrapper_UseX64=Y

;~ #include "_Dbug.au3"

#include <ButtonConstants.au3>
#include <ColorConstants.au3>
#include <FontConstants.au3>
#include <GuiButton.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>


AutoItSetOption("MustDeclareVars", 1)
AutoItSetOption("GUIOnEventMode", 1)
AutoItSetOption("WinTitleMatchMode", 1)
AutoItSetOption("GUICloseOnESC", 1 )
;
;
Const $eTitle = "Testing"
Local $iFontName = "Courier New", $iFontSize = 12, $iFontWeight = $FW_NORMAL, $iFontAttribs = $GUI_FONTNORMAL

Local $dStyle = BitOr($LVS_REPORT, $LVS_ALIGNLEFT, $LVS_SHOWSELALWAYS, $LVS_NOCOLUMNHEADER)
Local $dExStyle = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_INFOTIP)

Local $iNumWins, $hWin, $iWinClass, $idDummy, $idDummy1, $idDummy2, $aPos[4], $aAcccel[3][2]
Local $iMoveThis, $iLeft, $iRight, $bMove, $iMoveTableIndex=10
Global $iNumLVItems
Local $sWinTitle, $iThisClassName, $iThisExtStyle, $iThisWinState, $iRetVal
Local $idThisID, $dExIndex, $sText, $ig_LVEindx, $hExHdl, $hLViewId

;
; Enter
;

Local $idMoveWinGUI = GUICreate("ListView Problems",647,414,-1,-1,BitOr($WS_POPUP,$WS_CAPTION, $WS_SYSMENU, _
                        $WS_DLGFRAME,$WS_POPUPWINDOW,$WS_VISIBLE),$WS_EX_TOPMOST)

Local $idAllBtn = GUICtrlCreateButton("All",188,9,60,30,-1,-1)
GUICtrlSetOnEvent(-1,"Ef_All")
GUICtrlSetFont(-1,12,400,0,"Courier New")
GUICtrlSetColor(-1,"0x008080")
Local $idNoneBtn = GUICtrlCreateButton("None",360,9,60,30,-1,-1)
GUICtrlSetOnEvent(-1,"Ef_None")
GUICtrlSetFont(-1,12,400,0,"Courier New")
GUICtrlSetColor(-1,"0x008080")
;Local $idSizingLabel = GUICtrlCreateLabel("",8,60,602,253,-1,-1)
GUICtrlSetBkColor(-1,"-2")
Local $idMainRadioBtn = GUICtrlCreateRadio("To Main",208,337,83,20,$BS_CENTER,-1)
GUICtrlSetOnEvent(-1,"Ef_ToMain")
GUICtrlSetFont(-1,10,400,0,"Courier New")
GUICtrlSetColor(-1,"0x008080")
Local $idLview = GUICtrlCreateListView( "Inventory", 8, 60, 602, 253, $dStyle, $dExStyle)
GUIStartGroup()
Local $idAltRadioBtn = GUICtrlCreateRadio("To Alt",316,337,83,20,$BS_CENTER,-1)
GUICtrlSetOnEvent(-1,"Ef_ToAlt")
GUICtrlSetState(-1,BitOr($GUI_UNCHECKED,$GUI_SHOW,$GUI_ENABLE))
GUICtrlSetFont(-1,10,400,0,"Courier New")
GUICtrlSetColor(-1,"0x008080")
Local $idCancelBtn = GUICtrlCreateButton("Cancel",98,336,83,30,-1,-1)
GUICtrlSetOnEvent(-1,"Ef_Cancel")
GUICtrlSetFont(-1,10,400,0,"Courier New")
GUICtrlSetColor(-1,"0x008080")
GUICtrlSetBkColor(-1,"-2")
Local $idOkBtn = GUICtrlCreateButton("OK",459,336,83,30,-1,-1)
GUICtrlSetOnEvent(-1,"Ef_OK")
GUICtrlSetFont(-1,10,400,0,"Courier New")
GUICtrlSetColor(-1,"0x008080")
GUICtrlSetBkColor(-1,"-2")
GUIStartGroup()
ConsoleWrite ($idLview & " - " & @CRLF)
GUISetState(@SW_SHOW)
GUICtrlSetState( $idMainRadioBtn, $GUI_CHECKED )
GUICtrlSetState( $idAltRadioBtn, $GUI_UNCHECKED )

$hLViewId = ControlGetHandle( $idMoveWinGUI, "", $idLview )

Local $iLViewFont = _WinAPI_CreateFont(14, 6, 0, 0, $FW_NORMAL, False, False, False, $DEFAULT_CHARSET, _
                        $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $PROOF_QUALITY, $FF_MODERN, "Courier New" )

$iRetVal = GUICtrlSetFont( $idLview, $iFontSize, $iFontWeight, $GUI_FONTNORMAL, $iFontName, $PROOF_QUALITY )

Global $aidListItem[$iMoveTableIndex +1][4]
Global $ToolTipText[$iMoveTableIndex +1]
$bMove = True
_GUICtrlListView_SetColumnWidth( $idLview, 0, 600 )     ; ALWAYS Fails. Why?

$iNumLVItems = 0

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

For $i = 0 To $iMoveTableIndex -1

    $sText = "This Is A Somewhat Long String (" & $i & ")"
    $idThisID = GUICtrlCreateListViewItem( $sText, $idLview )
    If ($idThisID = 0) Or ($idThisID = "") Then
        MsgBox($MB_OK + $MB_TOPMOST, $eTitle, "Error from GUICtrlCreateListViewItem()")
        Exit -1
    EndIf


    $iRetVal = GUICtrlSetData( $idThisID, $sText )
    $iRetVal = GUICtrlSetState( $idThisID, $GUI_SHOW + $GUI_ENABLE )

    $iRetVal = GUICtrlSetBkColor( $idThisID, $COLOR_CREAM )
    $iRetVal = GUICtrlSetColor( $idThisID, $COLOR_NAVY )
    $iRetVal = GUICtrlSetOnEvent( $idThisID, "Ef_ListItemClick" )

    ;$iRetVal = GUICtrlSetState( $idThisID, $GUI_ENABLE )
    $aidListItem[$i][0]=$idThisID
    $ToolTipText[$i]="Tooltip text of " & $i
    $iNumLVItems += 1
Next

$idDummy = GUICtrlCreateDummy()
$aAcccel[0][0] = "{ENTER}"
$aAcccel[0][1] = $idDummy
GUICtrlSetOnEvent( $idDummy, "Ef_Accel_Enter" )
$aAcccel[1][0] = "{BACKSPACE}"
$aAcccel[1][1] = $idDummy
GUICtrlSetOnEvent( $idDummy, "Ef_Accel_SwitchMons" )
$aAcccel[2][0] = "{DELETE}"
$aAcccel[2][1] = $idDummy
GUICtrlSetOnEvent( $idDummy, "Ef_Accel_SwitchMons" )

GUISetState(@SW_SHOW)

$iRetVal = _GUICtrlListView_SetView( $idLview, 1 )

;GUISetState( @SW_SHOWNORMAL, $idLview )

Local $aSelRow[$iNumLVItems]
For $i = 0 To $iNumLVItems -1
    $aSelRow[$i] = False
Next


local $nMSG
While True
    Sleep( 10 )
WEnd
Exit 0

Func Ef_SwitchMons()

EndFunc


Func Ef_ListItemClick()

    Local $iSelectedRowStr, $iSelectedCtrlID, $iSelectedRowNum, $iVidListIndex, $iFound, $iPrevSelIndex
    Local $iSelectedVidPath, $iSelectedVidState, $iRetVal, $iColor, $iColorStr, $iPrevSelStr, $iRowNum

    $iSelectedCtrlID = @GUI_CtrlID

    $iRowNum = 0
    $iFound = False

    For $i = 0 To $iNumLVItems -1
        If $aidListItem[$i][0] = $iSelectedCtrlID Then
            $iFound = True
            $iRowNum = $i
            ExitLoop
        EndIf
    Next
    If Not $iFound Then
        ;MsgBox($MB_OK + $MB_TOPMOST, $eTitle, "Error - Ef_ListItemClick() was unable to find the list item ID in array!")
        CW("Error - Ef_ListItemClick() was unable to find the list item ID in array!")
        return 0
        Exit -1
    EndIf

    Local $iSelectedDispRowAra = _GUICtrlListView_GetSelectedIndices( $idLview, True )
    If $iSelectedDispRowAra[0] <> 1 Then
        MsgBox($MB_OK + $MB_TOPMOST, $eTitle, "Gi_ListItemClick(): WIERD - SELECTED ROW COUNT = " & $iSelectedDispRowAra[0])
    EndIf
    ;MsgBox($MB_OK + $MB_TOPMOST, $eTitle, "Gi_ListItemClick(): Selected Row Number = " & $iSelectedDispRowAra[1])
    CW("Gi_ListItemClick(): Selected Row Number = " & $iSelectedDispRowAra[1])
    $aSelRow[$iRowNum] = True
    GUICtrlSetBkColor( $iSelectedCtrlID, $COLOR_SKYBLUE )
    GUICtrlSetColor( $iSelectedCtrlID, $COLOR_YELLOW )

    Return 0
EndFunc

Func Ef_ToMain()
    If Not $bMove Then
        $bMove = True
        GUICtrlSetState( $idMainRadioBtn, $GUI_CHECKED )
        GUICtrlSetState( $idAltRadioBtn, $GUI_UNCHECKED )
    EndIf
EndFunc

Func Ef_ToAlt()
    If $bMove Then
        $bMove = False
        GUICtrlSetState( $idMainRadioBtn, $GUI_UNCHECKED )
        GUICtrlSetState( $idAltRadioBtn, $GUI_CHECKED )
    EndIf
EndFunc

Func Ef_All()
ConsoleWrite ($iNumLVItems & " $iNumLVItems " & @CRLF)
    Local $iD
    For $i = 0 To $iNumLVItems -1
        $iD = $aidListItem[$i][0]
        $aSelRow[$i] = True
        GUICtrlSetBkColor( $iD, $COLOR_SKYBLUE )
        GUICtrlSetColor( $iD, $COLOR_YELLOW )
    Next
EndFunc

Func Ef_None()
    Local $iD
    For $i = 0 To $iNumLVItems -1
        $iD = $aidListItem[$i][0]
        $aSelRow[$i] = False
        GUICtrlSetBkColor( $iD, $COLOR_CREAM )
        GUICtrlSetColor( $iD, $COLOR_NAVY )
    Next
EndFunc

Func Ef_Close()
    Exit 0
EndFunc

Func Ef_Minimize()
EndFunc

Func Ef_Restore()
EndFunc

Func Ef_Maximize()
EndFunc

Func Ef_Cancel()
    Exit 0
EndFunc

Func Ef_Accel_SwitchMons()
EndFunc

Func Ef_Accel_Enter()
    Ef_OK()
EndFunc

Func Ef_OK()
    MsgBox($MB_OK + $MB_TOPMOST, $eTitle, "Exiting")
    Exit 0
EndFunc

Func CW($txt)
ConsoleWrite($txt & @CRLF)
EndFunc

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $iIDFrom
        Case $idLview
            Switch $iCode
                Case $LVN_HOTTRACK
                    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
                    Local $iItem = DllStructGetData($tInfo, "Item"), $iSubItem = DllStructGetData($tInfo, "SubItem")
                    If Not ($iItem = -1 Or $iSubItem = -1) Then
                        If $ToolTipText[$iItem] <> "" Then
                            ToolTip($ToolTipText[$iItem])
                        Else
                            ToolTip("")
                        EndIf
                    Else
                        ToolTip("")
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY

 

Copy following to your script:

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
Global $ToolTipText[$iMoveTableIndex +1]

Add the tooltip with: 

$ToolTipText[$i]="Tooltip text of " & $i

And, of course the, WM_NOTIFY function.

Edited by Dan_555

Some of my script sourcecode

Link to comment
Share on other sites

Wow, @Dan_555, you're awesome! 😎  Once again, I am extremely grateful for your gracious assistance.

I was having trouble at first, which appeared to be helped (but not totally solved) by adding a "#forceref" statement, but I no longer think that was necessary because the real problem was where in the code I placed the GUIRegisterMsg() call.

My app is now working exactly as I'd hoped, thanks in no small part to you, sir. Hats off!

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...