Link to home
Start Free TrialLog in
Avatar of Peter Kiers
Peter KiersFlag for Netherlands

asked on

Which component to use to make a terminal-emulation programm

HI Experts,

I need your advice?

I want to make a Terminal-Emulation programm.

Which existing-component can I use best to put on the form.
or is it possible to use the canvas of the form itself ?

But whatever the advice is, it has to do the following:

When the user resizes the form, the component
has to resize with it.

Offcourse, examples are very welcom.

Greetings,

Peter Kiers
Avatar of TheRealLoki
TheRealLoki
Flag of New Zealand image

Is this for connecting to terminal services, or your own custom method?
Avatar of Ubethatway
Ubethatway

If you simply want to make a command-line app, you dont need any components, it is just a certain type of delphi application. The you could simply execute it from the command line and all your output would be through the standard commandline for the OS...

If you specifically wish to run the app in a window, then i think the Memo component will possibly meet your requirements, but you may need to write a bit of code to get it behaving the way you want, scrolling etc...

To get it to resize with the window all you should need to do is set its anchor and resize properties to what you need.

Hope that helps, Mark
Avatar of Peter Kiers

ASKER

Hi,

Thank you for all the reactions.

The question from TheRealLoki is dont understand, forgive me
i am Dutch, my English is very bad.

andf for Ubethatway: No, it's not a command-line app.

My problem:

I have found a terminal-emulation programm on the internet that uses
a TImage for displaying the output receiving from the host.

It works fine, only there is one thing I'm not sadisfied:
When the user resizes the form, the TImage does not resize with it.

Is there a way to fix that, or is there a better way, maybe
by using another component, or use the canvas of the form itself.

greetings,

Peter Kiers
Hi,

I believe that you should simply be able to change the properties of the TImage component to get it to rersize with the form. I don't have access to a copy of Delphi atm, so i cant give you the exact name of the property you need to change, but theres a property which has a value that ends in ???client...that should set the Timage to be the full size of the orm canvas. Just play around with the properties that control how the component is displayed and you should find an answer.

Sorry i couldnt be more specific, Mark.

mmm, i think i am thinking wrong.

Because when the user changes the font to a bigger font the screen gets bigger.

Is it perhaps possible to programm in the resize-event of the Timage
that when the user resizes the form the font increase / decreases with it.

This is the procedure for changing font:

procedure Tscreenf.ChangeFont1Click(Sender: TObject);
var
  TxMetric: TTextMetric ;
begin
  FontDialog1.Font := ScrImage1.Canvas.Font ;
  if FontDialog1.Execute() then
    begin
      ScrImage1.Canvas.Font := FontDialog1.Font ;
      FontSize := ScrImage1.Canvas.Font.Size ;
      FontName := ScrImage1.Canvas.Font.Name ;

      { get the cell size based on the current font, calculate and set }
      { the client window size and the image area size }
      GetTextMetrics(ScrImage1.Canvas.Handle,TxMetric) ;
      FontWidthPix := TxMetric.tmMaxCharWidth ;
      FontHeightPix := TxMetric.tmHeight ;
      ScrImage1.Picture.Graphic.Height := SCRROWS * FontHeightPix
        + (FontHeightPix+2) ;
      ScrImage1.Picture.Graphic.Width := SCRCOLS * FontWidthPix ;

      { set client area after image size has been set }
      ClientHeight := SCRROWS * FontHeightPix + (FontHeightPix+2) ;
      ClientWidth := SCRCOLS * FontWidthPix ;

      { re-show the current screen }
      ShowBuf ;
    end  ;
end;

procedure Tscreenf.FormCreate(Sender: TObject);
var
  TxMetric: TTextMetric ;
  Bitmap: TBitmap ;
begin
   
  SCRCOLS := 80 ;
   SCRROWS := 24 ;
 
  { get the cell size based on the current font, calculate and set }
  { the client window size and the image area size }
  Bitmap := TBitmap.Create ;
  ScrImage1.Canvas.Font.Size := FontSize ;
  ScrImage1.Canvas.Font.Name := FontName ;
  GetTextMetrics(ScrImage1.Canvas.Handle,TxMetric) ;
  FontWidthPix := TxMetric.tmMaxCharWidth ;
  FontHeightPix := TxMetric.tmHeight ;
  Bitmap.Height := SCRROWS * FontHeightPix + (FontHeightPix+2) ;
  Bitmap.Width := SCRCOLS * FontWidthPix ;
  ScrImage1.Picture.Graphic := Bitmap ;
  ScrImage1.Canvas.Font.Size := FontSize ;
  ScrImage1.Canvas.Font.Name := FontName ;

  { set client area after image size has been set }
  ClientHeight := SCRROWS * FontHeightPix + (FontHeightPix+2) ;
  ClientWidth := SCRCOLS * FontWidthPix ;

  { create and show the initial screen }
  ClearBuf ;
  ShowBuf ;
end;

procedure Tscreenf.FormResize(Sender: TObject);
var
  TxMetric: TTextMetric ;
begin
  ClientHeight := SCRROWS * FontHeightPix + (FontHeightPix+2);
  ClientWidth := SCRCOLS * FontWidthPix ;
end;

Peter K.
You should give us the link to that terminal-emulation programm on the internet that uses
a TImage for displaying the output receiving from the host.

This way we could analyze the source code and give you a more accurate answer

Regards
I have put it on my site:

http://members.home.nl/peterkiers/

Click on download and you see the ZQJEme32703.zip

P.
OK, the way to do this is to set the "Align" property of the component to "alClient", then set the "stretch" property of the TImage component to "true". The image will then be the full size of the client area whenever the form is resized.

Mark
When you do that, the font wil be stretched too, then the font
will be misformed.

I like your idea, but what can we do about the font.
maybe in de resize-event!

Peter.
ASKER CERTIFIED SOLUTION
Avatar of Ubethatway
Ubethatway

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial