8 Tips for Delphi:
1. How to call external exe file in Delphi?
usesWinProcs;
.
begin
WinExec(......);
.
end.
It is no different from calling Pascal library functions.
2. How to change the font and color of Delphi hint
The properties of TApplication in Delphi include HintColor and HintPause.
You can change the color of Hint in the application by setting HintColor, and by setting HintPause
Change the time when Hint is triggered.
But unfortunately: the font of Hint in Delphi cannot be changed.
3. How to calculate date in Delphi
Calculating time is the easiest in Delphi, as follows:
var ss : TDateTime
In fact, Tdatetime is a double-precision floating point number, and its decimal point represents the number of days:
For example, ss := ss + 20 means 20 days from ss, if ss = 234.567
It means 234.567 days, starting from AD 0 of course!
4. How to program ScreenSaver using Delphi? (null)
The screen saver is nothing more than an executable program whose extension is changed to .SCR. It accepts two command line parameters:
-s run command parameters
-c configure command parameters
Windows starts a program by sending the -s command line parameter to the program.
It should be noted that: the program window has no borders and titles; the window size should be the same as the screen size; also note that
Handling of window events.
5. How to change the name of a directory in Delphi
Call the RenameFile function, such as:
RenameFile('c:/wang/temp', 'c:/wang/tmp');
6. DELPHI displays JPEG image files
Just add JPEG to uses
There is a TJPEGImage class in the JPEG unit, which can define a variable such as Jpeg and call it with LoadFromFile.
Import a JPEG file, and then use Form's Canvas.Draw(x,y,Jpeg) to display it.
7. Processing of Jpeg format files in Delphi...
(1). Add JPEG unit to Uses;
(2). Define a global variable, such as var AJPEG: TJPEGImage;
(3). Add: in the OnCreate event of the Form:
Canvas.Pen.Color:=clBlack;
Canvas.Pen.Style:=psSolid;
Canvas.Brush.color:=clBtnFace;
Canvas.Brush.Style:=bsSolid; //This is to set some properties of Canvas for future convenience
//Clear Form and Load a new JPEG file;
AJpeg:=TJpegImage.Create;//Dynamicly generate AJpeg;
AJpeg.LoadFromFile('D:/Temp.jpg') //After generating AJpeg, load the JPEG file;
(4).Add in the OnPain event of Form
Canvas.Rectangle(2,2,560,430); //Draw a black rectangle to surround the image;
x:=10; y:=10;
Form1.Canvas.Draw(x,y,AJpeg); //Output the JPEG file with (x,y) as the upper left corner;
//In fact, its function is to restore the graphics when the graphics is destroyed;
(5). Add the following to the OnClick event of the 'Load' or 'Browse' button:
begin
if OpenPictureDialog1.Execute then
begin
AJpeg.Free; //Release the old AJpeg;
AJpeg:=TJpegImage.Create; //Generate a new AJpeg;
AJpeg.LoadFromFile(OpenPictureDialog1.Filename); //Load JPEG file;
end;
Canvas.Rectangle(2,2,560,430); //Clear Form;
x:=10;
y:=10;
Form1.Canvas.Draw(x,y,AJpeg); //Display new AJpeg;
end;
8. DELPHI3 startup screen