我在Delhi8中使用MessageBox.Show('确定要删除吗?','提示',MessageBoxButtons.OKCancel,MessageBoxIcon.Question)=DialogResult.OK想要取得用户的选择值,既是单击了确定还是取消,但是总是报错,说我“record,object or class type....”的错误,我该怎么用这个东东呀?郁闷。
使用Delphi8的windows form开发程序,不是vcl form开发程序。变动太多了。郁闷。

解决方案 »

  1.   

    if Application.MessageBox('确定要删除吗?','提示',MB_OKCANCEL+MB_ICONQUESTION)=id_ok then
      

  2.   

    其中id_ok 也可以用idok或者1来代替,详见delphi的help文件
    Delphi syntax:function MessageBox(const Text, Caption: PChar; Flags: Longint = MB_OK): Integer;C++ syntax:int __fastcall MessageBox(const char * Text, const char * Caption, int Flags = MB_OK);DescriptionUse MessageBox to display a generic dialog box a message and one or more buttons. Caption is the caption of the dialog box and is optional.MessageBox is an encapsulation of the Windows API MessageBox function. TApplication抯 encapsulation of MessageBox automatically supplies the missing window handle parameter needed for the Windows API function.The value of the Text parameter is the message, which can be longer than 255 characters if necessary. Long messages are automatically wrapped in the message box. The value of the Caption parameter is the caption that appears in the title bar of the dialog box. Captions can be longer than 255 characters, but don't wrap. A long caption results in a wide message box.The Flags parameter specifies what buttons appear on the message box and the behavior (possible return values). The following table lists the possible values. These values can be combined to obtain the desired effect.Value MeaningMB_ABORTRETRYIGNORE The message box contains three push buttons: Abort, Retry, and Ignore.
    MB_OK The message box contains one push button: OK. This is the default.
    MB_OKCANCEL The message box contains two push buttons: OK and Cancel.
    MB_RETRYCANCEL The message box contains two push buttons: Retry and Cancel.
    MB_YESNO The message box contains two push buttons: Yes and No.
    MB_YESNOCANCEL The message box contains three push buttons: Yes, No, and Cancel.MessageBox returns 0 if there isn抰 enough memory to create the message box. Otherwise it returns one of the following values:Value Numeric value MeaningIDOK 1 The user chose the OK button.
    IDCANCEL 2 The user chose the Cancel button.
    IDABORT 3 The user chose the Abort button.
    IDRETRY 4 The user chose the Retry button.
    IDIGNORE 5 The user chose the Ignore button.
    IDYES 6 The user chose the Yes button.
    IDNO 7 The user chose the No button.
      

  3.   

    if Application.MessageBox('确定要删除吗?','提示',MB_YESNO+MB_ICONQUESTION)=idok then
    //...
      

  4.   

    各位大哥,不知道你们有没有仔细看我的问题。首先是用Delphi8,再是用Delphi8的WinForm开发程序。真的不一样的。
    用了快6年的Delphi了。郁闷。
      

  5.   

    好了,我解决了。在D8中,虽然是Winform的程序,也可以使用VCL的内容。就是在uses中加上
    Borland.vcl.windows和Borland.vcl.forms,然后使用Application.MessageBox。唉,还是老路子。