mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-02-02 10:25:26 +02:00
Fixes #198: Setting the HwndParent for the Chrome_WidgetWin_0 window makes the popupmenu to close if the user clicks somewhere else.
This commit is contained in:
parent
e9f4bb16d6
commit
688969bcd7
@ -4513,6 +4513,22 @@ begin
|
||||
if Assigned(FOnRenderProcessTerminated) then FOnRenderProcessTerminated(Self, browser, status);
|
||||
end;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
function EnumProcOSRChromeWidgetWin0(hWnd: HWND; lParam: LPARAM): BOOL; stdcall;
|
||||
var
|
||||
ClsName: array[0..256] of Char;
|
||||
begin
|
||||
ClsName[GetClassName(hWnd, ClsName, 256)] := #0;
|
||||
if StrComp(ClsName, 'Chrome_WidgetWin_0') = 0 then
|
||||
begin
|
||||
PHandle(lParam)^ := hWnd;
|
||||
Result := False;
|
||||
end
|
||||
else
|
||||
Result := True;
|
||||
end;
|
||||
{$ENDIF MSWINDOWS}
|
||||
|
||||
procedure TChromiumCore.doOnRenderViewReady(const browser: ICefBrowser);
|
||||
{$IFDEF MSWINDOWS}
|
||||
var
|
||||
@ -4532,7 +4548,19 @@ begin
|
||||
FBrowserCompHWND := browser.Host.WindowHandle;
|
||||
{$IFDEF MSWINDOWS}
|
||||
if (FBrowserCompHWND <> 0) then
|
||||
begin
|
||||
FWidgetCompHWND := FindWindowEx(FBrowserCompHWND, 0, 'Chrome_WidgetWin_0', '');
|
||||
if (FWidgetCompHWND = 0) and FIsOSR and CefCurrentlyOn(TID_UI) then
|
||||
begin
|
||||
// The WidgetCompHWND window doesn't have a HwndParent (Owner). If we are in OSR mode this
|
||||
// causes popup menus that are opened by CEF to stay open if the user clicks somewhere else.
|
||||
// With this code we search for the Widget window in the UI Thread's window list and set
|
||||
// the Browser window as its HwndParent. This works around the bug.
|
||||
EnumThreadWindows(GetCurrentThreadId, @EnumProcOSRChromeWidgetWin0, NativeInt(@FWidgetCompHWND));
|
||||
if FWidgetCompHWND <> 0 then
|
||||
SetWindowLongPtr(FWidgetCompHWND, GWLP_HWNDPARENT, NativeInt(FBrowserCompHWND));
|
||||
end;
|
||||
end;
|
||||
|
||||
if (FWidgetCompHWND <> 0) then
|
||||
FRenderCompHWND := FindWindowEx(FWidgetCompHWND, 0, 'Chrome_RenderWidgetHostHWND', 'Chrome Legacy Window');
|
||||
|
@ -138,6 +138,7 @@ function PathIsURLUnicode(pszPath: LPCWSTR): BOOL; stdcall; external SHLWAPIDLL
|
||||
{$IFNDEF DELPHI12_UP}
|
||||
const
|
||||
GWLP_WNDPROC = GWL_WNDPROC;
|
||||
GWLP_HWNDPARENT = GWL_HWNDPARENT;
|
||||
{$IFDEF WIN64}
|
||||
function SetWindowLongPtr(hWnd: HWND; nIndex: Integer; dwNewLong: int64): int64; stdcall; external user32 name 'SetWindowLongPtrW';
|
||||
{$ELSE}
|
||||
|
Loading…
x
Reference in New Issue
Block a user