Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2000-11

Text mode windows

6 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

This questions is for go32v2 and win32...

I'm writing a text mode status program that has 5 different windows on the screen, all displaying various information that changes every few seconds. I'm using the window () procedure to create the windows and have a simple (?) question; can the windows be assigned a "name" somehow? When the program first loads it draws the windows, but then I have no smooth way of switching between them, other then to call the window () procedure again with the exact same parameters. To me, this seems wrong but I haven't been able to determine how to name a window so I can just put calls in the code to MainWindow, TimerWindow, etc. Is there a better way to do this??

TIA.

Jim Wilson

Reply by email

Jeff Wormsley
to Unknown author
AM wrote
To me, this seems wrong but I haven't been able to determine how to name a window so I can just put calls in the code to MainWindow, TimerWindow, etc. Is there a better way to do this??

Can you encapsulate the window functionality in a class? I am not sure how the window unit works, as I have always done direct screen writes (and the Win32 equivalent). From what little I remember, you don't get a "handle" to the window, per se, so you can't really store it as a named thing. Perhaps this would work...

Type
 TTextWindow = Class (TObject)
  private
   FLeft,
   FRight,
   FTop,
   FBottom : Byte;
   FCursorX,
   FCursorY : Byte;
   procedure SaveWindow;
   procedure RestoreWindow;
  public
   constructor Create(Top, Left, Bottom, Right : Byte); override;
   procedure WinWrite(S: String);
   procedure WinWriteXY(S: String);
   procedure WinClrScrn;
   procedure WinGotoXY(X,Y: Byte);
  end;
constructor TTextWindow.Create(Top, Left, Bottom, Right : Byte);
Begin
 inherited Create;
 FTop := Top;
 FLeft := Left;
 FBottom := Bottom;
 FRight := Right;
 Window(FTop, FLeft, FBottom, FRight);
 SaveWindow;
End;
Procedure TTextWindow.SaveWindow;
Begin
 FCursorX := WhereX;
 FCursorY := WhereY;
End;
Procedure TTextWindow.RestoreWindow;
Begin
 Window(FTop, FLeft, FBottom, FRight);
 GotoXY(FCursorX, FCursorY);
End;
procedure TTextWindow.WinWrite(S: String);
Begin
 RestoreWindow;
 Write(S);
 SaveWindow;
End;
procedure TTextWindow.WinWriteln(S: String);
Begin
 RestoreWindow;
 Writeln(S);
 SaveWindow;
End;
procedure TTextWindow.WinClrScrn;
Begin
 RestoreWindow;
 ClrScrn;
 SaveWindow;
End;
procedure TTextWindow.WinGotoXY(X,Y: Byte);
Begin
 RestoreWindow;
 GotoXY(X,Y);
 SaveWindow;
End;
Var
 MyFirstWindow, MySecondWindow : TTextWindow;
Begin
 MyFirstWindow := TTextWindow.Create(1,1,10,40);
 MySecondWindow := TTextWindow.Create(11,1,21,40);
 MyFirstWindow.WinWriteln('Hello');
 MySecondWindow.WinWriteln('Hello');
 MyFirstWindow.WinWriteln('Hello Again');
 MySecondWindow.WinWriteln('Hello Again');
 MyFirstWindow.Free;
 MySecondWindow.Free;
End;

This is totally untested, and obviously you'll want more (like text attributes and so on) but it should be close to what you need. Just remember that you can't overlap windows with this approach (well, you can, but it would be ugly...)

Hope this helps,
Jeff.

Reply by email

Unknown author
Show quoted text 5 lines
Can you encapsulate the window functionality in a class? I am not sure how the window unit works, as I have always done direct screen writes (and the Win32 equivalent). From what little I remember, you don't get a "handle" to the window, per se, so you can't really store it as a named thing. Perhaps this would work...

Thanks for the help -- I'll give that a try (although, I'm shamed to admit it, but I've never worked with objects yet so it may be a stretch for me to do). I guess I was just hoping that there'd be some simply thing I was overlooking...

Jim

Reply by email

Marco van de Voort
to Unknown author
Show quoted text 10 lines
> Can you encapsulate the window functionality in a class? I am not > sure how the window unit works, as I have always done direct screen > writes (and the Win32 equivalent). From what little I remember, you > don't get a "handle" to the window, per se, so you can't really > store it as a named thing. Perhaps this would work... Thanks for the help -- I'll give that a try (although, I'm shamed to admit it, but I've never worked with objects yet so it may be a stretch for me to do). I guess I was just hoping that there'd be some simply thing I was overlooking...

In my source archive downloadable from

www.stack.nl/~marcov/xtdfpc.htm

there is a handle based unit called EWindows, which implements simple handle based textwindowing.

Reply by email

Unknown author
In my source archive downloadable from www.stack.nl/~marcov/xtdfpc.htm there is a handle based unit called EWindows, which implements simple handle based textwindowing.

Thanks for the help -- I'll get a copy and try it out.

Jim

Reply by email

Marco van de Voort
to Unknown author
Show quoted text 6 lines
> In my source archive downloadable from > www.stack.nl/~marcov/xtdfpc.htm > there is a handle based unit called EWindows, which implements > simple handle based textwindowing. Thanks for the help -- I'll get a copy and try it out.

The package was last tested with 0.99.14b. If you find problems, mail me.

Marco van de Voort ( or )

Reply by email