Движение с Миганиями?
Здравствуйте, это мой первый post в Форуме, привет, я из Боливии - Юг Америка.
У следующего кода есть эффект рисования текста в движении на любом объекте TForm; этот функционирует верно, но если я ввожу TImage фона (background) TForm, Delphi показывает мне ошибку на этой линии:
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
Как решать это ERROR?
.
Код:
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.
Как Новичок я попытался решить таким образом:
Я разместил TPanel такую (собственность Align=AllClient) как фон TForm'a и этот в свою очередь содержит TImage (собственность Align=AllClient; stretch=true), эффект работает нормально но медленнo, и у него есть проблема с перекрашенным, а именно очевидно много МИГАНИЕ, и медленнo.
Mне нужно в том, чтобы разместить в этом коде TImage как фон в TForm и также мне нужно, чтобы оно функционировало без миганий, Как?
Как решать и предотвращать это Мигание после того, когда повторно рисовано?
Как решать это без миганий?
Мигание, Мигание.......
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 in background TForm's, Delphi shows me an error in this line:
Border: = BorderWidth + 3
ERROR
raised exception EAccess Violation
As Beginner I have tried to solve this way:
I have placed a TPanel (property Align=AllClient) as background of the Form and east in turn contains the TImage (property Align=AllClient; stretch= true), the one effect works normal but slowly, and it has a problem with the one repainted, that is to say a lot of TWINKLING (BLINKKINGS) and slowly.
I need to place in this code a background TImage in the TForm and I need that it works without twinklings, How?
How to solve and without blinkings to the redraw, please?
|