if MessageBox(handle,'確定要刪除當前記錄?','確定',MB_IconQuestion+MB_YesNo)=IDNO then
Abort;
Abort;
TApplication类中封装的MessageBox是直接调用Windows API的,两者的差别就是Tapplication省去了一个从String转到PChar的过程。这给调用者带来了一定的方便。
以下是WINDOWS API HELP中MessageBox的解释。
如果追求是一些个性化的东西还可以使用
MessageBox在WINDOWS API中的函数原型如下:
int MessageBox(
HWND hWnd, // handle of owner window
LPCTSTR lpText, // address of text in message box
LPCTSTR lpCaption, // address of title of message box
UINT uType // style of message box
);
Handle参数是显示时基于的窗口句柄,如果为0则自己新开一个窗口。一般如果无法确定当前窗口
的句则需要调用GetForegroundWindow函数返回。
其uTupe参数一般有如下几个。
MB_ABORTRETRYIGNORE
MB_OK
MB_OKCANCEL
MB_RETRYCANCEL
MB_YESNO
MB_YESNOCANCEL
另外在MessageBox中还可以显示特定的图标。
MB_ICONEXCLAMATION,
MB_ICONWARNING
MB_ICONINFORMATION
MB_ICONASTERISK
MB_ICONQUESTION
MB_ICONSTOP,
MB_ICONERROR,
MB_ICONHAND
至于返回结果,只不过是把uTupe参数中的“MB”改成了“ID”,以下是一段演示代码。
function TForm1.Demo(Sender:TObject):String;
begin
case MessageBox(Handle,'您是程序员吗?','提示信息',MB_YESNOCANCEL+MB_ICONQUESTION
) of
case ID_YES:Result:='是';
case ID_NO:Result:='不是';
case ID_CANCEL:Result:='程序员是什么工作?';
end;
end;
以下是WINDOWS API HELP中MessageBox的解释。
如果追求是一些个性化的东西还可以使用
MessageBox在WINDOWS API中的函数原型如下:
int MessageBox(
HWND hWnd, // handle of owner window
LPCTSTR lpText, // address of text in message box
LPCTSTR lpCaption, // address of title of message box
UINT uType // style of message box
);
Handle参数是显示时基于的窗口句柄,如果为0则自己新开一个窗口。一般如果无法确定当前窗口
的句则需要调用GetForegroundWindow函数返回。
其uTupe参数一般有如下几个。
MB_ABORTRETRYIGNORE
MB_OK
MB_OKCANCEL
MB_RETRYCANCEL
MB_YESNO
MB_YESNOCANCEL
另外在MessageBox中还可以显示特定的图标。
MB_ICONEXCLAMATION,
MB_ICONWARNING
MB_ICONINFORMATION
MB_ICONASTERISK
MB_ICONQUESTION
MB_ICONSTOP,
MB_ICONERROR,
MB_ICONHAND
至于返回结果,只不过是把uTupe参数中的“MB”改成了“ID”,以下是一段演示代码。
function TForm1.Demo(Sender:TObject):String;
begin
case MessageBox(Handle,'您是程序员吗?','提示信息',MB_YESNOCANCEL+MB_ICONQUESTION
) of
case ID_YES:Result:='是';
case ID_NO:Result:='不是';
case ID_CANCEL:Result:='程序员是什么工作?';
end;
end;
function InputQuery(const ACaption, APrompt: string; var Value: string): Boolean;
function InputQuery(const ACaption, APrompt: WideString; var Value: WideString): Boolean; overload;
function InputQuery(const ACaption, APrompt: WideString; var Value: string): Boolean; overload;
function InputQuery(const ACaption, APrompt: WideString; var Value: Double, Min: Double = Low(Integer); Max: Double = High(Integer); Decimals: Integer = 1): Boolean; overload;
function InputQuery(const ACaption, APrompt: WideString; var Value: Integer, Min: Integer = Low(Integer); Max: Integer = High(Integer); Increment: Integer = 1): Boolean; overload;