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

asked on

Client-window resize with the TTextMetric

Hi,

I'm making a 3270-component and I use a TTextMetric in the Paint-event.
When i change the size of the font in de Constructor-procedure the
TTextMetric gets larger. Is it possible to get the client-window resize with it.

procedure TDSP3333.Paint;
var
  TxMetric: TTextMetric ;
begin
  with Canvas do
      begin
        Brush.Style := bsSolid ;
        Brush.Color := fColorBlack ;
        FillRect(ClipRect) ;
    end ;
  Canvas.Font.Size := fFontSize ;
  Canvas.Font.Name := fFontName ;
  GetTextMetrics(Canvas.Handle,TxMetric) ;
  fFontWidthPix := TxMetric.tmAveCharWidth ;
  fFontHeightPix := TxMetric.tmHeight ;
  showbuf;
end;

procedure TDSP3333.ShowBuf;
var    i, j: integer ;
begin
    for i := 1 to fSCRROWS do
    for j := 1 to fSCRCOLS do
      DispCell(j,i,false) ;
    DrawCursor(fCsrCol,fCsrRow) ;    //drawcursor
  ShowStatus ;                               //draw statusbar
end;

Peter
Avatar of 2266180
2266180
Flag of United States of America image

well ... right now all I can think of is a simple way:
get the textmetrics of the component canvas (CC ) and the form canvas (FC)
it is matematically true (for your case with resize) that:
CC.height/CC.metric.fontheight = FC.height/FC.metric.fontheight
same for width
then, you know the cc.height/width, the cc.metric.fontheight/width and the fc.metric.fontheight/width so you calculate the dc.height/width from there :)
Avatar of Peter Kiers

ASKER

oeh!, I dont follow

Maybe something like this

procedure TDSP3270.Resize;
begin
  inherited;
  ClientHeight := .....
  ClientWidth := .....
end;

Peter
ASKER CERTIFIED SOLUTION
Avatar of 2266180
2266180
Flag of United States of America image

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
Thank you for the explenation. Now i understand.

Peter