Craig Chapman

Member since: Thursday, 16 April 2015
Last login: 7 days ago
Profile viewed: 1,126 views

Your Rank: 91
Points: 4

Best viewed at full screen (1080p) ...

Best viewed in Full Screen (1080p) ...

Best viewed in full screen mode (1080p) ...

Craig Chapman created new blog post Introducing the Panthera Project in Programming 2 weeks ago

Best Viewed in Full Screen ...

Craig Chapman created new blog post RAD Mobile Boot Camp Day 3 in Programming 3 weeks ago

Slides: Slides SourceCode: Source Code ...

Craig Chapman created new blog post REST, You’re doing it wrong. in Programming 4 weeks ago

  My wife recently expressed her frustration with the abundance of blog posts entitled ‘you’re doing it wrong’, or some approximation there-of; and so I could hardly resist writing one of my own! In... ...

Recently I wrote a blog post on using the fork() instruction to create a Daemon under Linux with Delphi. In that post, the Daemon which is created does nothing but enter into an infinite... ...

Craig Chapman replied to the topic 'Drawing a selection Rectangle' in the forum. 1 month ago

In order to do this cleanly on a form, you'll need several events.The reason that your rect is not being drawn cleanly is because your rendering loop is not within the redraw of the form, so effectively as soon as the panel is invalidated, the form is redrawn and that is overwriting your rendering.
Try this... (Be sure to hook up each of the events)..

[color=#800000; font-weight: bold]unit[/color] Unit1;
[color=#800000; font-weight: bold]interface[/color]
[color=#800000; font-weight: bold]uses[/color]System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,FMX.Controls.Presentation, FMX.StdCtrls;
[color=#800000; font-weight: bold]type[/color]TForm1 = [color=#800000; font-weight: bold]class[/color](TForm)Panel1: TPanel;[color=#800000; font-weight: bold]procedure[/color] Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Single);[color=#800000; font-weight: bold]procedure[/color] Panel1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single);[color=#800000; font-weight: bold]procedure[/color] Panel1Paint(Sender: TObject; Canvas: TCanvas; [color=#800000; font-weight: bold]const[/color] ARect: TRectF);[color=#800000; font-weight: bold]procedure[/color] Panel1MouseUp(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Single);[color=#800000; font-weight: bold]procedure[/color] Panel1MouseLeave(Sender: TObject);[color=#800000; font-weight: bold]private[/color]Drawing: boolean;AnchorX: single;AnchorY: single;TargetX: single;TargetY: single;[color=#800000; font-weight: bold]procedure[/color] Invalidate;[color=#800000; font-weight: bold]public[/color]{ Public declarations }[color=#800000; font-weight: bold]end[/color];
[color=#800000; font-weight: bold]var[/color]Form1: TForm1;
[color=#800000; font-weight: bold]implementation[/color]
{$R *.fmx}
[color=#800000; font-weight: bold]procedure[/color] TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single);[color=#800000; font-weight: bold]begin[/color]Drawing := True;AnchorX := X;AnchorY := Y;[color=#800000; font-weight: bold]end[/color];
[color=#800000; font-weight: bold]procedure[/color] TForm1.Invalidate;[color=#800000; font-weight: bold]begin[/color]Panel1.InvalidateRect(Panel1.ClipRect);[color=#800000; font-weight: bold]end[/color];
[color=#800000; font-weight: bold]procedure[/color] TForm1.Panel1MouseLeave(Sender: TObject);[color=#800000; font-weight: bold]begin[/color][color=#800000; font-weight: bold]if[/color] Drawing [color=#800000; font-weight: bold]then[/color] [color=#800000; font-weight: bold]begin[/color]Drawing := False;Invalidate;[color=#800000; font-weight: bold]end[/color];[color=#800000; font-weight: bold]end[/color];
[color=#800000; font-weight: bold]procedure[/color] TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Single);[color=#800000; font-weight: bold]var[/color]myRect : TRectF;thePoints: TPointF;[color=#800000; font-weight: bold]begin[/color][color=#800000; font-weight: bold]if[/color] [color=#800000; font-weight: bold]not[/color] Drawing [color=#800000; font-weight: bold]then[/color] [color=#800000; font-weight: bold]begin[/color][color=#800000; font-weight: bold]exit[/color];[color=#800000; font-weight: bold]end[/color];TargetX := X;TargetY := Y;Invalidate;[color=#800000; font-weight: bold]end[/color];
[color=#800000; font-weight: bold]procedure[/color] TForm1.Panel1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single);[color=#800000; font-weight: bold]begin[/color]Drawing := False;Invalidate;[color=#800000; font-weight: bold]end[/color];
[color=#800000; font-weight: bold]procedure[/color] TForm1.Panel1Paint(Sender: TObject; Canvas: TCanvas; [color=#800000; font-weight: bold]const[/color] ARect: TRectF);[color=#800000; font-weight: bold]var[/color]RenderRect: TRectF;[color=#800000; font-weight: bold]begin[/color][color=#800000; font-weight: bold]if[/color] [color=#800000; font-weight: bold]not[/color] Drawing [color=#800000; font-weight: bold]then[/color] [color=#800000; font-weight: bold]begin[/color][color=#800000; font-weight: bold]exit[/color];[color=#800000; font-weight: bold]end[/color];RenderRect.TopLeft := Panel1.LocalToAbsolute(PointF(AnchorX,AnchorY));RenderRect.BottomRight := Panel1.LocalToAbsolute(PointF(TargetX,TargetY));RenderRect.TopLeft := PointF(AnchorX,AnchorY);RenderRect.BottomRight := PointF(TargetX,TargetY);panel1.Canvas.BeginScene();panel1.Canvas.DrawDashRect(RenderRect,0,0,allcorners,1,talphacolors.Black);panel1.Canvas.EndScene;[color=#800000; font-weight: bold]end[/color];
[color=#800000; font-weight: bold]end[/color].


Read More...

During one of my webinars this morning on migrating services from windows to Linux, a question was raised about how to import libraries to Delphi. In this post I’d like to explain what I’d... ...

Craig Chapman replied to the topic 'Tquery and Tdatabase available in Delphi Trial ?' in the forum. 3 months ago

It was some time ago for a previous version, but I wrote a blog on connecting to MySQL using FireDAC (the replacement for BDE), it should still be relevant:
chapmanworld.com/2015/01/18/connecting-r...-mysql-with-firedac/

Read More...

Willian Santos is friends with Craig Chapman

Bob Swart is friends with Craig Chapman

One of the great features of Linux is that you can do just about anything from the command line. If we're able to gain access to command line instructions fr ...

One of the great features of Linux is that you can do just about anything from the command line. If we're able to gain access to command line instructions fr ...

One of the great features of Linux is that you can do just about anything from the command line. If we're able to gain access to command line instructions fr ...

Craig Chapman created new blog post Calling Linux Commands from Delphi in Programming 3 months ago

One of the great features of Linux is that you can do just about anything from the command line. If we're able to gain access to command line instructions fr ...

With the introduction of the Linux target for Delphi, a wide range of possibilities are opened up to Delphi developers, to create Linux server applications. Unfortunate ...

With the introduction of the Linux target for Delphi, a wide range of possibilities are opened up to Delphi developers, to create Linux server applications. Unfortunate ...