Welcome! Log In Create A New Profile

Advanced

how detect if someone is scrolling in a table-control

Posted by Patrick Thijs 
Patrick Thijs
how detect if someone is scrolling in a table-control
July 09, 2009 01:27PM
Hello,

I'm searching for a way to detect if a user is scrolling in a table.
I need to know this because I have a routine that changes the color of a row based on the content of a certain column. This routine only needs to work when the table is filled (it is linked to a query), but NOT when a user scrolls in the table.
I'm using the Row_Display procedure of the tablecontrol to color the rows.
Perhaps there's a better way to do this ? But keep in mind that I'm working with quite large tables (> 50000 records) and "coloring" the rows must be done very fast

best regards,

Patrick
Piet van Zanten
Re: how detect if someone is scrolling in a table-control
July 09, 2009 02:16PM
Hi Patrick,

I think the row display code should work even if you are scrolling and it should work only on rows that are currently displayed, so no extra overhead.
Can you give the code you use in the row display section?

regards,
Piet
Patrick Thijs
Re: how detect if someone is scrolling in a table-control
July 09, 2009 02:23PM
Hello Piet,

I just want it NOT to update when I'm scrolling, the normal update seems to work fine.
But if it's updating only the visible records in a table, then I have a problem...

The code for the row display section is very simple
SWITCH tblTracks.Status
CASE 1 // on disk
tblTracks[tblTracks]..Color = iWhite

CASE 2 // on site
tblTracks[tblTracks]..Color = RGB(153,153,255)

CASE 3 // requested
tblTracks[tblTracks]..Color = RGB(255,128,0)

CASE 4 // new
tblTracks[tblTracks]..Color = RGB(255,255,0)

CASE 5 // favorite
tblTracks[tblTracks]..Color = iLightGreen
END
CASE 1 // on disk
tblTracks[tblTracks]..Color = iWhite

CASE 2 // on site
tblTracks[tblTracks]..Color = RGB(153,153,255)

CASE 3 // requested
tblTracks[tblTracks]..Color = RGB(255,128,0)

CASE 4 // new
tblTracks[tblTracks]..Color = RGB(255,255,0)

CASE 5 // favorite
tblTracks[tblTracks]..Color = iLightGreen
END
Patrick Thijs
Re: how detect if someone is scrolling in a table-control
July 09, 2009 02:23PM
Hello Piet,

I just want it NOT to update when I'm scrolling, the normal update seems to work fine.
But if it's updating only the visible records in a table, then I have a problem...

The code for the row display section is very simple

SWITCH tblTracks.Status
CASE 1 // on disk
tblTracks[tblTracks]..Color = iWhite

CASE 2 // on site
tblTracks[tblTracks]..Color = RGB(153,153,255)

CASE 3 // requested
tblTracks[tblTracks]..Color = RGB(255,128,0)

CASE 4 // new
tblTracks[tblTracks]..Color = RGB(255,255,0)

CASE 5 // favorite
tblTracks[tblTracks]..Color = iLightGreen
END
Alexandre Leclerc
Re: how detect if someone is scrolling in a table-control
July 09, 2009 02:39PM
Hi Patrick,

I think you have the best approach. There is indeed no overhead with this method, even if scrolling is a bit slower. The only other alternative you have is to parse the 50K+ rows immediately after the query has loaded the data in the table. But this would cause a slow initial display.

Best regards.
Piet van Zanten
Re: how detect if someone is scrolling in a table-control
July 09, 2009 04:10PM
Hi Patrick,

Sorry if I misunderstand your question, but as I see it, coloring the rows is only relevant for the displayed ones. It's not necessary to color ALL the rows.
The row display code does exactly that: the code is only executed if a row is displayed.
So if a user scrolls the table and new rows become visible they are colored as needed.
Note that you have to leave out the subscript in your code.

Regards,
Piet




Edited 1 time(s). Last edit at 07/09/2009 04:13PM by Piet van Zanten.
Piet van Zanten
Re: how detect if someone is scrolling in a table-control
July 09, 2009 04:21PM
Hi Patrick,

I think I'm mistaking here, because I can't think of a way to know the subscript of the row being displayed. You need the subscript to color a row.

Reagrds,
Piet
Piet van Zanten
Re: how detect if someone is scrolling in a table-control
July 09, 2009 04:39PM
Discard my previous post.
Just found a table in which I use this technique and it works fine
Row Display of table
IF col_Check[Table] THEN 
	Table[Table]..BrushColor=iLightRed
END
Regards,
Piet



Edited 1 time(s). Last edit at 07/09/2009 04:52PM by Piet van Zanten.
I agree with Piet,

But make sure you check the currentSubscript is greater then 0 or you will get an error if the table is empty.

//Set the color of the font for each row of the table
nRow is int = CurrentSubscript()

IF nRow > 0 THEN
IF NOT Table.COL_Comp_Status[nRow] THEN //
Table[nRow]..Color = DarkGray // Inactive calls
Table[nRow]..FontItalic = True
ELSE
Table[nRow]..Color = Default // All others
Table[nRow]..FontItalic = False
END
END

Dennis



Edited 1 time(s). Last edit at 07/09/2009 09:38PM by Dennis W.
Fabrice Harari.pcs.crosspost
Re: how detect if someone is scrolling in a table-control
July 10, 2009 01:34PM
Hi Dennis

if the code is the Row Display area, then there IS a row, and the
subscript cannot be 0

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

More information on [www.fabriceharari.com]


Dennis W wrote:
> I agree with Piet,
> But make sure you check the currentSubscript is greater then 0 or you will get an error if the table is empty.
> //Set the color of the font for each row of the table
> nRow is int = CurrentSubscript()
> IF nRow > 0 THEN
> IF NOT Table.COL_Comp_Status[nRow] THEN //
> Table[nRow]..Color = DarkGray // Inactive calls
> Table[nRow]..FontItalic = True
> ELSE
> Table[nRow]..Color = Default // All others
> Table[nRow]..FontItalic = False
> END
> END
> Dennis
>
Message forwarded from pcsoft.us.windev
Hi Patrick,

what do you think of this?

wiEvent = Event(lpTest,Table_Klant..Name,1750)

PROCEDURE lpTest()
   Trace(_EVE.nom,_EVE.wMessage,_EVE.wParam,_EVE.lParam)

with _EVE.lParam = the index of the first visible row in the table during scrolling.

Kind regards
Xavier
----------------------------
Xavier Schauwvlieghe
Micronaos bvba
WinDev/WebDev/Mobile consultant
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: