Solved

Which component to use to make a terminal-emulation programm

Posted on 2006-07-02
10
292 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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 500 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now