Answered Browse Title bar

Laurent T

New Member
Hello,

I find a post for select a line in a browse with the right clik.
PS : I can't link the post
Code:
DEFINE VARIABLE iRowHeight   AS INTEGER     NO-UNDO.
DEFINE VARIABLE iLastY       AS INTEGER     NO-UNDO.
DEFINE VARIABLE iRow         AS INTEGER     NO-UNDO.
DEFINE VARIABLE hCell        AS HANDLE      NO-UNDO.
DEFINE VARIABLE iTopRowY     AS INTEGER     NO-UNDO.

/* See if there are ANY rows in view... */
IF SELF:NUM-ITERATIONS = 0 THEN
DO:
   /* No rows, the user clicked on an empty browse widget */
   RETURN NO-APPLY.
END.

/* We don't know which row was clicked on, we have to calculate it from the mouse coordinates and the row heights. No really. */
SELF:SELECT-ROW(1).               /* Select the first row so we can get the first cell. */
hCell      = SELF:FIRST-COLUMN.   /* Get the first cell so we can get the Y coord of the first row, and the height of cells. */
iTopRowY   = hCell:Y - 1.         /* The Y coord of the top of the top row relative to the browse widget. Had to subtract 1 pixel to get it accurate. */
iRowHeight = hCell:HEIGHT-PIXELS. /* SELF:ROW-HEIGHT-PIXELS is not the same as hCell:HEIGHT-PIXELS for some reason */
iLastY     = LAST-EVENT:Y.        /* The Y position of the mouse event (relative to the browse widget) */

/* calculate which row was clicked. Truncate so that it doesn't round clicks past the middle of the row up to the next row. */
iRow       = 1 + TRUNCATE((iLastY - iTopRowY) / iRowHeight, 0).

IF iRow > 0 AND iRow <= SELF:NUM-ITERATIONS THEN
DO:
  /* The user clicked on a populated row */
  Your coding here, for example:
  SELF:SELECT-ROW(iRow).
END.
ELSE DO:
  /* The click was on an empty row. */
  SELF:DESELECT-ROWS().
  RETURN NO-APPLY.
END.

This function works only if the browse don't get the "Title bar" activated.

I would like to adapt this procedure (dynamically) to take this parameter into account. But I don't find any TitleBar attribute for the browse.
Do you have any idea how i can know if the browse got it activated ? Ideally, i also need to know the height of it.

Thanks


Progress : 11.6.4
 
Back
Top