Board index » delphi » Preventing Dataset Scrolling...

Preventing Dataset Scrolling...

I'm using a TRichEdit control coupled with a TDBGrid control
(attached via ADO objects). The TRichedit control, when
populated, parses the contents for particular string matches
and highlights matched text accordingly.

Is there a direct way to prevent subsequent Dataset record
movement while parsing of the TRichEdit control takes place?

The dilemma occurs if a user moves the record pointer via
the DBGrid control while the TRichEdit control is being
parsed. The Parsing routing gets called again (recursively
as a result of record movement) before the first call may
have completed, thus reeking extreme havoc on both the
DBGrid control and the TRichEdit control (control repainting
methods flip-out and produce some eerie visual effects).

The adverse reactions only happen if a user moves through
the table rapidly (sliding the scroll bar on the DBGrid
control). Simple moving a single record at a time causes no
problems.

Ideally, I'd like to prevent record movement until the
parsing routine has completed, however, Dataset events such
as BeforeScroll do not offer a property for circumventing
record movement.

thanks,
Blaise...

 

Re:Preventing Dataset Scrolling...


Quote
> Ideally, I'd like to prevent record movement until the
> parsing routine has completed, however, Dataset events such
> as BeforeScroll do not offer a property for circumventing
> record movement.

Have you tried using the Abort procedure in the BeforeScroll and see if that
stops the scrolling?

Re:Preventing Dataset Scrolling...


Actually, after posting the message I tried "abort" and yes,
it works (imagine that -- duhhhh). Admittedly, it's not the
most graceful approach as it's equal to an (silent)
exception, but it does stops the scrolling.

Thanks for the suggestion.

Blaise...

"Michael P. Schneider" <mich...@sbpaaimt.{*word*104}magician.net>
wrote in message news:3b8e869f_2@dnews...

Quote
> > Ideally, I'd like to prevent record movement until the
> > parsing routine has completed, however, Dataset events
such
> > as BeforeScroll do not offer a property for
circumventing
> > record movement.

> Have you tried using the Abort procedure in the

BeforeScroll and see if that
Quote
> stops the scrolling?

Re:Preventing Dataset Scrolling...


Quote
"Blaise" <mgath...@pacbell.net> wrote in message news:3b8e9b3f_1@dnews...
> Actually, after posting the message I tried "abort" and yes,
> it works (imagine that -- duhhhh). Admittedly, it's not the
> most graceful approach as it's equal to an (silent)
> exception, but it does stops the scrolling.

The other option I was thinking about was to have a method of exiting the
parse state when it knows that something else triggered a new parse.

I'm thinking of something like the following {somewhere else at
form/module/global scope}:
  const
    StaticParseCounter : integer = 0;

procedure ParseIt;
  var
    LocalParseCounter : integer;
  begin
    inc( StaticParseCounter );
    LocalParseCounter :=  StaticParseCounter;
    while ( ...... ) do
      begin
        ... Do Parsing
        if ( StaticParseCounter <> LocalParseCounter ) then
          begin
            Exit;
          end;
      end;  file://while
  end;

My thought is to just canceling the parse when it noticies that something
else has triggered a parse.  The idea being that the latter parse is the one
that actually needs to finish and the previous one(s) can just cancel out
safely.

This example doesn't handle any locking issues and isn't thread safe but I
hope the concept gets through.

Quote
> Thanks for the suggestion.

You are very welcome [grin]

Michael P. Schneider

Other Threads