刚学delphi不久,知道其中MessageDlg()、MessageBox()等几个函数都是用过来弹出一个提示对话框的,但是感觉效果都差不多,不知道具体该怎么用。在这里请大家能够指教一下关于delphi中常用的一些消息提示函数和具体的说明,最好能够讲解一下具体在什么环境下运用。现谢谢了!

解决方案 »

  1.   

    1.procedure ShowMessage(const Msg: string);
      单元:Dialogsor QDialogs
      例子:showmessage('hello');
    2.function MessageBox(const Text, Caption: PChar; Flags: Longint = MB_OK): Integer;
      单元:Forms
      例子:MessageBox('This should be on top.', 'Look', mb_OK)
      注:delphi的帮助文档提供的例子好像有误他的最后一个参数是[sbmok]
    3.function MessageDlg(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint): Word;
      单元:Dialogsor QDialogs
      例子:if messagedlg('确定要退出吗?',mtwarnint,[mbyes,mbno],0)=mryes then close;
    4.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
       );
      单元:windows API
      例子:windows.messagebox(0,'标题','警告错误',MB_ICONSTOP);