Peter Kiers
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.Hand le,TxMetri c) ;
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
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.Hand
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
ShowStatus ; //draw statusbar
end;
Peter
ASKER
oeh!, I dont follow
Maybe something like this
procedure TDSP3270.Resize;
begin
inherited;
ClientHeight := .....
ClientWidth := .....
end;
Peter
Maybe something like this
procedure TDSP3270.Resize;
begin
inherited;
ClientHeight := .....
ClientWidth := .....
end;
Peter
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for the explenation. Now i understand.
Peter
Peter
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.fonthe
same for width
then, you know the cc.height/width, the cc.metric.fontheight/width