青
青云
Unregistered / Unconfirmed
GUEST, unregistred user!
下面是 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;
我想在它的基础上,让提示信息可以拷贝,这个功能很重要,不知道为何delphi不支持。
如果实现 提示信息拷贝 比较麻烦,那么也可以在提示窗体上加一个按钮,点这个按钮就让提示信息拷贝到粘贴板 ;
不知道有没有朋友搞过这个。
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;
我想在它的基础上,让提示信息可以拷贝,这个功能很重要,不知道为何delphi不支持。
如果实现 提示信息拷贝 比较麻烦,那么也可以在提示窗体上加一个按钮,点这个按钮就让提示信息拷贝到粘贴板 ;
不知道有没有朋友搞过这个。