FMX.Dialogs.InputQuery

Aus RAD Studio API Documentation
Wechseln zu: Navigation, Suche

Delphi

function InputQuery(const ACaption: string; const APrompts: array of string; var AValues: array of string; const ACloseQueryFunc: TInputCloseQueryFunc): Boolean;
function InputQuery(const ACaption: string; const APrompts: array of string; var AValues: array of string; const ACloseQueryEvent: TInputCloseQueryEvent; const AContext: TObject): Boolean;
function InputQuery(const ACaption, APrompt: string; var Value: string): Boolean;
procedure InputQuery(const ACaption: string; const APrompts: array of string; const ADefaultValues: array of string; const ACloseQueryProc: TInputCloseQueryProc);
procedure InputQuery(const ACaption: string; const APrompts: array of string; const ADefaultValues: array of string; const ACloseQueryEvent: TInputCloseQueryWithResultEvent; const AContext: TObject);
procedure InputQuery(const ACaption, APrompt, ADefaultValue: string; const ACloseBoxProc: TInputCloseBoxProc);
procedure InputQuery(const ACaption, APrompt, ADefaultValue: string; const ACloseQueryEvent: TInputCloseQueryWithResultEvent; const AContext: TObject); overload;

C++

extern DELPHI_PACKAGE bool __fastcall InputQuery _DEPRECATED_ATTRIBUTE1("Use FMX.DialogService methods") (const System::UnicodeString ACaption, const System::UnicodeString *APrompts, const int APrompts_High, System::UnicodeString *AValues, const int AValues_High, const _di_TInputCloseQueryFunc ACloseQueryFunc = _di_TInputCloseQueryFunc())/* overload */;

Eigenschaften

Typ Sichtbarkeit Quelle Unit Übergeordnet
function public
FMX.Dialogs.pas
FMX.Dialogs.hpp
FMX.Dialogs FMX.Dialogs


Beschreibung

Warnung: InputQuery ist veraltet. Bitte verwenden Sie Platform.IFMXDialogServiceAsync.MessageDialogAsync.

Zeigt ein Dialogfeld an, das mehrere Eingabefelder enthält.

Mit InputQuery können Sie ein Dialogfeld anzeigen, das entsprechend der Anzahl der Strings in APrompts mehrere TEdit-Steuerelemente enthält.

InputQuery erhält die folgenden Parameter:

  • ACaption repräsentiert den Titel des Dialogfeldes.
  • APrompts repräsentiert die Beschriftungen links neben den TEdit-Steuerelementen. Um ein Feld in einem Dialogfeld als maskiertes Feld festzulegen (wie z. B. ein Passwortfeld), verwenden Sie ein Flag vor der Feldbezeichnung.
  • AValues oder ADefaultValues sind die Standardtextwerte für die TEdit-Steuerelemente.
  • ACloseQueryProc ist eine anonyme Methode, die beim Schließen des Dialogfeldes InputQuery ausführt.
Hinweis: AValues muss länger oder gleich lang wie APrompts sein.

Wenn der Benutzer auf die Schaltfläche OK klickt, gibt InputQuery True zurück; ansonsten gibt InputQuery False zurück. Wenn Sie den Parameter ACloseQueryProc angeben, gibt InputQuery keinen Wert zurück; das an die Methode ACloseQueryProc übergebene Argument AResult gibt an, auf was der Benutzer geklickt hat.

Die in die Eingabefelder des Dialogfeldes eingegebenen Werte werden in AValues gespeichert. Wenn Sie den Parameter ACloseQueryProc angeben, übergibt InputQuery die Werte stattdessen an die Methode ACloseQueryProc.

Wenn im Aufruf von InputQuery der Parameter ACloseQueryProc nicht enthalten ist, wird der Aufruf auf allen Plattformen blockiert; d. h., InputQuery kehrt erst zurück, wenn das Dialogfeld geschlossen wird. Android unterstützt keine blockierenden Aufrufe; Sie können InputQuery unter Android nur verwenden, wenn Sie den Parameter ACloseQueryProc angeben.

