LB-Get first selected row

From Vectorlab
Jump to: navigation, search


Gets the first selected row in a List Browser. Returns the string (or empty string) and the image (or -1). By Orso B. Schmid

{ Orso ******************************************** }
{ gets the first selected row IN RANGE OF SELECTED ROWS. returns -1 if no selection. Gets the string and image }
FUNCTION LB_GetFirstSelRow(d, LB: LONGINT; col: INTEGER; VAR LBstr: STRING; VAR LBimg: INTEGER): INTEGER;
	VAR
		i, selRow : INTEGER;
		temp_b : BOOLEAN;
		
	BEGIN
		i := 0;
		selRow := -1;
		
		IF GetNumSelectedLBItems(d, LB) > 0 THEN
			WHILE selRow = -1 DO BEGIN { find first sel row }
				IF IsLBItemSelected(d, LB, i) THEN BEGIN
					temp_b := GetLBItemInfo(d, LB, i, col, LBstr, LBimg);
					selRow := i;
				END;
				
				i := i + 1;
			END;
			
		LB_GetFirstSelRow := selRow;
	END;