Delphi [Remember to come to Kang Kang Me]

What does $30 mean?

$30 in hexadecimal is 48 in decimal

Normal---------------When the focus is lost
Focused--------------When the focus is acquired
Hot------------ ------
Pressed when the mouse is moved up --------------
FrameFocised when the mouse is pressed ---------the frame when the focus is acquired
Alpha---------- -----------Opacity

Anchors--------------You can set the control to change with the change of the window
Constraints----------You can set the maximum and minimum size of the window


[Control: scStyledForm1] You can add a circle of shadow
DWMClientShadow to a borderless form, and set the form to a borderless form

[Controls: scLabel1, scPanel1, scGPPanel1]
DragForm Set whether the form can be dragged

[Control: Panel]

procedure TForm2.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  //当鼠标按下时窗体随鼠标移动而移动
  ReleaseCapture;
  Perform(WM_SYSCOMMAND, $F012, 0);
end;

[Control: scGPPanel]
FrameColor Set the border color
FrameColorAlpha Set the opacity of the
border FrameRadius Set the corner radian of the border [Round corners]
FrameSides Set whether the four sides of the border are displayed (four sides are set separately)
FrameWidth Set the width of the border (0 means no border)

FillColor Color 1
FillColor2 Color 2
FillColorAlpha Set the opacity when only color 1 is used
FillGradientAngle Set the gradient angle [gradient from top to bottom or left to right or a certain angle]
FllGradientBeginAlpha Opacity of color 1
FillGradientBeginColorOffset Brightness of color 1
FillGradientEndAlpha Color 2 The opacity of
FillGradientEndC olorOffset The brightness of color 2
FillStyle This is a gradient only after setting this property, the default is not gradient

[Control: cxGrid1]
DataController->DataSource—[Set Data Source]
OptionsView->GroupByBox------Set to False [Remove title bar]


[Shortcut key]
CTRL+ SHIFT + C: write a statement or add a function


Set the following properties to display text on a transparent form:
Set the form properties:
Set the BorderStyle property to bsNone
Color property to clWhite (white: form background color)
TransparentColor property to true
TransparentColorValue property to clWhite (white: transparent color )
------The above two colors must be consistent to make the form transparent-------------------
Set the Label property:
Set the Color property to clWhite (white: transparent color )
Font.Color property is set to clRed (non-transparent color is sufficient)
Transparent property is set to true


Set the transparent
property of the Image control to true,
but if the image itself has white parts, there is no way.

[Control: scStyledForm1]
DWMClientShadow--------------DWM client shadow

Image uses the picture in ImageList
DataModule1.ImageList1.GetBitmap(7, Image3.Picture.Bitmap);


**Call the default browser to open the webpage**
uses
shellapi

ShellExecute(handle,nil,pchar('http://www.baidu.com'),nil,nil,SW_shownormal);

The function of ShellExecute is to run an external program (or open a registered file, open a directory, print a file, etc.) and have certain control over the external program.

ShellExecute common methods

1.开始一个新的应用程序
  ShellExecute(Handle, 'open', PChar('c:\test\app.exe'), nil, nil, SW_SHOW);
 
2.打开记事本,并打开一个文件(系统能识别记事本应用程序的路径,因此我们不必使用绝对路径)
  ShellExecute(Handle, 'open', PChar('notepad'), PChar('c:\test\readme.txt'), nil, SW_SHOW);
 
3.打印一个文档
  ShellExecute(Handle, 'print', PChar('c:\test\test.doc'), nil, nil, SW_SHOW);
  注意:可能你会看到word暂时的被打开,但它会自动关闭。
 
4.打开一个HTML页面
  ShellExecute(Handle, 'open', PChar('http://www.festra.com/'), nil, nil, SW_SHOW);
 
5.你能通过一个已经注册的文件类型来打开应用程序
  ShellExecute(Handle, 'open', PChar('c:\test\readme.txt'), nil, nil, SW_SHOW);
 
6.用windows Explorer 打开一个目录
   ShellExecute(Handle, 'explore', PChar('c:\windows)', nil, nil, SW_SHOW);
 
7.调用资源管理器
  ShellExecute(0,'explore',0,filename,0,1); //此处的FILENAME为驱动器,如C:\  
 
8.运行一个DOS命令并立即返回
  ShellExecute(Handle, 'open', PChar('command.com'), PChar('/c copy file1.txt file2.txt'), nil, SW_SHOW);
 
9.运行一个DOS命令并保持DOS窗口存在
  ShellExecute(Handle, 'open', PChar('command.com'), PChar('/k dir'), nil, SW_SHOW);
 
10.发email
   v_mailto:='mailto:'+filename; //filename为EMAIL地址   
   v_mailto:=v_mailto+'?subject='+docname;  // docname为标题   
   shellexecute(0,'open',v_mailto,0,0,1);

ShellExecute detailed

    ShellExecute函数用于打开或者打印一个指定的文件。指定的文件必须是可执行文件或者文档文件。
HINSTANCE ShellExecute(
     HWND hwnd, // handle to parent window 【父窗口的句柄】
     LPCTSTR lpOperation, // pointer to string that specifies operation to perform 【指向指定执行操作的字符串的指针】
     LPCTSTR lpFile, // pointer to filename or folder name string 【指向文件名或文件夹名称字符串的指针】
     LPCTSTR lpParameters, // pointer to string that specifies executable-file parameters 【指向指定可执行文件参数的字符串的指针 】
     LPCTSTR lpDirectory, // pointer to string that specifies default directory 【指向指定默认目录的字符串的指针】
     INT nShowCmd   // whether file is shown when opened 【打开时是否显示文件】
    )
******************************************************************************
* Params(参数解释)
1.Hwnd
  指定父窗口句柄。这个窗口接收工程产生的所有消息。例如:一个工程可以通过消息框报告错误。
  
2.lpOperation
  以一个以null结束的字符串描述操作的执行。以下的操作字符串是有效的:
  行号 参数 含义
  1open” 函数打开由lpFile指定的文件。这个文件必须是可执行文件或者文档文件。文件夹必须是可打开的文件夹。
  2print” 函数打印由lpFile指定的文件。这个文件应该是文档文件。如果指定的文件是可执行文件,函数将以open的方式打开这个文件。
  3 “explore” 函数将搜索由lpFile指定的文件夹。

  4 lpOperation 参数如果为null,函数将以open的方式打开由lpFile指定的文件。
  
3.lpFile
  以一个null结束的字符串描述打开或者打印指定的文件,或者打开或者搜索指定的
文件夹。函数可以打开一个指定的文件或者文件夹,也可以打印一个文档文件。

4.lpParameters
  如果lpFile指定的是一个可执行文件,lpParameters以一个以null结束的字符串指定该执行文件传给应用软件的参数。
行号 参数 含义
1 SW_HIDE 隐藏这个窗体,并激活其他窗体。
2 SW_MAXIMIZE 最大化指定的窗体。
3 SW_MINIMIZE 最小化指定的窗体,并按顺序激活最上层的窗体。
4 SW_RESTORE 激活并显示窗体。如果窗体为最小化或者最大化,窗体恢复到原始大小和位置。应用程序当恢复一个最小化的窗体时将指定标记。
5 SW_SHOW 以当前的大小和位置激活并显示窗体。
6 SW_SHOWDEFAULT 
7 SW_SHOWMAXIMIZED 激活并最大化显示窗体。
8 SW_SHOWMINIMIZED 激活并最小化现实窗体。
9 SW_SHOWMINNOACTIVE 最小化窗体,保持其激活状态。
10 SW_SHOWNA 以当前状态显示窗体,保持其激活状态。
11 SW_SHOWNOACTIVATE 以当前的大小和位置显示窗体,并保持其激活状态。
12 SW_SHOWNORMAL 激活并显示一个窗体。如果窗体为最大化或者最小化,窗体恢复到原始的大小和位置。当窗体第一次显示的时候,应用程序记录标记。
如果lpField指定的是一个文档文件,lpParameters应该为null5.lpDirectory
  以一个以null结束的字符串指定文件开始运行的默认目录。
  
6.nShowCmd
  如果lpField指定了一个可执行文件,nShowCmd指定这个文件在被打开时如何显示。这个参数可以是以下值中的任何一个:
如果lpField指定的是文档文件,nShowCmd应该为0******************************************************************************
* return Values(返回值)
  如果函数执行成功,返回值是已经运行的工程的实例句柄,或者动态数据交换服务器应用程序的句柄。
(具体返回值列表从略,请参考Delphi在线帮助)

* Remarks(注释)
  被lpFile参数指定的文件必须是一个可执行文件或者文档文件。如果文件是一个文档文件,ShellExecute函数将根据lpOperation参数决定打开或者打印这个文件。如果是可执行文件,ShellExecute函数将打开它,即使lpOperation参数被指定为printing。
  你可以使用ShellExecute打开活着搜索一个文件夹。可以使用以下任意一种方式打开一个文件夹:
ShellExecute(handle, NULL, path_to_folder, NULL, NULL, SW_SHOWNORMAL);
或者
ShellExecute(handle, "open", path_to_folder, NULL, NULL, SW_SHOWNORMAL);

使用下面的调用搜索文件夹:
  ShellExecute(handle, "explore", path_to_folder, NULL, NULL, SW_SHOWNORMAL)
如果lpOperation参数为null,函数将打开由lpFile指定的文件。如果lpOperation参数为”open”或者”explore”,函数将强制打开窗体或者资源管理器。

注:在新窗口打开网页的办法
  ShellExecute(self.Handle, PChar('open'), PChar('explorer'), PChar(URL), nil, SW_MAXIMIZE);

scGPEdit2.SetFocus; -------------- scGPEdit2 gets focus


Time: 16:49, September 8, 2020

Control: scTreeView1-automatically expand the tree structure
scTreeView1.Items[0].Expanded := True;

Form窗体置前
SetWindowPos(Self.Handle, HWND_TOPMOST, Left, Top, Width, height, SWP_NOMOVE or SWP_NOSIZE);

Get the current directory
GetCurrentDir


Time: 17:07, September 9, 2020

Modify the content of Label to class wrap.
Method 1:
Add [#10] where you need to wrap, which is a newline symbol

Method 2:
Modify the two attributes of label:
autosize is changed to false and wordwrap is changed to true.
After the modification is completed, set the content of Caption. When it is too long, it will automatically wrap. If an English word is too long, it will not wrap if it exceeds the width of the Label.

image image clear
image1.picture := nil;

Select folder

var
  Dir: string;
begin
  SelectDirectory( 标题名, 默认路径, Dir);    // 需要声明 FileCtrl
  // 返回文件路径【 Dir 位文件路径】

Select file and add to Image


Time: 17:24, September 10, 2020

Dataset. ****
open returns the result set, that is, the data
exec is executed, that is, insert, delete, update use


Put quotation marks on both sides of the string QuotedStr ('Add quotation marks on both sides of my paragraph');


Time: 18:03, September 11, 2020

New annotations for Delphi method attribute parameters

------------------- Divide----------------------
ModalResult := mrok; // User Click the OK button to exit. [Control property: ModalResult]

ModalResult refers to the return value of a modal form (MyForm.showmodal), which is generally used in the ModalResult property of the button on the corresponding form; after the form is displayed (closed), the preset value of this property will be returned as the return value.
After the button containing the ModalResult property is executed, the form where the button is located will be automatically closed, without adding statements such as Close in the OnClick event.
The ModalResult property of the form is automatically passed to the showmodal method as the return value of the method.

In the Login interface designed by yourself, select the corresponding button and set the ModalResult property of the button to mrOK, mrCancel, etc.
With such a setting, when the button is pressed, the interface will close by itself, and the ModalResult property of the button will be passed to the form so that the calling code can obtain the value.
In the call interface, you must use ShowModal, not show.
Note: In the Login interface, do not write close code on the button


Time: 17:42, September 14, 2020

TClientDataSet.Fields[]; {field collection; it has more functions than FieldList, such as access to nested fields}
TClientDataSet.FieldList[]; {field list; it is lighter than Fields, it is faster if you just use it for values}
TClientDataSet .FieldByName(); {Get the field object based on the field name; Get a field object faster than the previous two}
TClientDataSet.FindField(); {Find the field object based on the field name}
TClientDataSet.FieldValues[]; {Get based on the field name Field value; If only to get the field value, this is the fastest}
TClientDataSet.First; {To the first record}
TClientDataSet.Next; {To the next record}
TClientDataSet.Last; {To the last record}
TClientDataSet.Prior; {
Go to the previous record} TClientDataSet.RecNo; {Set or read the current record position}
TClientDataSet.Bof; {Whether the current position is the first record}
TClientDataSet.Eof; {Whether the current position is the last record}
TClientDataSet.RecordSize; {The size of a record; the so-called record is all the fields of the current row}
TClientDataSet.RecordCount; {the total number of records; that is, the total number of rows}
TClientDataSet.GetFieldList(); {Get the list of field objects according to the specified field names}
TClientDataSet.GetFieldData(); {Write the value of the specified field into a buffer}
TClientDataSet.GetCurrentRecord(); {Save the current record (not (Including Bolb field) write to a buffer)

Article : Delphi [Trim(), Application.MessageBox(), three-tier database modification]


Time: 18:03, September 15, 2020

Unfinished

Take a few notes so you can read them later.

Guess you like

Origin blog.csdn.net/qq_44111597/article/details/108225187