- remove stayOnTop flag on ShowModal and reset it back after
- bring modal window to front
(issue #0002011, #0007824)

git-svn-id: trunk@12252 -
This commit is contained in:
paul 2007-09-30 07:51:49 +00:00
parent 5aa0e950b7
commit 1a6c35994e
3 changed files with 67 additions and 4 deletions

View File

@ -1427,13 +1427,19 @@ begin
end;
WM_ENABLE:
begin
If WParam <> 0 Then
if WParam <> 0 Then
LMessage.Msg := LM_SETEDITABLE;
If Window=TWin32WidgetSet(WidgetSet).FAppHandle then
if WParam=0 then
DisableApplicationWindows(Window)
if Window = TWin32WidgetSet(WidgetSet).FAppHandle then
if WParam = 0 then
begin
RemoveStayOnTopFlags(Window);
DisableApplicationWindows(Window);
end
else
begin
RestoreStayOnTopFlags(Window);
EnableApplicationWindows(Window);
end;
If (lWinControl is TCustomFloatSpinEdit) then
EnableFloatSpinEditBuddy(Window, WParam<>0);

View File

@ -46,6 +46,7 @@ Type
AWinControl: TWinControl; // control associated with (for buddy controls)
List: TStrings;
DisabledWindowList: TList;// a list of windows that were disabled when showing modal
StayOnTopList: TList;
needParentPaint: boolean; // has a tabpage as parent, and is winxp themed
isTabPage: boolean; // is window of tabpage
isComboEdit: boolean; // is buddy of combobox, the edit control
@ -101,8 +102,12 @@ function AllocWindowInfo(Window: HWND): PWindowInfo;
function DisposeWindowInfo(Window: HWND): boolean;
function GetWindowInfo(Window: HWND): PWindowInfo;
function DisableWindowsProc(Window: HWND; Data: LParam): LongBool; stdcall;
procedure DisableApplicationWindows(Window: HWND);
procedure EnableApplicationWindows(Window: HWND);
procedure RemoveStayOnTopFlags(Window: HWND);
procedure RestoreStayOnTopFlags(Window: HWND);
procedure AddToChangedMenus(Window: HWnd);
procedure RedrawMenus;
function MeasureText(const AWinControl: TWinControl; Text: string; var Width, Height: integer): boolean;
@ -122,6 +127,12 @@ type
NewModalWindow: HWND;
DisabledWindowList: TList;
end;
PStayOnTopWindowsInfo = ^TStayOnTopWindowsInfo;
TStayOnTopWindowsInfo = record
AppWindow: HWND;
StayOnTopList: TList;
end;
var
DefaultWindowInfo: TWindowInfo;
@ -987,6 +998,7 @@ begin
if Result then
begin
WindowInfo^.DisabledWindowList.Free;
WindowInfo^.StayOnTopList.Free;
Dispose(WindowInfo);
end;
end;
@ -1071,6 +1083,50 @@ begin
end;
end;
function EnumStatOnTopRemove(Handle: HWND; Param: LPARAM): WINBOOL; stdcall;
var
AStyle: DWord;
StayOnTopWindowsInfo: PStayOnTopWindowsInfo absolute Param;
begin
Result := Handle <> StayOnTopWindowsInfo^.AppWindow;
AStyle := GetWindowLong(Handle, GWL_EXSTYLE);
if (AStyle and WS_EX_TOPMOST) <> 0 then // if stay on top then
begin
StayOnTopWindowsInfo^.StayOnTopList.Add(Pointer(Handle));
SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE);
end;
end;
procedure RemoveStayOnTopFlags(Window: HWND);
var
StayOnTopWindowsInfo: PStayOnTopWindowsInfo;
WindowInfo: PWindowInfo;
begin
New(StayOnTopWindowsInfo);
StayOnTopWindowsInfo^.AppWindow := Window;
StayOnTopWindowsInfo^.StayOnTopList := TList.Create;
WindowInfo := GetWindowInfo(Window);
WindowInfo^.StayOnTopList := StayOnTopWindowsInfo^.StayOnTopList;
EnumThreadWindows(GetWindowThreadProcessId(Window, nil),
@EnumStatOnTopRemove, LPARAM(StayOnTopWindowsInfo));
Dispose(StayOnTopWindowsInfo);
end;
procedure RestoreStayOnTopFlags(Window: HWND);
var
WindowInfo: PWindowInfo;
I: integer;
begin
WindowInfo := GetWindowInfo(Window);
if WindowInfo^.StayOnTopList <> nil then
begin
for I := 0 to WindowInfo^.StayOnTopList.Count - 1 do
SetWindowPos(HWND(WindowInfo^.StayOnTopList.Items[I]), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE);
FreeAndNil(WindowInfo^.StayOnTopList);
end;
end;
{-------------------------------------------------------------------------------
procedure AddToChangedMenus(Window: HWnd);

View File

@ -378,6 +378,7 @@ class procedure TWin32WSCustomForm.ShowModal(const ACustomForm: TCustomForm);
begin
DisableApplicationWindows(ACustomForm.Handle);
ShowWindow(ACustomForm.Handle, SW_SHOW);
BringWindowToTop(ACustomForm.Handle);
end;
{ TWin32WSHintWindow }