Selection rectangle in Mac OS X lazarus / 39-Graphics ---------------------------------------------------------------------- pedromdsantos · 2012-11-02 21:27 I need to create a selection rectangle on a paintbox or a form. The code works on Windows but not on Mac OS X. Can someone check the code and tell me how to fix it. I am not a programmer but sometimes I need to use Lazarus to do some routines just using the basics of pascal. I am using Lazarus 1.0.2, FPC 2.6.0, Carbon, Intel x86, Mountain Lion 10.8.2 TIA Pedro ---   TForm1 = class(TForm)     PaintBox1: TPaintBox;     procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;       Shift: TShiftState; X, Y: Integer);     procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X,       Y: Integer);     procedure PaintBox1MouseUp(Sender: TObject; Button: TMouseButton;       Shift: TShiftState; X, Y: Integer);   private     { private declarations }   public     { public declarations }   end; var   Form1: TForm1;   PontoInicial, PontoFinal: TPoint;   Arrastar: Boolean; implementation {$R *.lfm} { TForm1 } function RectSelec(PontoInicial, PontoFinal : TPoint) : TRect; begin   if PontoInicial.X < PontoFinal.X then   begin     RectSelec.Left := PontoInicial.X;     RectSelec.Right := PontoFinal.X;   end   else begin          RectSelec.Left := PontoFinal.X;          RectSelec.Right := PontoInicial.X;        end;   if PontoInicial.Y < PontoFinal.Y then   begin     RectSelec.Top    := PontoInicial.Y;     RectSelec.Bottom := PontoFinal.Y;   end   else begin          RectSelec.Top := PontoFinal.Y;          RectSelec.Bottom := PontoInicial.Y;       end; end; procedure TForm1.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;   Shift: TShiftState; X, Y: Integer); begin   PontoInicial.X := X;   PontoInicial.Y := Y;   PontoFinal.X := X;   PontoFinal.Y := Y;   PaintBox1.Canvas.DrawFocusRect(RectSelec(PontoInicial, PontoFinal));   Arrastar := True; end; procedure TForm1.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X,   Y: Integer); begin   if Arrastar = True then   begin     PaintBox1.Canvas.DrawFocusRect(RectSelec(PontoInicial, PontoFinal));     PontoFinal.X := X;     PontoFinal.Y := Y;     PaintBox1.Canvas.DrawFocusRect(RectSelec(PontoInicial, PontoFinal));   end; end; procedure TForm1.PaintBox1MouseUp(Sender: TObject; Button: TMouseButton;   Shift: TShiftState; X, Y: Integer); begin   if Arrastar = True then   begin     PaintBox1.Canvas.DrawFocusRect(RectSelec(PontoInicial, PontoFinal));     PontoFinal.X := X;     PontoFinal.Y := Y;   end;   Arrastar := False; end;