delphi는 문자열을 통해 함수 이름을 가져옵니다. (판단 조건이 너무 많은 방법 대신)
2815 단어 delphi
아래의 방법은 마땅히 실행할 수 있어야 한다
MethodAddress: 방법의 주소를 얻습니다. 이 방법은published가 필요합니다.
인스턴스 코드:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TShowInfo = procedure (info: string ) of object ; // procedure , ShowInfo TForm1 = class (TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } published procedure ShowInfo(info: string ); end ; var Form1: TForm1; implementation {$R *.dfm} { TForm1 } procedure TForm1 . ShowInfo(info: string ); begin ShowMessage(info); end ; procedure TForm1 . Button1Click(Sender: TObject); var s:TShowInfo; begin @s := MethodAddress( 'ShowInfo' ); // ShowInfo if @s <> nil then // begin s( ' ' ); // end ; end ; end .
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Delphi 10.3.3 IDE 글꼴 및 글꼴 크기 수정Delphi는 Windows 플랫폼에서 유명한 빠른 응용 프로그램 개발 도구(Rapid Application Development, 약칭 RAD)입니다.그것의 전신은 바로 DOS 시대에 성행한'Borland Turb...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.