Jump to content

Recommended Posts

Posted

First, I want to thank both authors of these great UDF's.  I just can't seem to get them to work nice together.  Any and all help would be appreciated, as I've tried for the past 3 days to get a row to highlight in the table while mousing over it.  :)

 

#include <Table.au3>
#include <GUICtrlOnHover.au3>

Global $NewCode     = "Create New Code"
Global $TestHL      = "Test Highlight a row in Table"

    $GUI            =   GUICreate              ("",              450, 450,  -1, -1, -1, 0x2000000);----- GUI (Double Buffered) -----
                        GUICtrlCreateLabel     ($TestHL,          40,  10, 400, 40)
                        GUICtrlSetFont         (-1,                         18,600)
    $LbCreateCode   =   GUICtrlCreateLabel     ($NewCode,         22,  60, 110, 20)
                        GUICtrlSetColor        (-1,                       0x0000ff);blue
                        GUICtrlSetFont         (-1,                         10,400)
    $Button         =   GUICtrlCreateButton    ("Test Highlight", 22,  90, 100, 20)

                       _GUICtrl_OnHoverRegister($LbCreateCode, "_Hover_Func", "_Hover_Func")
                       _GUICtrl_OnHoverRegister($Button,       "_Hover_Func", "_Hover_Func")

GUISetState();----- Make sure GUI exists BEFORE creating Tables -----
GUISetState(@SW_LOCK);----- Lock GUI until tables drawn -----
GUICtrlCreateLabel(" Example 1 ", 25, 250, 100, 13);----- Table Example 4 -----
$Table4 = _GUICtrlTable_Create              (35, 268, 62, 18, 8, 6, 0)
          _GUICtrlTable_Set_RowHeight       ($Table4, 1, 35)
          _GUICtrlTable_Set_Justify_All     ($Table4, 1, 1)
          _GUICtrlTable_Set_TextFont_All    ($Table4, 8.5, 800, 0, "Tahoma")
          _GUICtrlTable_Set_CellColor_Row   ($Table4, 1, 0x555555)
          _GUICtrlTable_Set_TextColor_All   ($Table4, 0x555555)
          _GUICtrlTable_Set_TextColor_Row   ($Table4, 1, 0xFFFFFF)
For $row = 3 To 10 Step 2
    _GUICtrlTable_Set_CellColor_Row($Table4, $row, 0xDDDDDD)
Next
_GUICtrlTable_Set_Text_Row    ($Table4, 1, "Fixing|Size|Weight|Net|Gross|Order")
_GUICtrlTable_Set_Text_Row    ($Table4, 2, "Block|20.0|0.01|300|340|No")
_GUICtrlTable_Set_Text_Row    ($Table4, 3, "Screw|8.5|0.3|50|100|No")
_GUICtrlTable_Set_Text_Row    ($Table4, 4, "Rivet|0.1|0.4|10|11|Yes")
_GUICtrlTable_Set_Text_Row    ($Table4, 5, "Rope|300.0|100.0|2|10|No")
_GUICtrlTable_Set_Text_Row    ($Table4, 6, "Tack|10.6|0.3|1000|1011|Yes")
_GUICtrlTable_Set_Text_Row    ($Table4, 7, "Nail|30.3|0.4|400|600|No")
_GUICtrlTable_Set_Text_Row    ($Table4, 8, "Staple|0.3|0.05|10000|12000|No")
_GUICtrlTable_Set_Border_Table($Table4, 0x555555)
GUISetState(@SW_UNLOCK)
for $x = 1 to 8
    for $y = 1 to 6
    _GUICtrl_OnHoverRegister($Table4[$x][$y], "_Hover_Func", "_Hover_Func")
    Next
Next
Do;----- Loop -----
    Sleep(10)
    $m = MouseGetPos()
Until GUIGetMsg() = -3
Func _Hover_Func($iCtrlID, $iParam)
    Local $sConsole_Data = "Hovered"
    Local $iLabel_Color = 0x00000FF;0x0000ff
    Local $iLabel_FontAttrib = 4
    Local $iTable1_highlight_Color1 = 0xFFD700
    Local $iTable1_highlight_Color2 = 0xFFD700
    If $iParam = 2 Then ;Indicates On *Leave* Hover process
        $sConsole_Data = "NOT Hovered"
        $iLabel_Color = 0x0000ff
        $iLabel_FontAttrib = 0
        $iTable1_highlight_Color1 = 0xFFFFFF
        $iTable1_highlight_Color2 = 0xDDDDDD
    EndIf
    Printf("Control " & $iCtrlID & " [Data: " & GUICtrlRead($iCtrlID, 1) & "] Is Now " & $sConsole_Data)
    Switch $iCtrlID
        Case $LbCreateCode
            GUICtrlSetColor($iCtrlID, $iLabel_Color)
            GUICtrlSetFont($iCtrlID, 10, 400, $iLabel_FontAttrib)
        Case $Table4[2][1]
            _GUICtrlTable_Set_CellColor_Row($Table4, 2, $iTable1_highlight_Color1)
        Case $Table4[3][1]
            _GUICtrlTable_Set_CellColor_Row($Table4, 3, $iTable1_highlight_Color2)
        Case $Button
            _GUICtrlTable_Set_CellColor_Row($Table4, 2, $iTable1_highlight_Color1)
    EndSwitch
EndFunc
Func Printf($Str, $Line=@ScriptLineNumber)
    ConsoleWrite("!===========================================================" & @LF & _
                "+======================================================" & @LF & _
                "--> Script Line (" & $Line & "):" & @LF & "!" & @TAB & $Str & @LF & _
                "+======================================================" & @LF)
EndFunc

I've modified the table example to be closer to my actual project, and I'm trying to hover the mouse over the rows in the table to highlight the entire row, regardless of which cell in the row I'm hovering over.  in this example, hovering over the button gives the desired effect (as an example).  I've also only coded looking specifically at 2 cells for now, to highlight the entire row (I'll add more later if I can get this to work).

Thoughts?  and thanks in advance.  I LOVE AutoIT and this community!!!

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
  • Recently Browsing   0 members

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