messagebox(self.Handle,'操作成功!', '提示',MB_OK + MB_ICONASTERISK);

Application.MessageBox('请设置共享路径!','提示',MB_OK);
有什么不同吗?

解决方案 »

  1.   

    MessageBox是Windows提供的
    Application.MessageBox是Delphi封装的
    Application.MessageBox调用了MessageBox函数
      

  2.   

    没什么区别,不过application.messagebox不用传递句柄而已
      

  3.   

    可以参考下delphi里的源代码的 ~
      

  4.   

    那为什么Application.MessageBox是模态的,而MessageBox(Application.HANDLE....)是非模态?
      

  5.   

    Application是Form单元的一个全局对象 
    具体实现是 
    ---------------------- 
    function TApplication.MessageBox(const Text, Caption: PChar; Flags: Longint): Integer; 
    var 
    ActiveWindow: HWnd; 
    WindowList: Pointer; 
    MBMonitor, AppMonitor: HMonitor; 
    MonInfo: TMonitorInfo; 
    Rect: TRect; 
    FocusState: TFocusState; 
    begin 
    ActiveWindow := GetActiveWindow; 
    MBMonitor := MonitorFromWindow(ActiveWindow, MONITOR_DEFAULTTONEAREST); 
    AppMonitor := MonitorFromWindow(Handle, MONITOR_DEFAULTTONEAREST); 
    if MBMonitor <> AppMonitor then 
    begin 
    MonInfo.cbSize := Sizeof(TMonitorInfo); 
    GetMonitorInfo(MBMonitor, @MonInfo); 
    GetWindowRect(Handle, Rect); 
    SetWindowPos(Handle, 0, 
    MonInfo.rcMonitor.Left + ((MonInfo.rcMonitor.Right - MonInfo.rcMonitor.Left) div 2), 
    MonInfo.rcMonitor.Top + ((MonInfo.rcMonitor.Bottom - MonInfo.rcMonitor.Top) div 2), 
    0, 0, SWP_NOACTIVATE or SWP_NOREDRAW or SWP_NOSIZE or SWP_NOZORDER); 
    end; 
    WindowList := DisableTaskWindows(0); 
    FocusState := SaveFocusState; 
    if UseRightToLeftReading then Flags := Flags or MB_RTLREADING; 
    try 
    Result := Windows.MessageBox(Handle, Text, Caption, Flags); 
    finally 
    if MBMonitor <> AppMonitor then 
    SetWindowPos(Handle, 0, 
    Rect.Left + ((Rect.Right - Rect.Left) div 2), 
    Rect.Top + ((Rect.Bottom - Rect.Top) div 2), 
    0, 0, SWP_NOACTIVATE or SWP_NOREDRAW or SWP_NOSIZE or SWP_NOZORDER); 
    EnableTaskWindows(WindowList); 
    SetActiveWindow(ActiveWindow); 
    RestoreFocusState(FocusState); 
    end; 
    end; 
    --------------------------------- MessageBox是Windows单元的函数 
    可以看到Application.MessageBox调用了Windows.MessageBox 编译时要包含相应的单元 
    比如用到Application.Messagebox就包含Form 
    用到MessageBox要包含WIndows
      

  6.   

    最后一个参数除了MB_OK和MB_ICONASTERISK还有哪些东西啊?