LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Possible bug found in GetTableCellFromPoint when used with large tables (CVI 8.1 on XPThis )

There is a possible bug that I found in "GetTableCellFromPoint" when used with large tables on CVI 8.1 under XP Pro SP2.
 
Create a table in a UIR panel, populate it with lots of empty row and columns with both scroll bars activated.  Use enough rows and columns to go force the table to turn on the scrol bars.  Add a callback function to the table.  In that callback, add the event that captures the mouse cursor movement.  Add a custom function to that particular event branch that reports back the row index and column index.  That would look something like this.
 
int __cdecl TableCCB (int panel, int control, int event,  void *callbackData, int eventData1, int eventData2)
{
    int    rowIndex;
    int    colIndex;
 
    switch (event) {
        case EVENT_MOUSE_POINTER_MOVE:
            MouseOverGetsTableCell (panel, control, eventData2, eventData1, &rowIndex, &colIndex);
        break;
     }
 return 0;
}
 
 
Your custom function would be like this (the print statement was temporarily added for text reporting from this function):
 
 
static int __stdcall MouseOverGetsTableCell (int pnl, int ctrl, int msX, int msY, int *row, int *col)
{
    Rect   gridCoords;
    Point   hoverCell;
 
    /*----------------------------------------------------------------------*/
    GetTableCellRangeRect (pnl, ctrl, VAL_TABLE_ENTIRE_RANGE, &gridCoords);
    GetTableCellFromPoint (pnl, ctrl, MakePoint (msX, msY), &hoverCell);
 
    printf ("Row = %4d, Col = %4d.\n", hoverCell.y, hoverCell.x);
 
    *row = hoverCell.y;
    *col = hoverCell.x;
    return 0;
}
 
You will notice that when you hover over the row labels and the column labels, it will report erroneous cell values.
 
I already got a fix for this for my use, using a technique from one of the CVI samples.
 
Insert the following where the "/*----*/" comment is located and add the appropriate Rect and int variables:
 
 
    GetTableCellRangeRect (pnl, ctrl, VAL_TABLE_ENTIRE_RANGE, &labelCoords);
    GetCtrlAttribute (pnl, ctrl,  ATTR_ROW_LABELS_WIDTH, &labelCoords.width);
    GetCtrlAttribute (pnl, ctrl, ATTR_GRID_AREA_LEFT, &gridLeft);
    GetCtrlAttribute (pnl, ctrl, ATTR_LEFT, &tableLeft);
    labelCoords.left = tableLeft + gridLeft - labelCoords.width;
    if (RectContainsPoint (labelCoords, MakePoint (msX, msY))) {
        *row = 0;
        *col = 0;
        printf ("Mouse is over row label area.\n");
        return 0;
    }
    GetTableCellRangeRect (pnl, ctrl, VAL_TABLE_ENTIRE_RANGE, &labelCoords);
    GetCtrlAttribute (pnl, ctrl, ATTR_COLUMN_LABELS_HEIGHT, &labelCoords.height);
    GetCtrlAttribute (pnl, ctrl, ATTR_GRID_AREA_TOP, &gridTop);
    GetCtrlAttribute (pnl, ctrl, ATTR_TOP, &tableTop);
    labelCoords.top = tableTop + gridTop - labelCoords.height;
    if (RectContainsPoint (labelCoords, MakePoint (msX, msY))) {
        *row = 0;
        *col = 0;
        printf ("Mouse is over col label area.\n");
        return 0;
    }
 
Does anyone have any comments on whether this is a CVI bug or not?
I don't recall that behavior before, and I think I was using tables ever since they first appeared...
 
JB
 
 
 
--
To whom it may concern: My alias is also my nickname, I've had it since I was a (very) skinny basketball-playing teen. OK, so I've got a 38 inch waist now, but my hometown friends haven't shaken that appellation for me. I trust that you will someday be OK with that alias, as I have been with that nickname.
0 Kudos
Message 1 of 4
(3,437 Views)
I just tried to replicate this and was unable to get the same results. The output (without the added code you provided) gave me the correct values. It is possible that something has gone wrong with you CVI installation. Try repairing the installation or possibly uninstalling and reinstalling.

Brandon Vasquez | Software Engineer | Integration Services | National Instruments
0 Kudos
Message 2 of 4
(3,412 Views)
Hello JB,

I noticed that when I hover over the column labels, and the table is not scrolled all the way to the top, the values returned are not (0,0) as you'd expect, but isntead correspond to the row that would be "behind" the column labels. And the same thing happens with the row labels, if the table is not scrolled all the way to the left.

I'll have to investigate this a bit further, but at first glance, this does seem like a bug. Thanks for reporting this!

Luis
0 Kudos
Message 3 of 4
(3,404 Views)
Sorry that in my original posting I forgot to say that you've got to push either of the two scroll bars to some percentage of their scrolling range, and *then* move your cursor outside the grid area and over the label areas in order to see the behavior that Luis and I were able to see. I guess I was too busy cutting and pasting the code that discovered and fixed this bug...

That fix I gave solves it for me for now, and I don't suspect that this would be a show-stopper for many CVI users. So I guess that this can be a back-burner bug-fix for a future revision. Which means that I still won't get a free NI T-shirt for finding a bug in CVI! :^)

But this is a good thing, really...

JB
--
To whom it may concern: My alias is also my nickname, I've had it since I was a (very) skinny basketball-playing teen. OK, so I've got a 38 inch waist now, but my hometown friends haven't shaken that appellation for me. I trust that you will someday be OK with that alias, as I have been with that nickname.
0 Kudos
Message 4 of 4
(3,379 Views)