Jump to content
Sign in to follow this  
andybiochem

Table UDF

Recommended Posts

jeffml

I figured out the problem. I have this table generating in a child GUI, so I had to alter the function to accept GUI handle and now it works.

Second problem though: why do the cells appear to draw an extra gapwidth every 3 cells? Every 3 cells, I see an extra pixel gap. Does this happen to anyone else? It makes trying to draw borders kind of hard. Especially because the border technically draws behind the cell unless you move it within the function. Maybe this is just behavior on my computer. I appear to be having lots of troubles other people aren't, unless I'm the only one messing around with broders.

Thanks for any help.

Hi,

Your table looks great. Implemented it, then tried to use draw border functionality and got error "Subscript used with non-Array variable." I noticed that it is due to ControlGetPos() not getting the position of a cell control and rather erroring instead. Is anyone else having this issue? ControlGetPos() doesn't pass any extra variables except Control ID. Is this usually a problem? I confirmed with Au3Info.exe that the control ID was correct, but even manually trying to identify the control without calling the draw border function doesn't appear to work.

Quick example:

$tableArray = _GUICtrlTable_Create(5, 25, 100, 20, $_vCells, $_hCells+1)

msgbox(0,"",_GUICtrlTable_CellGetID($tableArray,2,2))

get ID returns value: 30

local $temp

$temp = ControlGetPos("[CLASS:Static]","",30)

msgbox(0,"",$temp[0] & @CRLF & $temp[1])

ControlGetPos spits out @error = 1, and subsequently referencing temp[0] and temp[1] result in above array error.

Anyone?

Thanks!

Share this post


Link to post
Share on other sites
andybiochem

Second problem though: why do the cells appear to draw an extra gapwidth every 3 cells? Every 3 cells, I see an extra pixel gap.

Sorry you're having problems with my UDF ;) .

Can you post a small script that recreates the gap problem? I've tried a dozen or so different tables, but can't get the error you describe.

Are you editing the cells manually via control id's, or are you sticking to the udf functions?

Cheers


- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

Share this post


Link to post
Share on other sites
BlueLord

Hy,

It's posible to use this UDF to display in a table data from a sql database (from a month by example)

If it is can somebody to guide me with a small example?

Thanks,

Share this post


Link to post
Share on other sites
InvalidSyntax

So I am trying to use this UDF is a tab but for some reason the borders disappear. You can see them when resizing the window but thats about it.

Share this post


Link to post
Share on other sites
monoscout999

hi i kwonw is old topic but... why it doesn´t work this?

#include <Table.au3>
Dim $enumcolors[10][2]
$enumcolors[0][0] = "9" ; the first element of the first columns says how many colors are in the list
$enumcolors[1][0] = "009D9D9C"
$enumcolors[2][0] = "00B2B4B5"
$enumcolors[3][0] = "00596475"
$enumcolors[4][0] = "00686B6F"
$enumcolors[5][0] = "00BCBEBC"
$enumcolors[6][0] = "00BDBFBF"
$enumcolors[7][0] = "00B9BEBF"
$enumcolors[8][0] = "00B9BCBD"
$enumcolors[9][0] = "00C1C1BF"
$enumcolors[0][1] = "how of each..." ; the first element of the second column says how many of each color are
$enumcolors[1][1] = "1"
$enumcolors[2][1] = "1"
$enumcolors[3][1] = "7"
$enumcolors[4][1] = "2"
$enumcolors[5][1] = "2"
$enumcolors[6][1] = "2"
$enumcolors[7][1] = "8"
$enumcolors[8][1] = "6"
$enumcolors[9][1] = "6"

Guicreate("list",-1,-1,-1,-1,-1,0x2000000)
GUISetState()
GUISetState(@SW_LOCK)
$table = _GUICtrlTable_Create(0,0,400,400,ubound($enumcolors),ubound($enumcolors,2), 2)
_GUICtrlTable_Set_Text_FromArray($table,$enumcolors)
GUISetState(@SW_UNLOCK)
while 1
    $msj = Guigetmsg()
    switch $msj
        case -3
            Exit
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
andybiochem

hi i kwonw is old topic but... why it doesn´t work this?

From the function file:

; #FUNCTION# ;===============================================================================
; Name...........: _GUICtrlTable_Create
; Description ...: Creates a 'table' of label controls, and preps the 'border array'
; Syntax.........: _GUICtrlTable_Create($iLeft, $iTop, $iWidth, $iHeight, $iRows, $iColumns[, $iGapWidth = 1])
; Parameters ....: $iLeft - Horisontal position of first cell
;                  $iTop - Vertical position of first cell
;                  $iWidth - Initial width of each cell
;                  $iHeight - Initial height of each cell
;                  $iRows - Number of rows in table
;                  $iColumns - Number of columns in table
;                  $iGapWidth - Size (pixels) of gap between each cell (can be zero = no gaps)
; Return values .: Success - Returns array of label IDs for other functions ($ReturnedArray[ROW][COLUMN])
;                  Failure - (under construction)
; Notes .........: Rows/Columns are NOT zero-indexed. The first row IS row 1, the first column IS col 1 etc

