Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Which component to use to make a terminal-emulation programm

Posted on 2006-07-02
10
Medium Priority
?
304 Views
Last Modified: 2010-04-05
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
0
Comment
Question by:peterkiers
10 Comments
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 17028064
Is this for connecting to terminal services, or your own custom method?
0
 
LVL 3

Expert Comment

by:Ubethatway
ID: 17028665
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
0
 
LVL 1

Author Comment

by:peterkiers
ID: 17029614
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
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 3

Expert Comment

by:Ubethatway
ID: 17029902
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.
0
 
LVL 1

Author Comment

by:peterkiers
ID: 17030063

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.
0
 
LVL 11

Expert Comment

by:calinutz
ID: 17030169
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
0
 
LVL 1

Author Comment

by:peterkiers
ID: 17031519
I have put it on my site:

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

Click on download and you see the ZQJEme32703.zip

P.
0
 
LVL 3

Expert Comment

by:Ubethatway
ID: 17034658
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
0
 
LVL 1

Author Comment

by:peterkiers
ID: 17035730
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.
0
 
LVL 3

Accepted Solution

by:
Ubethatway earned 1500 total points
ID: 17035880
the simplest way to do it would be to change the font size to something more suitable on the form resize event:

procedure Tscreenf.FormResize(Sender: TObject);
var
  TxMetric: TTextMetric ;
begin
// CHANGE FONT PROCEDURE GOES HERE

//  ClientHeight := SCRROWS * FontHeightPix + (FontHeightPix+2);
//  ClientWidth := SCRCOLS * FontWidthPix ;
end;

You will need to work out a more suitable font size based on the height/width of the form (i.e. the values of ClientHeight & ClientWidth).

You can the either change to the new font, and leave it at that...or change to the new font and resize the form back to the propper proportions based on the original specs (i.e leave the two original lines in the resize procedure)

Mark
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question