Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scrolling String Grid

Status
Not open for further replies.

lespaul

Programmer
Feb 4, 2002
7,083
US
We have a program that displays the court docket for each courtroom on a monitor mounted outside the courtroom (think of an airline arrival/departure screen).

Anyway, this display scrolls information like this:

9:30 Criminal Trial
CR 123404 Joe Blow ..... other case information
CR 142404 Jane Doe ..... other case information
10:00 Bond Arraignment
DW 242103 John Smith ..... other case information
CR 525202 Mary Jones ..... other case information

So, if this is the beginning of the display, 9:30 Criminal Trial moves off the display and all you have is:

CR 123404 Joe Blow ..... other case information
CR 142404 Jane Doe ..... other case information
10:00 Bond Arraignment
DW 242103 John Smith ..... other case information
CR 525202 Mary Jones ..... other case information

What I'm looking for is a way to keep the title bar in row 1 until another title bar comes along and then replace the Row 1 with the new title.

So in this case

9:30 Criminal Trial

will stay in Row 1 of the string grid until 10:00 Bond Arraignment gets to the top. Then

10:00 Bond Arraignment

replaces the Criminal Trial title.

Anyone have any ideas on how to accomplish this?

Here's the code we are currently using to scroll the display:

Code:
procedure TForm_Main.Timer_ScrollTimer(Sender: TObject);
var
  J: integer;
begin
  with StrGrid_Docket do
  begin
    //set the row down at the bottom of the grid so display moves sooner
    if Row < 15 Then Row := 15;
    if Row = RowCount - 3
    then
      begin
        Timer_Scroll.Enabled:= False;
        for J:= 0 to 30 do    // leave the bottom displayed for ~ 3 sec.
        begin
          Sleep(30);         // (50 * 100 mS = 3 sec)
          Application.ProcessMessages;
        end;

        Row:= 1;             // then reset data to top of display.
        Update;
        Row:= 15;
        Timer_Scroll.Enabled:= True;
      end
    else
      if Row < RowCount - 1 then
        Row:= Row + 1;

  end;
end;




Leslie
 
Do the title bars always start with a time? Or not necessarily? Also, are the 2 entries below the title bar related to the title bar? Are there always 2 entries between title bars?

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Yes, there is always a time at the beginning of each title row. There is also different row color and font size for each title row. The 2 entries below the title row are the cases being heard at that time (the details for that hearing type and time). The number of rows in between each title can range from 1 to many. Thanks!

Leslie
 
I think that the best strategy is to write a scrolling string grid component which would be descended from TStringGrid.

Something like:
Code:
type
  TScrollingGrid = class(TStringGrid)
   private
    fTop: integer;   // top line
    fTimer: TTimer;  // Internal timer
    function GetInterval: cardinal;
    procedure SetInterval ( value: cardinal );
   public
    procedure OnDrawCell (Sender: TObject; ACol, ARow: Longint; Rect: TRect; State: TGridDrawState);
    constructor Create(AOwner: TComponent); override;
   published
    property Interval: cardinal read GetInterval write SetInterval;
  end;
You would also need to have a call back function to determine if a row was a title or not.

If you encapsulate everything in a class then it should be easier to debug and might make a worthwhile component that could be used in other applications.

Andrew
Hampshire, UK
 
That would be marvelous Andrew, but I don't know how to implement all that!! I've never created my own component like that. I've tried, never been successful and had to find some other, less efficient way.

I'm willing to give it a shot, if you're willing to give me a hand!!

Les
 
I agree with Andrew, creating a derived component would be a nice way to do it.

Should the data constantly scroll up (i.e. every few seconds) or should it only move up once the time associated with the previous title bar has passed?

For example,
At 09:15 the display reads:
9:30 Criminal Trial
CR 123404 Joe Blow ..... other case information
CR 142404 Jane Doe ..... other case information
10:00 Bond Arraignment
DW 242103 John Smith ..... other case information
CR 525202 Mary Jones ..... other case information
10:30 Criminal Trial
XW 242103 Mary Smith ..... other case information
RR 525202 Joe Doe ..... other case information

At 09:31 the display reads:
10:00 Bond Arraignment
DW 242103 John Smith ..... other case information
CR 525202 Mary Jones ..... other case information
10:30 Criminal Trial
XW 242103 Mary Smith ..... other case information
RR 525202 Joe Doe ..... other case information

At 10:01 the display reads:
10:30 Criminal Trial
XW 242103 Mary Smith ..... other case information
RR 525202 Joe Doe ..... other case information



Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Let's say that there are only 5 rows in the grid. The data below is what needs to be displayed from 8:00 am - 12:00 pm.


DATA:
9:30 Criminal Trial
CR 123404 Joe Blow ..... other case information
CR 142404 Jane Doe ..... other case information
10:00 Bond Arraignment
DW 242103 John Smith ..... other case information
CR 525202 Mary Jones ..... other case information
10:30 Criminal Trial
XW 242103 Mary Smith ..... other case information
RR 525202 Joe Doe ..... other case information


but like I said, there are only 5 rows in the grid (pretend that's all the rows that will fit on the monitor at a single time). So, the time line and display would be as follows:

Display 1 - current time = 9:00:00 am

9:30 Criminal Trial
CR 123404 Joe Blow ..... other case information
CR 142404 Jane Doe ..... other case information
10:00 Bond Arraignment
DW 242103 John Smith ..... other case information


Display 2 - 3 seconds later

CR 123404 Joe Blow ..... other case information
CR 142404 Jane Doe ..... other case information
10:00 Bond Arraignment
DW 242103 John Smith ..... other case information
CR 525202 Mary Jones ..... other case information


Display 3 - 3 seconds later

CR 142404 Jane Doe ..... other case information
10:00 Bond Arraignment
DW 242103 John Smith ..... other case information
CR 525202 Mary Jones ..... other case information
10:30 Criminal Trial


Display 4 - 3 seconds later

10:00 Bond Arraignment
DW 242103 John Smith ..... other case information
CR 525202 Mary Jones ..... other case information
10:30 Criminal Trial
XW 242103 Mary Smith ..... other case information


Display 5 - 3 seconds later

DW 242103 John Smith ..... other case information
CR 525202 Mary Jones ..... other case information
10:30 Criminal Trial
XW 242103 Mary Smith ..... other case information
RR 525202 Joe Doe ..... other case information


In Display 2 there is information being displayed about the 9:30 Criminal Trial, but the Title Row has already scrolled. Here's what I'd like to have happen:

Display 1 - current time = 9:00:00 am

9:30 Criminal Trial
CR 123404 Joe Blow ..... other case information
CR 142404 Jane Doe ..... other case information
10:00 Bond Arraignment
DW 242103 John Smith ..... other case information


Display 2 - 3 seconds later

9:30 Criminal Trial
CR 142404 Jane Doe ..... other case information
10:00 Bond Arraignment
DW 242103 John Smith ..... other case information
CR 525202 Mary Jones ..... other case information


Display 3 - 3 seconds later

10:00 Bond Arraignment
DW 242103 John Smith ..... other case information
CR 525202 Mary Jones ..... other case information
10:30 Criminal Trial
XW 242103 Mary Smith ..... other case information


Display 4 - 3 seconds later

10:00 Bond Arraignment
CR 525202 Mary Jones ..... other case information
10:30 Criminal Trial
XW 242103 Mary Smith ..... other case information
RR 525202 Joe Doe ..... other case information


Display 5 - 3 seconds later

10:30 Criminal Trial
XW 242103 Mary Smith ..... other case information
RR 525202 Joe Doe ..... other case information


So there is always a title row at the top at all times. Then, what currently happens when it reaches the end, it goes back to the top:

Display 6 - current time = 9:00:15 am

9:30 Criminal Trial
CR 123404 Joe Blow ..... other case information
CR 142404 Jane Doe ..... other case information
10:00 Bond Arraignment
DW 242103 John Smith ..... other case information


Hope this helps you visualize a little better what I'm trying to accomplish! Thanks for everyone's help!






Leslie
 
Les

I'm not going to write the component for you (well, not unless you pay me). But I'm prepared to offer advice where I can. Maybe Clive is too.

Like Clive, I'm a bit confused as to what exactly you want - but perhaps this doesn't matter as long as you're 100% certain.

Did you read and understand the FAQ on component writing?

Andrew
Hampshire, UK
 
OK, I'm checking out the FAQ on component writing and I'm going to give it a shot! I'm sure I'll need some assistance, and as much as I'd like to pay you to do it, I'm not sure my boss will!!


Leslie
 
I'm willing to give a hand where I can too. I now understand exactly what you are trying to do.
Here are a couple of pointers to set you on your way.

1) The TStringGrid component is quite well suited to your problem as it contains a useful property called FixedRows. FixedRows specifies the number of rows on the top of the grid that cannot be scrolled - so is well suited for your title bars.

2) There are a number of good tutorials on component writing (including Andrew's!)
Have a read of:
- -
Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top