LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Button-table with colors?

Solved!
Go to solution

Hey everyone,

 

I made a matrix table of buttons (please open my attached picture to understand what I meant).

 

I would like to do two things:

1. Make the buttons clickable, and to make an event each time one of them was clicked by the user.

2. To control the color of each button sepertly in the table.

 

I use CVI 2013 with academic lessons.

 

Are that possible? and which are the commands I can use for these tasks? 

 
Best,

 

Tom

0 Kudos
Message 1 of 6
(5,084 Views)
Solution
Accepted by topic author RaVen88

Button cells are already active provided the table is in hot or normal mode.

If in hot mode, you receive an EVENT_COMMIT in the table callback: you can then detect the button pressed calling GetTactiveTableCell and processing cell coordinates.

 

Individual cells can be painted in color provided the panel the control is on is not set to follow Windows theme: edit panel attributes, select Other attributes... and uncheck Use Windows Visuali Styles for Controls checkbox.

Alternatively, the table alone can be set this way leaving the panel and other controls to adhere to the theme: you can obtain this by calling:

SetCtrlAttribute (panelHandle, PANEL_TABLE, ATTR_DISABLE_PANEL_THEME, 1);

 

In this case, individual cells need to be painted programmatically by calling:

SetTableCellAttribute (panelHandle, PANEL_TABLE, MakePoint (col, row), ATTR_CMD_BUTTON_COLOR, VAL_CYAN);

 

where col, row are 1-based column and row indexes of the cell to operate on. The function will fail if the cell is not a button.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 6
(5,061 Views)

Thanks a lot!! It worked!

May I ask another question about tables?


When the user choose a cell from the table, I could get the cell's coordinates into the point structure Cell from this series of commands:

case EVENT_LEFT_CLICK:  

Point Mouse_Coords, Cell;
Mouse_Coords.x = eventData2;
Mouse_Coords.y = eventData1;
GetTableCellFromPoint (panelHandle_3, ilfmaker_ilftable, Mouse_Coords, &Cell);

But when the user mark the entire column or the entire row by pressing the first column from above or row to the left, I want that the event would go over the entire row/column, instead nothing is happened.
Moreover, I am unable to get the column/row coordinates in this case only Cell.x and Cell.y 0,0.

Thank you,

Tom

 

0 Kudos
Message 3 of 6
(5,045 Views)

When the user clicks on a row or column header it selects the entrire row/column: in this case an EVENT_SELECTION_CHANGE is sent to the table callback: in this case you can trap that event and use GetTableSelection to obtain the selected area in a Rect structure.

Be careful in doing so: if the user manually selects a set of cells with mouse or keyboard  you will receive a series of EVENT_SELECTION_CHANGE events that you must properly handle.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 6
(5,042 Views)
Solution
Accepted by topic author RaVen88

If it turns out that EVENT_SELECTION_CHANGE is unreliable for this purpose, you can look for EVENT_TABLE_ROW_COL_LABEL_CLICK instead.

Message 5 of 6
(5,028 Views)

Wow guys!!! thank you so much!!! this event was exactly what I needed! 🙂

0 Kudos
Message 6 of 6
(5,005 Views)