LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

using images in a table

I want to know which image is loaded to a table cell.
I tried GetTableCelVal to get the id of the image and compring it to the id i got from GetBitMapFromFile, every time I use GetTableCelVal I get a different value.
how can I solve this problem?
0 Kudos
Message 1 of 2
(2,831 Views)
Let me explain why you are getting a new bitmap ID. When you get the bitmap from the table cell it creates a new copy of the bitmap for you to use in your code, so there is a new bitmap ID every time.

The best way to accomplish what you want to do is to use multiple data types of the table cells to include an integer ID with the bitmap. These integers could be reference numbers or the original bitmap ID.

So what you would do is this.

1) When you set the bitmap value into the cell, also set an integer value of the cell. Your code would be something like:

SetTableCellAttribute (panelHandle, PANEL_TABLE, cell,
ATTR_CELL_TYPE, VAL_CELL_PICTURE);
SetTableCellVal (panelHandle, PANEL_TABLE, cell, bitmapID);
SetTableCellAttribute (panelH
andle, PANEL_TABLE, cell,
ATTR_CELL_TYPE, VAL_CELL_NUMERIC);
SetTableCellVal (panelHandle, PANEL_TABLE, cell, bitmapID);
SetTableCellAttribute (panelHandle, PANEL_TABLE, cell,
ATTR_CELL_TYPE, VAL_CELL_PICTURE);

2) Then, when you want to see which bitmap is displayed, check the numeric value of the cell with:

SetTableCellAttribute (panelHandle, PANEL_TABLE, cell,
ATTR_CELL_TYPE, VAL_CELL_NUMERIC);
GetTableCellVal (panelHandle, PANEL_TABLE, cell, &currentBMPID);
SetTableCellAttribute (panelHandle, PANEL_TABLE, cell,
ATTR_CELL_TYPE, VAL_CELL_PICTURE);


It will retain both the picture and integer data for the cell, so you can use the integer value to reference which bitmap is currently in the cell.

Best Regards,

Chris Matthews
National Instruments
Message 2 of 2
(2,831 Views)