win32: apply Dmitry patch with modifications for fixing application focus - move focus to last focused window on getting focus event (issue #0015494)

git-svn-id: trunk@23911 -
This commit is contained in:
paul 2010-03-10 08:22:45 +00:00
parent c45eae6352
commit a77478ebb9
2 changed files with 17 additions and 0 deletions

View File

@ -2028,11 +2028,27 @@ begin
begin
HandleSetCursor;
end;
CM_ACTIVATE:
begin
if (Window = Win32WidgetSet.AppHandle) then
begin
if not IsIconic(Window) and IsWindow(WindowLastFocused) then
SetFocus(WindowLastFocused);
Result := 0;
Exit;
end;
WinProcess := False;
end;
WM_SETFOCUS:
begin
{$ifdef DEBUG_CARET}
DebugLn('WM_SETFOCUS received for window ', IntToHex(Window, 8));
{$endif}
// move focus to another application window but process event first
if (Window = Win32WidgetSet.AppHandle) then
PostMessage(Window, CM_ACTIVATE, 0, 0)
else
WindowLastFocused := Window;
// handle feature mouse-click, setfocus, mouse-click -> double-click
if (Window <> MouseDownWindow) and (MouseDownFocusStatus <> mfNone) then
begin

View File

@ -269,6 +269,7 @@ var
MouseDownWindow: HWND = 0;
MouseDownFocusWindow: HWND;
MouseDownFocusStatus: TMouseDownFocusStatus = mfNone;
WindowLastFocused: HWND = 0;
ComboBoxHandleSizeWindow: HWND = 0;
IgnoreNextCharWindow: HWND = 0; // ignore next WM_(SYS)CHAR message
// set to true, if we are redirecting a WM_MOUSEWHEEL message, to prevent recursion