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

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,SepY+2,Format('%.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
Avatar of Mike Littlewood
Mike Littlewood
Flag of United Kingdom of Great Britain and Northern Ireland image

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 ;)
Avatar of Peter Kiers

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.Handle,TxMetric) ;
  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.
No, I have not use the TStatusbar, I have draw my own on the canvas.

Peter
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:=fStatusColor;
   Canvas.FillRect(fStatusRect);
   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)+'/'+IntToStr(WhereY);
   Canvas.TextOut(Width-Canvas.TextWidth(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,SepY+2,Format('%.2d/%.3d',  
         [FCsrRow,FCsrCol])) ;
        end ;
  end ;

Peter
what is 74? since it's hardcoded, it is likely to cause the issue.
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?

TRUE.

procedure TDSP3270.WMSize(var Msg: TWMSize);
begin
   inherited;
  Resize;
end;

procedure TDSP3270.Resize;
begin
  inherited;
  fFontWidthPix :=ClientWidth  div (fSCRCOLS);
  fFontHeightPix:=(ClientHeight-2) div (fSCRROWS+1);
end;

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