mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 23:19:12 +02:00
win32: activate application when inactive disabled form is clicked (windows does not send any other messages for such forms than WM_SETCURSOR) - fixes issue #0019069
git-svn-id: trunk@36182 -
This commit is contained in:
parent
a793b4fa1f
commit
0d66913910
@ -706,32 +706,53 @@ var
|
|||||||
lControl: TControl;
|
lControl: TControl;
|
||||||
BoundsOffset: TRect;
|
BoundsOffset: TRect;
|
||||||
ACursor: TCursor;
|
ACursor: TCursor;
|
||||||
|
MouseMessage: Word;
|
||||||
begin
|
begin
|
||||||
if (lWinControl <> nil) and not (csDesigning in lWinControl.ComponentState)
|
if Assigned(lWinControl) then
|
||||||
and (LOWORD(LParam) = HTCLIENT) then
|
|
||||||
begin
|
begin
|
||||||
ACursor := Screen.Cursor;
|
if not (csDesigning in lWinControl.ComponentState) and (LOWORD(LParam) = HTCLIENT) then
|
||||||
if ACursor = crDefault then
|
|
||||||
begin
|
begin
|
||||||
Windows.GetCursorPos(Windows.POINT(P));
|
ACursor := Screen.Cursor;
|
||||||
Windows.ScreenToClient(Window, Windows.POINT(P));
|
if ACursor = crDefault then
|
||||||
if GetLCLClientBoundsOffset(lWinControl, BoundsOffset) then
|
|
||||||
begin
|
begin
|
||||||
Dec(P.X, BoundsOffset.Left);
|
Windows.GetCursorPos(Windows.POINT(P));
|
||||||
Dec(P.Y, BoundsOffset.Top);
|
Windows.ScreenToClient(Window, Windows.POINT(P));
|
||||||
|
if GetLCLClientBoundsOffset(lWinControl, BoundsOffset) then
|
||||||
|
begin
|
||||||
|
Dec(P.X, BoundsOffset.Left);
|
||||||
|
Dec(P.Y, BoundsOffset.Top);
|
||||||
|
end;
|
||||||
|
// TGraphicControl controls do not get WM_SETCURSOR messages...
|
||||||
|
lControl := lWinControl.ControlAtPos(P, [capfOnlyClientAreas,
|
||||||
|
capfAllowWinControls, capfHasScrollOffset, capfRecursive]);
|
||||||
|
if lControl = nil then
|
||||||
|
lControl := lWinControl;
|
||||||
|
ACursor := lControl.Cursor;
|
||||||
end;
|
end;
|
||||||
// TGraphicControl controls do not get WM_SETCURSOR messages...
|
if ACursor <> crDefault then
|
||||||
lControl := lWinControl.ControlAtPos(P, [capfOnlyClientAreas,
|
begin
|
||||||
capfAllowWinControls, capfHasScrollOffset, capfRecursive]);
|
// DebugLn('Set cursor. Control = ', LControl.Name, ' cur = ',ACursor);
|
||||||
if lControl = nil then
|
Windows.SetCursor(Screen.Cursors[ACursor]);
|
||||||
lControl := lWinControl;
|
LMessage.Result := 1;
|
||||||
ACursor := lControl.Cursor;
|
end;
|
||||||
end;
|
end
|
||||||
if ACursor <> crDefault then
|
else
|
||||||
|
if (LOWORD(LParam) = Word(HTERROR)) then
|
||||||
begin
|
begin
|
||||||
// DebugLn('Set cursor. Control = ', LControl.Name, ' cur = ',ACursor);
|
MouseMessage := HIWORD(LParam);
|
||||||
Windows.SetCursor(Screen.Cursors[ACursor]);
|
// a mouse click on a window
|
||||||
LMessage.Result := 1;
|
if ((MouseMessage = WM_LBUTTONDOWN) or
|
||||||
|
(MouseMessage = WM_RBUTTONDOWN) or
|
||||||
|
(MouseMessage = WM_XBUTTONDOWN)) and
|
||||||
|
Assigned(Screen) and Assigned(Screen.ActiveCustomForm) and
|
||||||
|
Screen.ActiveCustomForm.HandleAllocated and
|
||||||
|
(GetForegroundWindow <> Screen.ActiveCustomForm.Handle) then
|
||||||
|
begin
|
||||||
|
// A mouse click is happen on our application window which is not active
|
||||||
|
// we need to active it ourself. This is needed only when click is happen
|
||||||
|
// on disabled window (e.g. ShowModal is called and non modal window is clicked)
|
||||||
|
Win32WidgetSet.AppBringToFront;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if LMessage.Result = 0 then
|
if LMessage.Result = 0 then
|
||||||
@ -1005,7 +1026,6 @@ begin
|
|||||||
WinProcess := True;
|
WinProcess := True;
|
||||||
NotifyUserInput := False;
|
NotifyUserInput := False;
|
||||||
|
|
||||||
//WriteLn('Msg: ', WM_To_String(Msg), ' ', WndClassName(Window));
|
|
||||||
WindowInfo := GetWin32WindowInfo(Window);
|
WindowInfo := GetWin32WindowInfo(Window);
|
||||||
if WindowInfo^.isChildEdit then
|
if WindowInfo^.isChildEdit then
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user