Delphi Common Properties + methods + Event + code + function

Source: Internet
Author: User

Center content (attributes)

Alignment->tacenter mome Controls

Disable Maximize (properties)

form, bordericons properties, bimaximize-> False

Make the mouse unable to change form size (properties)

form, constraints Properties->maxheight and minheight-> settings same limit the height of the mouse change form

form, constraints Properties->maxwidth and minwidth-> settings are the same as restricting the mouse to change the width of the form

========================================================================

Cannot change size (event)

Procedure Tform1.formcanresize (Sender:tobject; var newwidth,
Newheight:integer; var resize:boolean);
Begin
Resize:=false;
End

How to add a confirmation dialog box (event) before closing a window

Add the following code to the Onclosequery event of the form:
If Application.messagebox (Close it now?,ask,mb_yesno) =idyes Then
Canclose:=true
Else
Canclose:=false;

Disable Ait+f4 (event) in Delphi

Method 1.

Set canclose:=false in Onclosequery;

Method 2.

Procedure Tmainform.formkeydown (Sender:tobject; var Key:word; Shift:tshiftstate);
Begin
if (KEY=VK_F4) and ([Ssalt]=shift) then//Mask ALT+F4 key allows the program not to be closed
key:=0;
End

==================================================================

String Right lookup (function)

Lastdelimiter ()

Such as:

s:= ' ABCDEFG ';

Lastdelimiter (S, ' ef '); {6}

Rounding in mathematics (function)

Floor and Ceil are functions in the math unit, and Uses math before use.
Trunc and round are functions in the system unit, which can be used by default.
Floor directly to the small take, such as floor ( -123.55) =-124,floor (123.55) =123
Trunc directly cut down integers, such as trunc ( -123.55) =-123, Floor (123.55) =123
Ceil directly to the large, such as Ceil ( -123.55) =-123, Ceil (123.55) =124
Round computed rounding, such as round ( -123.55) =-124,round (123.55) =124

File operation (function) exists \ delete \ prompt \ personality hint

1.FileExists (Opendialog1. FileName)-----------------------------[see if the file exists]

2.showmessage (' File already exists ')-----------------------------------[hint form]

3.application.messagebox (' Save success ', '! hint ', mb_iconwarning)---[Personality tips]

4.erase (FI);---------------------------------------------------[Delete Files]

5.sysutils.deletefile (LJ)--------------------------------------[forcibly deleting files]

6.DirectoryExists (Opendialog1. FileName)------------------------[see if directory exists]

==========================================================

to see if a subform in a project is established (method)

Method 1.

If Assigned (FORM1) Then
ShowMessage (' Form1 has been created '); If the Form1 is already free, the judgment statement returns the true

Method 2.
if (Form1 = nil) Then
ShowMessage (' Form1 not created '); There is no prompt, there is no prompt

Method 3.

Determines whether the form name already exists.
function Tmainform.formisexist (name:string): Boolean;
var I:integer;
Begin
Result:=false;
If Mainform.mdichildcount>0 Then
Begin
For i:=mainform.mdichildcount-1 Downto 0 do

Begin
If Mainform.mdichildren[i]. Name=name Then

Begin
Result:=true;
break;
End //

End //

End
End

Delphi Common Properties + methods + Event + code + function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.