Jump to content
Sign in to follow this  
andybiochem

Table UDF

Recommended Posts

Dmitry0Es
Hello, everyone!
Really like UDF, but lacks interactivity .. =)
 
Maybe this can help solve problem:
 
#include "Table.au3"
#include <GuiConstants.au3>




Global $top=40
Global $left=40
Global $w  = 60
Global $ww= 0
Global $h = 20
Global $nr = 20
Global $nc = 6


Opt("GUIOnEventMode", 1)
;----- GUI (Double Buffered) -----
Global $GUI = GUICreate("", 450, 2*$top+ ($h+$ww)*$nr, -1, -1, -1, 0x2000000)
GUISetOnEvent($GUI_EVENT_CLOSE, "EventClose")

;----- Make sure GUI exists BEFORE creating Tables -----
GUISetState()

;----- Lock GUI until tables drawn -----
GUISetState(@SW_LOCK)


GUICtrlCreateLabel(" Example 4 ", $left, $top -30)
Global $Table4 = _GUICtrlTable_Create($left, $top, $w, $h, $nr, $nc, $ww)
Global $Table44 = _GUICtrlTable_Create($left, $top, $w, $h, $nr, $nc, $ww)

For $i = 1 To $nr
    For $j= 1 To $nc
        GUICtrlSetOnEvent($Table44[$i][$j], "EventTableClick")
    Next
Next


_GUICtrlTable_Set_RowHeight($Table4, 1, $h*2)
_GUICtrlTable_Set_RowHeight($Table44, 1, $h*2)
_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 $nr 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)

;----- Unlock GUI to show tables -----
GUISetState(@SW_UNLOCK)

While Sleep(20)
WEnd


Func EventClose()
    Exit
EndFunc

Func EventTableClick()
    Local $bFound=False
    Local $i_f, $j_f
    For $i =1 To UBound($Table44,1)-1
        For $j =1 To UBound($Table44,2)-1
            If $Table44[$i][$j] =  @GUI_CtrlId  Then
                $i_f =$i
                $j_f = $j
                $bFound =True
                ExitLoop
            EndIf
        Next
    Next

    If Not $bFound Then Return

    ToolTip( $i_f  &" x " & $j_f )
    Sleep(330)
    ToolTip("")
EndFunc

:bike:

Share this post


Link to post
Share on other sites
Scampy
On 05.09.2014 at 10:06 AM, Dmitry0Es said:
Hello, everyone!
Really like UDF, but lacks interactivity .. =)
 
Maybe this can help solve problem:
 
#include "Table.au3"
#include <GuiConstants.au3>




Global $top=40
Global $left=40
Global $w  = 60
Global $ww= 0
Global $h = 20
Global $nr = 20
Global $nc = 6


Opt("GUIOnEventMode", 1)
;----- GUI (Double Buffered) -----
Global $GUI = GUICreate("", 450, 2*$top+ ($h+$ww)*$nr, -1, -1, -1, 0x2000000)
GUISetOnEvent($GUI_EVENT_CLOSE, "EventClose")

;----- Make sure GUI exists BEFORE creating Tables -----
GUISetState()

;----- Lock GUI until tables drawn -----
GUISetState(@SW_LOCK)


GUICtrlCreateLabel(" Example 4 ", $left, $top -30)
Global $Table4 = _GUICtrlTable_Create($left, $top, $w, $h, $nr, $nc, $ww)
Global $Table44 = _GUICtrlTable_Create($left, $top, $w, $h, $nr, $nc, $ww)

For $i = 1 To $nr
    For $j= 1 To $nc
        GUICtrlSetOnEvent($Table44[$i][$j], "EventTableClick")
    Next
Next


_GUICtrlTable_Set_RowHeight($Table4, 1, $h*2)
_GUICtrlTable_Set_RowHeight($Table44, 1, $h*2)
_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 $nr 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)

;----- Unlock GUI to show tables -----
GUISetState(@SW_UNLOCK)

While Sleep(20)
WEnd


Func EventClose()
    Exit
EndFunc

Func EventTableClick()
    Local $bFound=False
    Local $i_f, $j_f
    For $i =1 To UBound($Table44,1)-1
        For $j =1 To UBound($Table44,2)-1
            If $Table44[$i][$j] =  @GUI_CtrlId  Then
                $i_f =$i
                $j_f = $j
                $bFound =True
                ExitLoop
            EndIf
        Next
    Next

    If Not $bFound Then Return

    ToolTip( $i_f  &" x " & $j_f )
    Sleep(330)
    ToolTip("")
EndFunc

:bike:

Hi!

How to add a macro to one of cells?  For example "@WindowsDir"?

 

Edited by Scampy

Share this post


Link to post
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
Sign in to follow this  

×