In your code you are creating a table with cells 400x400 pixels in size.

The table then does not fill with your data because you are using the zeroeth array elements for storage.

This works fine:

#include <Table.au3>
Dim $enumcolors[11][3]
$enumcolors[1][1] = "9" ; the first element of the first columns says how many colors are in the list
$enumcolors[2][1] = "009D9D9C"
$enumcolors[3][1] = "00B2B4B5"
$enumcolors[4][1] = "00596475"
$enumcolors[5][1] = "00686B6F"
$enumcolors[6][1] = "00BCBEBC"
$enumcolors[7][1] = "00BDBFBF"
$enumcolors[8][1] = "00B9BEBF"
$enumcolors[9][1] = "00B9BCBD"
$enumcolors[10][1] = "00C1C1BF"
$enumcolors[1][2] = "how of each..." ; the first element of the second column says how many of each color are
$enumcolors[2][2] = "1"
$enumcolors[3][2] = "1"
$enumcolors[4][2] = "7"
$enumcolors[5][2] = "2"
$enumcolors[6][2] = "2"
$enumcolors[7][2] = "2"
$enumcolors[8][2] = "8"
$enumcolors[9][2] = "6"
$enumcolors[10][2] = "6"

Guicreate("list",-1,-1,-1,-1,-1,0x2000000)
GUISetState()
GUISetState(@SW_LOCK)
$table = _GUICtrlTable_Create(0,0,70,15,ubound($enumcolors)-1,ubound($enumcolors,2)-1, 2)
_GUICtrlTable_Set_Text_FromArray($table,$enumcolors)
GUISetState(@SW_UNLOCK)
while 1
    $msj = Guigetmsg()
    switch $msj
        case -3
            Exit
    EndSwitch
WEnd

So I am trying to use this UDF is a tab but for some reason the borders disappear. You can see them when resizing the window but thats about it.

The borders are simply colored labels that are 'sent to the back' of the gui, below the input boxes. It might be that they are bieng sent below the tab control too? Not sure.

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

Share this post


Link to post
Share on other sites
quantum900

I have to say this is my first post here, AutoIT is such a wonderful tool! This UDF is VERY handy.

I have one commecnt, question. The column width seems to be a global hard set value. WHat if I need columns of different widths? I noticed tha tif the column wasn't wide enough that it cuts off content instead of auto-resizing.

Thanks for all your work with this!

Share this post


Link to post
Share on other sites
ijourneaux

I have been using this UDF for a while now. Great Job! Easy to use and very useful.

I am finally trying to troubleshoot an intermittant problem where I get the error mentioned earlier in the thread "Subscript used on a non-array variable". The interesting thing is that it doesn't always fail. I would say I get the error message 11 out of every 3-4 time I start my autoit script.

Here is a code snippet. Itf it is coing to error out, it happens between "CreateTable 3" and "Create Table 4"

Since the problem doesn't occur every time, it is difficult to troubleshoot.

;----- Table Example 4 -----
DebugLog("CreateTable 1")
$Table4 = _GUICtrlTable_Create(10, 10, 62, 18, 21, 10, 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)
DebugLog("CreateTable 2")
For $row = 3 To $Table4Rows+1 Step 2
  _GUICtrlTable_Set_CellColor_Row($Table4, $row, 0xDDDDDD)
Next
DebugLog("CreateTable 3")
_GUICtrlTable_Set_ColumnWidth($Table4, 1, 70)
_GUICtrlTable_Set_ColumnWidth($Table4, 3, 80)
_GUICtrlTable_Set_ColumnWidth($Table4, 4, 80)
_GUICtrlTable_Set_ColumnWidth($Table4, 5, 40)
_GUICtrlTable_Set_ColumnWidth($Table4, 6, 30)
if($HelioDevice = "Research") then
  DebugLog("CreateTable 5a")
  _GUICtrlTable_Set_Text_Row($Table4, 1, "Date,Time,Job,Sample,Side,Rep,Test,Result1,Result2,Result3", ",")
Else
  DebugLog("CreateTable 5b")
  _GUICtrlTable_Set_Text_Row($Table4, 1, "Date,Time,Job,Sample,Side,Rep,Test,Helio-20,Result2,Result3", ",")
EndIf
DebugLog("CreateTable 6")
_GUICtrlTable_Set_Border_Table($Table4, 0x555555)
EndFunc

Share this post


Link to post
Share on other sites
ijourneaux

I fiannly had it fail when running in the editor. The error occurs at line 256 in Table.Au3 I copied a snippet from the function. The error occurs at the last line where

GUICtrlSetPos($array[$i][$j], $iCurrBoxLeft, $aTemp[1])

The error only seems to happen the first time I run the application involved. The second time I run it, it seems to work correctly

Any thoughts on how I can correct table.au3 or atleast work around this issue?

