E2003 未声明的标识符:'mtConfirmation' 和 'mbOK'
E2003 Undeclared identifier: 'mtConfirmation' and 'mbOK'
据我所知,这两个都应该在我正在使用的 System.UITypes 中,但我仍然收到错误消息。我该如何解决这个问题?
我已经基于 http://docwiki.embarcadero.com/CodeExamples/XE7/en/FileExists_(Delphi)
中示例的消息对话框
unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
uses
NetworkState;
procedure TForm1.Button1Click(Sender: TObject);
var
NS: TNetworkState;
begin
NS := TNetworkState.Create;
try
if not NS.IsConnected then begin
MessageDlg(('No connection'), mtConfirmation, [mbOK], 0);
end else if NS.IsWifiConnected then begin
MessageDlg(('Wifi connection'), mtConfirmation, [mbOK], 0);
end else if NS.IsMobileConnected then begin
MessageDlg(('Mobile connection'), mtConfirmation, [mbOK], 0);
end;
Label2.Text := NS.CurrentSSID;
finally
NS.Free;
end;
end;
end.
本单元的枚举类型为scoped。注意使用
{$SCOPEDENUMS ON}
就在单元的顶部。
The $SCOPEDENUMS directive enables or disables the use of scoped
enumerations in Delphi code. More specifically, $SCOPEDENUMS affects
only definitions of new enumerations, and only controls the addition
of the enumeration's value symbols to the global scope.
In the {$SCOPEDENUMS ON} state, enumerations are scoped, and enum
values are not added to the global scope. To specify a member of a
scoped enum, you must include the type of the enum.
这意味着需要完全确定值的范围,就像这样
TMsgDlgType.mtConfirmation
像这样
TMsgDlgBtn.mbOK
等等。
据我所知,这两个都应该在我正在使用的 System.UITypes 中,但我仍然收到错误消息。我该如何解决这个问题?
我已经基于 http://docwiki.embarcadero.com/CodeExamples/XE7/en/FileExists_(Delphi)
中示例的消息对话框unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
uses
NetworkState;
procedure TForm1.Button1Click(Sender: TObject);
var
NS: TNetworkState;
begin
NS := TNetworkState.Create;
try
if not NS.IsConnected then begin
MessageDlg(('No connection'), mtConfirmation, [mbOK], 0);
end else if NS.IsWifiConnected then begin
MessageDlg(('Wifi connection'), mtConfirmation, [mbOK], 0);
end else if NS.IsMobileConnected then begin
MessageDlg(('Mobile connection'), mtConfirmation, [mbOK], 0);
end;
Label2.Text := NS.CurrentSSID;
finally
NS.Free;
end;
end;
end.
本单元的枚举类型为scoped。注意使用
{$SCOPEDENUMS ON}
就在单元的顶部。
The $SCOPEDENUMS directive enables or disables the use of scoped enumerations in Delphi code. More specifically, $SCOPEDENUMS affects only definitions of new enumerations, and only controls the addition of the enumeration's value symbols to the global scope.
In the {$SCOPEDENUMS ON} state, enumerations are scoped, and enum values are not added to the global scope. To specify a member of a scoped enum, you must include the type of the enum.
这意味着需要完全确定值的范围,就像这样
TMsgDlgType.mtConfirmation
像这样
TMsgDlgBtn.mbOK
等等。