Thousands of quiet suspended karaoke subtitles, we must feel good, in fact, with Delphi, you can also easily do get. First of all, we create a new 700*130 in the Delphi form, which placed two image control, image control align=alclient, so that they fill the window, the only difference is, Image1 visuble=ture, for the foreground display subtitles, Image2 's visible=false, used for background drawing, also uses a Timer control, interval=100.
To make subtitles hover on the Windows desktop, the first requirement is transparent, only the subtitles are displayed, and the second requires that the caption is on the top level, and the other form cannot overwrite it. We solve it separately.
(1) The form is transparent and only the subtitles are displayed.
Delphi to achieve transparent form is very easy, the form of the property page has two parameters, set Transparentcolor=true, Transparentcolorvalue=clwhite can, The 2nd parameter is clwhite because the image draws the caption with a white bottom, and when the image fills the window, the white background is filtered to become transparent, leaving only subtitles.
(2) Top-level untitled no border form.
To do this, just add the following code:
Protected
Procedure CreateParams (var params:tcreateparams); Override
Procedure Tform1.createparams (var params:tcreateparams);
Begin
Inherited CreateParams (Params);
Visible:=true;
With Params do
Begin
Style: = Ws_popup or ws_clipsiblings;
ExStyle: = Ws_ex_toolwindow or ws_ex_topmost;
End
End
All right, give me all the code.
Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Stdctrls, Extctrls;
Type
TForm1 = Class (Tform)
Image1:timage;
Image2:timage;
Timer1:ttimer;
Procedure Formcreate (Sender:tobject);
Procedure Timer1timer (Sender:tobject);
Procedure Image1dblclick (Sender:tobject);
Private
{Private declarations}
Protected
Procedure CreateParams (var params:tcreateparams); Override
Public
{Public declarations}
End
Var
Form1:tform1;
Iy:integer;
Implementation
{$R *.DFM}
The
//implements the top-level untitled borderless form.
procedure tform1.createparams (var params: TCreateParams);
Begin
inherited createparams (Params);
visible:=true;
with params do
Begin
style := ws_popup or ws_clipsiblings ;
exstyle := Ws_ex_toolwindow or Ws_ex_topmost;
end;
End;
Initialize set font size, use black and red to draw subtitles, respectively
Procedure Tform1.formcreate (Sender:tobject);
Begin
iy:=0;
Image1. Parent.doublebuffered: =true;
Image2. Parent.doublebuffered: =true;
Image1. Canvas.Font.Size: = 50;
Image2. Canvas.Font.Size: = 50;
Image1. Canvas.Font.Color: =clbtntext;
Image2. Canvas.Font.Color: =clred;
Image1. Canvas.textout (10,10, ' We are all Chinese ');
Image2. Canvas.textout (10,10, ' We are all Chinese ');
Timer1. Enabled: =true;
End
Use the timer to copy the red caption of the IMAGE2 to the IMAGE1, to achieve karaoke walk word.
Procedure Tform1.timer1timer (Sender:tobject);
Begin
iy:=iy+2;
If Iy>image1. Width then Iy:=image1. Width-1;
Image1. Canvas.copyrect (Rect (0,0,iy,image1). Height-1), Image2. Canvas,rect (0,0,iy,image1. Height-1));
End
//Double-click the caption end program to run.
Procedure Tform1.image1dblclick (Sender:tobject);
Begin
Close
End
End.
To achieve more beautiful Karachi subtitles, such as text plus edge plus shadow what, on the basis of the above code to play on it.
Delphi to achieve suspended karaoke subtitles