Wenn Sie InputQuery auf Desktop-Plattformen aufrufen, sind die Aufrufe immer blockierend, unabhängig davon, ob sie den Parameter ACloseQueryProc enthalten; auf mobilen Plattformen wird Code nach einem Aufruf von InputQuery immer ausgeführt, bevor das Dialogfeld geschlossen wird. Wenn Sie nach dem Schließen des Dialogfeldes Quelltext ausführen müssen, verwenden Sie den Parameter ACloseQueryProc von InputQuery, um eine anonyme Methode zu definieren, die diesen Code ausführt. Siehe:

Maskieren eines Feldes

Dieses Codefragment zeigt ein Dialogfeld mit dem Namen "Login" mit zwei Feldern ("Username" und ein maskiertes "Password"-Feld).

Delphi:

  • In Delphi werden mit dem Flag "#1" vor der Feldbezeichnung Felder maskiert.
InputQuery( 'Login', ['Username', #1'Password:'], ['', ''],
    procedure(const AResult: TModalResult; const AValues: array of string)
    begin
    end);
C++:
  • Fügen Sie nach der TForm1-Definition die folgende Definition hinzu (in der .h-Datei Ihrer Unit):
typedef void __fastcall(__closure * TInputCloseQueryProcEvent)
	(const System::Uitypes::TModalResult AResult,
	System::UnicodeString const *AValues, const int AValues_High);
  • Fügen Sie die folgende Klassendefinition hinzu (in der .h-Datei Ihrer Unit nach dem zuvor definierten Typ):
class InputQueryMethod : public TCppInterfacedObject<TInputCloseQueryProc>
{
private:
	TInputCloseQueryProcEvent Event;

public:
	InputQueryMethod(TInputCloseQueryProcEvent _Event) {
		Event = _Event;
	}

	void __fastcall Invoke(const System::Uitypes::TModalResult AResult,
		System::UnicodeString const *AValues, const int AValues_High) {
		Event(AResult, AValues, AValues_High);
	}
};
  • Fügen Sie in den private-Abschnitt des Formulars die folgende Deklaration ein (in der .h-Datei Ihrer Unit):
private: //User declarations
	void __fastcall OnInputQuery_Close
		(const System::Uitypes::TModalResult AResult,
		System::UnicodeString const *AValues, const int AValues_High);
  • Fügen Sie folgenden Code hinzu (in der .cpp-Datei Ihrer Unit):
void __fastcall TForm1::OnInputQuery_Close(const System::Uitypes::TModalResult AResult,
		System::UnicodeString const *AValues, const int AValues_High) {	
}
  • Jetzt können Sie das folgende Codefragment verwenden:
  • In C++ werden mit dem Flag "\1" als erster Teil der Feldbezeichnung Felder maskiert.
	String caption = "Login";
	String Prompts[2];
	Prompts[0] = "Username";
	Prompts[1] = "\1Password";
	String Defaults[2];
	Defaults[1] = "";
	Defaults[0] = "";
	_di_TInputCloseQueryProc Met = new InputQueryMethod(&OnInputQuery_Close);

        InputQuery(caption, Prompts, sizeof(Prompts)/sizeof(Prompts[0]) - 1, Defaults, sizeof(Defaults)/sizeof(Defaults[0]) - 1, (TInputCloseQueryProc *)Met);

Plattformunterstützung

Die folgende Tabelle enthält eine Übersicht über die Unterstützung von Aufrufen von InputQuery auf der jeweiligen Plattform und ob diese Aufrufe blockierend oder nicht blockierend sind:

Plattform Ohne ACloseQueryProc Mit ACloseQueryProc
Windows Blockierend Blockierend
OS X Blockierend Blockierend
iOS Blockierend Nicht blockierend
Android Nicht blockierend

Siehe auch