Peter Kiers
asked on
Statusbar doesn't resize with the form
Hello,
I am still working on a Terminal-emulation component.
Now I have made a statusbar, that looks like this:
procedure TDSP3270.ShowStatus;
var
StatY, SepX, SepY: integer ;
begin
SepX := FSCRCOLS * FFontWidthPix ;
SepY := FSCRROWS * FFontHeightPix ;
StatY := FSCRROWS * FFontHeightPix + (FFontHeightPix+2) ;
with Canvas do
begin
{ draw seperator line }
Pen.Mode := pmCopy ;
Pen.Color := FColorWhite ;
Brush.Style := bsClear ;
Brush.Color := FColorBlack ;
MoveTo(0,SepY) ;
LineTo(SepX,SepY) ;
{ display row and column indicator }
Font.Color := FColorWhite ;
TextOut(FFontWidthPix*74,S epY+2,Form at('%.2d/% .3d',
[FCsrRow,FCsrCol])) ;
end ;
end ;
Now my problem is when i resize the form the statusbar
doesn't resize with it.
How can I make my statusbar resizeable, and what do
I have to put in the Resize-event.
Greetings,
Peter Kiers
I am still working on a Terminal-emulation component.
Now I have made a statusbar, that looks like this:
procedure TDSP3270.ShowStatus;
var
StatY, SepX, SepY: integer ;
begin
SepX := FSCRCOLS * FFontWidthPix ;
SepY := FSCRROWS * FFontHeightPix ;
StatY := FSCRROWS * FFontHeightPix + (FFontHeightPix+2) ;
with Canvas do
begin
{ draw seperator line }
Pen.Mode := pmCopy ;
Pen.Color := FColorWhite ;
Brush.Style := bsClear ;
Brush.Color := FColorBlack ;
MoveTo(0,SepY) ;
LineTo(SepX,SepY) ;
{ display row and column indicator }
Font.Color := FColorWhite ;
TextOut(FFontWidthPix*74,S
[FCsrRow,FCsrCol])) ;
end ;
end ;
Now my problem is when i resize the form the statusbar
doesn't resize with it.
How can I make my statusbar resizeable, and what do
I have to put in the Resize-event.
Greetings,
Peter Kiers
Is this status bar aligned to the bottom of the form and it doesnt resize?
is your statusbar part of the display component? if so, you will have to track the resize of the component (when the component resizez you also resize your statusbar)
if the statusbar is a descendant of TStatusBar, then as mike suggested, you need to make the statusbar align at the bottom; if you don't want that, then just resize the statusbar when the form/component resizez.
byt better give out full information as not everybody knows what you are doing ;)
if the statusbar is a descendant of TStatusBar, then as mike suggested, you need to make the statusbar align at the bottom; if you don't want that, then just resize the statusbar when the form/component resizez.
byt better give out full information as not everybody knows what you are doing ;)
ASKER
Yes, the statusbar is aligned to the bottom of the form.
procedure TDSP3270.Paint;
var
TxMetric: TTextMetric ;
begin
Canvas.Font.Size := FFontSize ;
Canvas.Font.Name := FFontName ;
GetTextMetrics(Canvas.Hand le,TxMetri c) ;
FFontWidthPix := TxMetric.tmMaxCharWidth ;
FFontHeightPix := TxMetric.tmHeight ;
Height := fSCRROWS * fFontHeightPix + (fFontHeightPix+2) ;
Width := fSCRCOLS * fFontWidthPix ;
ClearBuf ;
ShowBuf ;
end;
procedure TDSP3270.ShowBuf;
var
i, j: integer ;
begin
with Canvas do
begin
Brush.Style := bsSolid ;
Brush.Color := FColorBlack ;
FillRect(ClipRect) ;
end ;
for i := 1 to fSCRROWS do
for j := 1 to fSCRCOLS do
DispCell(j,i,false) ;
DrawCursor(FCsrCol,FCsrRow ) ;
ShowStatus ;
end;
p.
procedure TDSP3270.Paint;
var
TxMetric: TTextMetric ;
begin
Canvas.Font.Size := FFontSize ;
Canvas.Font.Name := FFontName ;
GetTextMetrics(Canvas.Hand
FFontWidthPix := TxMetric.tmMaxCharWidth ;
FFontHeightPix := TxMetric.tmHeight ;
Height := fSCRROWS * fFontHeightPix + (fFontHeightPix+2) ;
Width := fSCRCOLS * fFontWidthPix ;
ClearBuf ;
ShowBuf ;
end;
procedure TDSP3270.ShowBuf;
var
i, j: integer ;
begin
with Canvas do
begin
Brush.Style := bsSolid ;
Brush.Color := FColorBlack ;
FillRect(ClipRect) ;
end ;
for i := 1 to fSCRROWS do
for j := 1 to fSCRCOLS do
DispCell(j,i,false) ;
DrawCursor(FCsrCol,FCsrRow
ShowStatus ;
end;
p.
can you confirm/infirm that the statusbar is the same thing as delphi's TStatusBar? because it looks ackward that procedure TDSP3270.ShowStatus; accesses teh canvas directly to display the status information.
ASKER
No, I have not use the TStatusbar, I have draw my own on the canvas.
Peter
Peter
ASKER
Oke, I try another approach:
I have found an good example on the internet:
Procedure TDSP5250.Paint;
var
r:TRect;
a,c:char;
l1,l2,c1,c2:integer;
x,y,o:integer;
s:string;
begin
r:=Canvas.ClipRect;
if r.Bottom>=fStatusRect.Top then begin
Canvas.Brush.Color:=fStatu sColor;
Canvas.FillRect(fStatusRec t);
x:=fFontWidth div 2;
y:=fStatusRect.Top;
TextAttr:=$22;
Canvas.TextOut(x,y,fStatus );
if fInsert then Canvas.TextOut(Width div 2,y,'I');
s:=IntToStr(WhereX)+'/'+In tToStr(Whe reY);
Canvas.TextOut(Width-Canva s.TextWidt h(s)-x,y,s );
dec(y);
Canvas.Pen.Color:=clWhite;
Canvas.MoveTo(0,y);
Canvas.LineTo(Width,y);
end;
end;
How can I implement the code below (where the column and row indicator is drawn) in
the code above?
with Canvas do
begin
{ display row and column indicator }
Font.Color := FColorWhite ;
TextOut(FFontWidthPix*74,S epY+2,Form at('%.2d/% .3d',
[FCsrRow,FCsrCol])) ;
end ;
end ;
Peter
I have found an good example on the internet:
Procedure TDSP5250.Paint;
var
r:TRect;
a,c:char;
l1,l2,c1,c2:integer;
x,y,o:integer;
s:string;
begin
r:=Canvas.ClipRect;
if r.Bottom>=fStatusRect.Top then begin
Canvas.Brush.Color:=fStatu
Canvas.FillRect(fStatusRec
x:=fFontWidth div 2;
y:=fStatusRect.Top;
TextAttr:=$22;
Canvas.TextOut(x,y,fStatus
if fInsert then Canvas.TextOut(Width div 2,y,'I');
s:=IntToStr(WhereX)+'/'+In
Canvas.TextOut(Width-Canva
dec(y);
Canvas.Pen.Color:=clWhite;
Canvas.MoveTo(0,y);
Canvas.LineTo(Width,y);
end;
end;
How can I implement the code below (where the column and row indicator is drawn) in
the code above?
with Canvas do
begin
{ display row and column indicator }
Font.Color := FColorWhite ;
TextOut(FFontWidthPix*74,S
[FCsrRow,FCsrCol])) ;
end ;
end ;
Peter
what is 74? since it's hardcoded, it is likely to cause the issue.
ASKER
I don't know either!
well 74 is in YOUR code, you should know about it. from what it looks to me, it influences the position of the separator on teh x axis but that's all I can say about it.
also, I need you to confirm/infirm the following: you resize the component, but the statusbar does not resize. true?
can you post the code that takes care of component resizeing?
also, I need you to confirm/infirm the following: you resize the component, but the statusbar does not resize. true?
can you post the code that takes care of component resizeing?
ASKER
TRUE.
procedure TDSP3270.WMSize(var Msg: TWMSize);
begin
inherited;
Resize;
end;
procedure TDSP3270.Resize;
begin
inherited;
fFontWidthPix :=ClientWidth div (fSCRCOLS);
fFontHeightPix:=(ClientHei ght-2) div (fSCRROWS+1);
end;
procedure TDSP3270.WMSize(var Msg: TWMSize);
begin
inherited;
Resize;
end;
procedure TDSP3270.Resize;
begin
inherited;
fFontWidthPix :=ClientWidth div (fSCRCOLS);
fFontHeightPix:=(ClientHei
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.