$aTemp = ControlGetPos("", "", $array[1][1])
$aTemp2 = ControlGetPos("", "", $array[1][2])
$iGapWidth = $aTemp2[0] - ($aTemp[0] + $aTemp[2])
If $iGapWidth < 0 Then $iGapWidth = 0
For $i = 1 To UBound($array, 1) - 1
  $bFirst = True
  For $j = $iCol To UBound($array, 2) - 1
   $aTemp = ControlGetPos("", "", $array[$i][$j])
   If $bFirst = True Then $iCurrBoxLeft = $aTemp[0]
   $bFirst = False
   Switch $j
    Case $iCol
     GUICtrlSetPos($array[$i][$j], $iCurrBoxLeft, $aTemp[1], $iWidth)
     For $k = 1 To 4
      Switch $k
       Case 1
        GUICtrlSetPos($aRetrievedTableBorders[$i][$j][$k], $iCurrBoxLeft, $aTemp[1])
       Case 2
        GUICtrlSetPos($aRetrievedTableBorders[$i][$j][$k], $iCurrBoxLeft, $aTemp[1], $iWidth)
       Case 3
        GUICtrlSetPos($aRetrievedTableBorders[$i][$j][$k], $iCurrBoxLeft + $iWidth - 1, $aTemp[1])
       Case 4
        GUICtrlSetPos($aRetrievedTableBorders[$i][$j][$k], $iCurrBoxLeft, $aTemp[1] + $aTemp[3] - 1, $iWidth)
      EndSwitch
     Next
     $iCurrBoxLeft += $iWidth + $iGapWidth
    Case Else
     GUICtrlSetPos($array[$i][$j], $iCurrBoxLeft, $aTemp[1])

Share this post


Link to post
Share on other sites
ijourneaux

I was able to locate the problem. In the statement below "", "" referes to the current window which may or may not be the AutoIt window with the table. To try and address this, I modified my script so the window is made active immediately before the table is built. Not an ideal solution but should work in the short term.

$aTemp = ControlGetPos("", "", $array[$i][$j])

Share this post


Link to post
Share on other sites
ijourneaux

The Table UDF functionality met a need for a project I was working on. Sometimes my application would crash when populating the table. It turned out that the problem was that the Autoit window with the table control would lose focus that that would cause the application to crash.

The problem was the line

$aTemp = ControlGetPos("", "", $array[$i][$j])

that is peppered through the code. The help file mentions to be careful when using "","" with ControlGetPos.

To get around this, I changed the initial call to create the table to include the title of the window.

Func _GUICtrlTable_Create($Title, $iLeft, $iTop, $iWidth, $iHeight, $iRows, $iColumns, $iGapWidth = 1)

Then I use the title in all of the calls to ControlGetPos in table.au3.

Any way, it worked for me. Hopefully it will help someone else. And thanks to the OP for the original UDF.

Share this post


Link to post
Share on other sites
Acanis

Hey, great UDF, but if you use your

GUISetState()
AFTER the creation of the table, you get this error ->

F:AutoIt3IncludeTable.au3 (230) : ==> Subscript used with non-Array variable.:
$iGapWidth = $aTemp2[0] - ($aTemp[0] + $aTemp[2])
$iGapWidth = $aTemp2^ ERROR

That is sad...^^ Cause u dont want to show the GUI, before all is ready?!^^ AND you cant use it with Tabs!!! :/

Share this post


Link to post
Share on other sites
chun914

any way to make this table editable on the GUI?

Share this post


Link to post
Share on other sites
BugFix

any way to make this table editable on the GUI?

A way to do this:

- mouse click on the label you want to edit

- mouse click event checks if control under mouse is one of table-label

- if true: get position, size and text from label

- create child window including only an input in size of the label, move it over the label

- set label text into the input

- now you can edit the label text

- with hitting <Enter> read input value, set it to label and hide/delete the child

- with hitting <Esc> only hide/delete the child


Best Regards BugFix  

Share this post


Link to post
Share on other sites
hardfloor

Hey, great UDF, but if you use your

GUISetState()
AFTER the creation of the table, you get this error ->

F:AutoIt3IncludeTable.au3 (230) : ==> Subscript used with non-Array variable.:
$iGapWidth = $aTemp2[0] - ($aTemp[0] + $aTemp[2])
$iGapWidth = $aTemp2^ ERROR

That is sad...^^ Cause u dont want to show the GUI, before all is ready?!^^ AND you cant use it with Tabs!!! :/

 

Hello,

Has anyone found a solution to this problem.......

I'v the same!

Any help please :

Share this post


Link to post
Share on other sites
13lack13lade

i know this is an old thread but - can this be used to display tables from excel in a gui? :D

Share this post


Link to post
Share on other sites
BrewManNH

If you can put them into the labels this creates I don't see why it wouldn't work that way. This UDF doesn't create a real table, from the description given, it creates a series of label controls that look like a table.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
TheSaint

@13lack.... - Better to embed an Excel object .... not that I've tried ... but someone else here is sure to have, so you could be rewarded by doing a search or asking in General Help.

@hardfloor - Sorry, but I don't think many would be that interested in this type of Table, so you will no doubt need to work the issue out yourself or try what I said above.

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites
Melba23

Hi,

While debugging another script, I have discovered why lines appear between the cells on occasion (see post #22 above). It happens when you pass fractional values for the cell dimensions - rounding errors then occur when the display converts to integer pixel values. An example script showing the problem and the solution can be found here. :)

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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  

×