Recent

Author Topic: status bar and image  (Read 8913 times)

cpalx

  • Hero Member
  • *****
  • Posts: 753
status bar and image
« on: March 27, 2010, 11:48:55 pm »

hello i am using lazarus un Ubuntu Linux i would like to add some image (16x16) in my statusbar, but display nothing i used this code:

*********************************
procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
  Panel: TStatusPanel; const Rect: TRect);
begin
   with StatusBar1.Canvas do
  begin
    Brush.Color := clBtnFace;
    FillRect(Rect);
    Font.Color := clblack;
    Imagelist1.Draw(StatusBar1.Canvas,Rect.Left,Rect.Top,2);
    TextOut(Rect.left + 20, Rect.top + 2,Message1[0]);
    refresh;
End;
end;               
*********************************

i read some post that in linux we have to do this else
*********************************
sbMain:TStatusBar
function GetPanelBounds:TRect;
{$ifdef Linux}
sbMainDrawPanel(sbMain,sbMain.Panels[0],GetPanelBounds(sbMain.Panels[0]));
{$endif}
*********************************

but i dont understarnd the last code

i guest i call to Drawpanel function but what GetPanelBounds is?, looks like a function but ...

any tips please ...


Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: status bar and image
« Reply #1 on: March 28, 2010, 12:26:22 am »
It's a bug (http://bugs.freepascal.org/view.php?id=14495) but you can call the method manually.
Lazarus 1.7 (SVN) FPC 3.0.0

cpalx

  • Hero Member
  • *****
  • Posts: 753
Re: status bar and image
« Reply #2 on: March 28, 2010, 01:17:53 am »
and how would be

GetPanelBounds(sbMain.Panels[0]) ???

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: status bar and image
« Reply #3 on: March 28, 2010, 10:47:51 am »
OnDrawPanel is defined as DrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel; const Rect: TRect). I'm using a function GetPanelBounds():TRect in my code to calculate the Rect parameter of that event handler.

Code: [Select]
function TfmMain.GetPanelBounds(PanelID: byte): TRect;
var i:integer;
begin
  Result.Top:=1;
  Result.Bottom:=sbMain.Height-2;
  Result.Left:=0;
  for i:=0 to PanelID-1 do
    Result.Left:=Result.Left+sbMain.Panels[i].Width;
  Result.Right:=Result.Left+sbMain.Panels[PanelID].Width;
end;
Lazarus 1.7 (SVN) FPC 3.0.0

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: status bar and image
« Reply #4 on: June 03, 2010, 03:08:41 am »
Bug has been fixed in latest svn. You can use OwnerDraw()-method to paint on the canvas of statusbar.
Lazarus 1.7 (SVN) FPC 3.0.0

cpalx

  • Hero Member
  • *****
  • Posts: 753
Re: status bar and image
« Reply #5 on: June 03, 2010, 07:01:09 pm »
thanks for the reply, i will try now :p

 

TinyPortal © 2005-2018