Цитата(Злоумышленник @ 24.6.2007, 22:54 ) | Почему так? |
Чтобы понять почему так, нужно посмотреть, как устроен Application.MessageBox. Вот код.
Код | 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;
|
Строки, на которые стоит посмотреть, я выделил. |