Good Morning,
The following code has a effect to redraw a text in movement on any object of the TForm; this it works perfectly, but if I introduce a TImage (background) in the TForm, Delphi shows me an error in this line:
Border: = BorderWidth + 3;
ERROR
raised exception EAccess Violation
PaintTo (Bitmap. Canvas, Left, Top);//Draw the border
=> Border: = BorderWidth + 3;
BitBlt (Bitmap. Canvas. Handle, Left + Border, Top + Border, Width - Border * 2, Height - Border * 2, Canvas. Handle, Left + Border, Top + Border, SRCCOPY);//and the content
unit MIMOuse;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
Button1: TButton;
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Step: Double=0;
Bitmap: TBitmap;
Circle: array [0..255] of TPoint;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Timer1.Interval := 33;
Bitmap := TBitmap.Create;
Bitmap.Width := ClientWidth;
Bitmap.Height := ClientHeight;
Bitmap.Canvas.Brush.Color := Color;
Caption:= 'The New custom Cursor ';
end;
procedure TForm1.FormPaint(Sender: TObject);
var DestDC: Cardinal;
begin
DestDC := GetWindowDC(Handle);
BitBlt(DestDC, ClientOrigin.X - Left, ClientOrigin.Y - Top, Bitmap.Width, Bitmap.Height, Bitmap.Canvas.Handle, 0, 0, SRCCOPY);
ReleaseDC(Handle, DestDC);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
Size: Double;
Value: TPoint;
Index, Border: Integer;
begin
Size := 360 / Length(Caption);
with Bitmap.Canvas do
begin
FillRect(Classes.Rect(0, 0, Bitmap.Width, Bitmap.Height));
for Index := 0 to ControlCount - 1 do
with TWinControl(Controls[Index]) do
if Visible then
begin
Repaint;
PaintTo(Bitmap.Canvas, Left, Top); // Draw the border
Border := BorderWidth + 3;
BitBlt(Bitmap.Canvas.Handle, Left + Border, Top + Border, Width - Border * 2, Height - Border * 2, Canvas.Handle, Left + Border, Top + Border, SRCCOPY); // and the content
end;
SetBkMode(Handle, TRANSPARENT);
for Index := 1 to Length(Caption) do
begin
with Circle[Index] do
begin
if Index < 1 then
Value := Circle[Index - 1]
else
Value := ScreenToClient(Mouse.CursorPos);
Inc(X, Round((Value.X - X) * 0.6));
Inc(Y, Round((Value.Y - Y) * 0.6));
TextOut(X + Round(66 * Cos(Step + Index * Size * (Pi / 180))),
Y + Round(66 * Sin(Step + Index * Size * (Pi / 180))),
Caption[Index]);
end;
end;
end;
FormPaint(nil);
Step := Step - 0.06;
end;
end.
First.- How to solve this problem?As Beginner I have tried to solve this way:
I have placed a TPanel (property Align=AllClient) as background of the TForm and east in turn contains (inside) a TImage (property Align=AllClient; stretch= true), the effect works normal but slowly, and it has a problem with the repainted, that is to say a lot of TWINKLING and slowly.
I need to place in this code a TImage as background of the TForm and I need that it works without twinklings.
Second.- How to implement (to solve) this code when introducing a TImage in the TForm so that it works without twinklings?