TAPPLICATION class in Delphi

xiaoxiao2021-03-06  46

---- Delphi is an object-oriented programming language because it uses the advantage of complete integration OOP, so it is a very popular Windows development tool. In many classes contained in Delphi, Tapplication is a class with a very important role. The TAPPLICATION class is a class for describing the application prepared by Delphi. Many features can be prepared by flexible applications for this class. Let's take a few examples of this. ---- 1 Test if the current Windows program is activated: ---- TAPPLICATION class has an attribute --active, this property can describe whether the currently running program is activated and becoming the focus of Windows. The code detected is as follows: if Application.active = false the showMessage ('Current window is not activated "); ---- 2 Name of the current program: ---- TAPPLICATION class Exename property can return this executable program The full file name (including the path). The code is as follows: ---- ShowMessage (Application.exename); - 3 Title when the program is changed ---- If you are carefully observed that you can find that some programs title and program name It is inconsistent, especially some English procedures, the title bar of the form is relatively long, can accommodate more text, and when minimized, there is often a few letters. This is the Title property of the TAPPLICATION class. This attribute determines the title of the program minimized, and the title of the title bar in the window is determined by the Form's CAPTION attribute. The code is as follows: form1.caption: = 'The title' of the window '; Application.title: =' program's title '; ---- actually we can also specify the Title property value of the TApplication class when designing. The method of operation is to pull down the Project menu in the development environment and pop up the dialog box as shown in Figure 1 (omitted) when selecting the Options menu. This effect can also be achieved like the title of the program in the Title column in this dialog. And because the general engineering documents are named in English, the title in the message box popped in the program is in English. However, after the specified this property, the title of all message windows of this program becomes the value of Title. This makes the program more complete. ---- 4 Numms the main window of the program ---- The interface in the Windows system is a window, but in general, there is a main window. Tapplication's MainForm property can return the main window of the program. ---- 5 Display Messages ---- Delphi has many functions and processes that display the message box, which is often used for ShowMessage, which is very convenient, but there is a problem, that is, the button for this message box is Displayed in English. If you want to generate a button containing Chinese display, it is required to help the Tapplication's MessageBox function. The original shape of this function is as follows: --- Function MessageBox (Text, Caption: Char; Flags: longint): Integer; ---- In this function, the first two are the display prompt information and message window title, Flags is a long-term value for specifying the number and function of the button. Users who are familiar with Delphi may notice that this function is different from the same name function provided by Delphi 3, which is not given in the form of characters in the form of characters, and it is no longer required to convert it into a pointer. We should pay attention to the difference when we use.

转载请注明原文地址:https://www.9cbs.com/read-80365.html

New Post(0)