Clever programmers use DELPHI which is an ancient word, passed from generation to generation, the programmers and the school of DELPHI convenience and cohesion of the operating system is perfect, I enumerate several DELPHI into below tips to share! Hope that readers have good skills, please don't mention it, take it out to share! Welcome comments! 1, checks if a string is contained in another method of a string For example: if pos (' ab ', 'abcd') & lt;> 0 then Messagedlg (' ab is contained in the abcd, mtConfirmation, [mbYes mbNo], 0). Pos (obj, target) in the target string obj find out first in the first character of a place, if can't find, returns 0.
2, how to make full screen window, similar to the game, and not maximizing the window! (1) the BorderStyle to bsNone (2) the Windowstate for wsMaximized (3) exit can add a button or something, write down the close to quit,
3, the digital formatting output Format (' % 8.2 f, [123.456]), and return a string '123.46',
4, play a wav file Use mmsystem; SndPlaySound (' hello. Wav, SND_FILENAME or SND_SYNC);
5, InputBox, InputQuery and the power of the ShowMessage function USES dialogs. Var s, s1: string; B: Boolean; The begin S:=trim (Inputbox (' NewPassword 'and' Password ', 'masterkey')); B:=s<> "'; S1:=s; If b, then b:=InputQuery (' Confirm Password 'and' Password ', s1); If not the or b (s1 & lt;> S) then ShowMessage (' Password Failed); end;
6, the process of several concerning the operation of the subdirectories The MkDir (STR); The ChDir (STR); GetDir (DriveID, STR); SetCurrentDir (STR); IOResult - above a few procedure call successful namely return value 0
7, a visual control into graphic type Such as a LABEL with the background becomes a TIMAGE picture type, can do it: Image1. Width:=label1. Width; Image1. Height:=label1. Height; Label1. Perform (WM_PAINT, image1. Canvas. Handle, 0).
8, how to get the characters in the ASCII value Get the ASCII value of the characters, you can use the following statement: Var: a: integer; String1: string; The begin String1:='ABC'; A:=byte (string [1]). {now gained the ASCII value of the 'A'} end;
The color of 9, dynamic update DBGrid For example, if the population of a city is more than 2 million, we let it show as blue, used for DBGrid controls events. OnDrawColumeCell: Procedure TForm1. DBGrid1DrawColumnCell (Sender: TObject; Const the Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); The begin If Table1. FieldByName (' Population ') AsInteger & gt; 20000000 then DBGrid1. Canvas. The Font Color:=clBlue; DBGrid1. DefaultDrawColumnCell (the Rect, DataCol, the Column, the State); end;
10 for command line parameter 1. Get the number of command line parameters: ParamCount function 2. Call ParamStr (0), back to the executable file of the file name (including path) 3. Call ParamStr (n), back to the first n parameters of the contents of the Example: Procedure TForm1. FormCreate (Sender: TObject); Var Ix: integer; The begin Memo1. Lines. The Clear; If ParamCount=0 then Memo1. Lines. The Add (' no parameters') The else The begin Memo1. Lines. The Add (' file name: + ParamStr (0)); For ix:=1 to ParamCount do Memo1. Lines. The Add (ParamStr (ix)); end; end;