mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2024-11-24 08:02:15 +02:00
Moved TChromium.InitializeDragAndDrop to TForm.OnShow in PopupBrowser
This commit is contained in:
parent
c455886d29
commit
1d8773c42c
@ -3,7 +3,9 @@
|
||||
<body>
|
||||
|
||||
<p>The following button opens google.com in a popup window.</p>
|
||||
<button onclick="return popitup('https://www.google.com')">Click me</button>
|
||||
<button onclick="return popitup('https://www.google.com')">Click me to open Google</button><br/><br/>
|
||||
<button onclick="return popitup('about:blank')">Click me to open blank</button><br/><br/>
|
||||
<button onclick="return popitup('file:///PopupBrowser.html')">Click me to open a file</button><br/><br/>
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
<!--
|
||||
|
@ -50,7 +50,8 @@ uses
|
||||
Windows, Messages, SysUtils, Variants, Classes, SyncObjs,
|
||||
Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, AppEvnts,
|
||||
{$ENDIF}
|
||||
uCEFChromium, uCEFTypes, uCEFInterfaces, uCEFConstants, uCEFBufferPanel;
|
||||
uCEFChromium, uCEFTypes, uCEFInterfaces, uCEFConstants, uCEFBufferPanel,
|
||||
uCEFChromiumCore;
|
||||
|
||||
const
|
||||
CEF_SHOWCHILD = WM_APP + $A52;
|
||||
@ -77,7 +78,7 @@ type
|
||||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||||
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
|
||||
procedure Chromium1Paint(Sender: TObject; const browser: ICefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer);
|
||||
procedure Chromium1Paint(Sender: TObject; const browser: ICefBrowser; type_: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer);
|
||||
procedure Chromium1CursorChange(Sender: TObject; const browser: ICefBrowser; cursor: HICON; cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo);
|
||||
procedure Chromium1GetViewRect(Sender: TObject; const browser: ICefBrowser; var rect: TCefRect);
|
||||
procedure Chromium1GetScreenPoint(Sender: TObject; const browser: ICefBrowser; viewX, viewY: Integer; var screenX, screenY: Integer; out Result: Boolean);
|
||||
@ -306,8 +307,6 @@ function TChildForm.CreateClientHandler(var windowInfo : TCefWindowInfo;
|
||||
const targetFrameName : string;
|
||||
const popupFeatures : TCefPopupFeatures) : boolean;
|
||||
begin
|
||||
Chromium1.InitializeDragAndDrop(Panel1);
|
||||
|
||||
WindowInfoAsWindowless(windowInfo, 0, targetFrameName);
|
||||
FPopupFeatures := popupFeatures;
|
||||
FClientInitialized := Chromium1.CreateClientHandler(client);
|
||||
@ -328,7 +327,7 @@ begin
|
||||
PostMessage(Handle, WM_CLOSE, 0, 0);
|
||||
end;
|
||||
|
||||
procedure TChildForm.Chromium1BeforePopup(Sender : TObject;
|
||||
procedure TChildForm.Chromium1BeforePopup( Sender : TObject;
|
||||
const browser : ICefBrowser;
|
||||
const frame : ICefFrame;
|
||||
const targetUrl : ustring;
|
||||
@ -354,7 +353,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TChildForm.Chromium1CursorChange(Sender : TObject;
|
||||
procedure TChildForm.Chromium1CursorChange( Sender : TObject;
|
||||
const browser : ICefBrowser;
|
||||
cursor : HICON;
|
||||
cursorType : TCefCursorType;
|
||||
@ -363,7 +362,7 @@ begin
|
||||
Panel1.Cursor := CefCursorToWindowsCursor(cursorType);
|
||||
end;
|
||||
|
||||
procedure TChildForm.Chromium1GetScreenInfo(Sender : TObject;
|
||||
procedure TChildForm.Chromium1GetScreenInfo( Sender : TObject;
|
||||
const browser : ICefBrowser;
|
||||
var screenInfo : TCefScreenInfo;
|
||||
out Result : Boolean);
|
||||
@ -390,7 +389,7 @@ begin
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
procedure TChildForm.Chromium1GetScreenPoint(Sender : TObject;
|
||||
procedure TChildForm.Chromium1GetScreenPoint( Sender : TObject;
|
||||
const browser : ICefBrowser;
|
||||
viewX : Integer;
|
||||
viewY : Integer;
|
||||
@ -413,7 +412,7 @@ begin
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
procedure TChildForm.Chromium1GetViewRect(Sender : TObject;
|
||||
procedure TChildForm.Chromium1GetViewRect( Sender : TObject;
|
||||
const browser : ICefBrowser;
|
||||
var rect : TCefRect);
|
||||
begin
|
||||
@ -428,7 +427,7 @@ end;
|
||||
|
||||
procedure TChildForm.Chromium1Paint( Sender : TObject;
|
||||
const browser : ICefBrowser;
|
||||
kind : TCefPaintElementType;
|
||||
type_ : TCefPaintElementType;
|
||||
dirtyRectsCount : NativeUInt;
|
||||
const dirtyRects : PCefRectArray;
|
||||
const buffer : Pointer;
|
||||
@ -448,7 +447,7 @@ begin
|
||||
|
||||
if Panel1.BeginBufferDraw then
|
||||
begin
|
||||
if (kind = PET_POPUP) then
|
||||
if (type_ = PET_POPUP) then
|
||||
begin
|
||||
if (FPopUpBitmap = nil) or
|
||||
(width <> FPopUpBitmap.Width) or
|
||||
@ -523,7 +522,7 @@ begin
|
||||
Panel1.EndBufferDraw;
|
||||
Panel1.InvalidatePanel;
|
||||
|
||||
if (kind = PET_VIEW) then
|
||||
if (type_ = PET_VIEW) then
|
||||
begin
|
||||
if TempForcedResize or FPendingResize then PostMessage(Handle, CEF_PENDINGRESIZE, 0, 0);
|
||||
|
||||
@ -536,7 +535,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TChildForm.Chromium1PopupShow(Sender : TObject;
|
||||
procedure TChildForm.Chromium1PopupShow( Sender : TObject;
|
||||
const browser : ICefBrowser;
|
||||
show : Boolean);
|
||||
begin
|
||||
@ -547,11 +546,11 @@ begin
|
||||
FShowPopUp := False;
|
||||
FPopUpRect := rect(0, 0, 0, 0);
|
||||
|
||||
if (Chromium1 <> nil) then Chromium1.Invalidate(PET_VIEW);
|
||||
Chromium1.Invalidate(PET_VIEW);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TChildForm.Chromium1PopupSize(Sender : TObject;
|
||||
procedure TChildForm.Chromium1PopupSize( Sender : TObject;
|
||||
const browser : ICefBrowser;
|
||||
const rect : PCefRect);
|
||||
begin
|
||||
@ -566,12 +565,17 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TChildForm.Chromium1TitleChange(Sender: TObject; const browser: ICefBrowser; const title: ustring);
|
||||
procedure TChildForm.Chromium1TitleChange( Sender : TObject;
|
||||
const browser : ICefBrowser;
|
||||
const title : ustring);
|
||||
begin
|
||||
Caption := title;
|
||||
end;
|
||||
|
||||
procedure TChildForm.Chromium1Tooltip(Sender: TObject; const browser: ICefBrowser; var text: ustring; out Result: Boolean);
|
||||
procedure TChildForm.Chromium1Tooltip( Sender : TObject;
|
||||
const browser : ICefBrowser;
|
||||
var text : ustring;
|
||||
out Result : Boolean);
|
||||
begin
|
||||
Panel1.hint := text;
|
||||
Panel1.ShowHint := (length(text) > 0);
|
||||
@ -603,28 +607,28 @@ procedure TChildForm.WMMove(var aMessage : TWMMove);
|
||||
begin
|
||||
inherited;
|
||||
|
||||
if (Chromium1 <> nil) then Chromium1.NotifyMoveOrResizeStarted;
|
||||
Chromium1.NotifyMoveOrResizeStarted;
|
||||
end;
|
||||
|
||||
procedure TChildForm.WMMoving(var aMessage : TMessage);
|
||||
begin
|
||||
inherited;
|
||||
|
||||
if (Chromium1 <> nil) then Chromium1.NotifyMoveOrResizeStarted;
|
||||
Chromium1.NotifyMoveOrResizeStarted;
|
||||
end;
|
||||
|
||||
procedure TChildForm.WMCaptureChanged(var aMessage : TMessage);
|
||||
begin
|
||||
inherited;
|
||||
|
||||
if (Chromium1 <> nil) then Chromium1.SendCaptureLostEvent;
|
||||
Chromium1.SendCaptureLostEvent;
|
||||
end;
|
||||
|
||||
procedure TChildForm.WMCancelMode(var aMessage : TMessage);
|
||||
begin
|
||||
inherited;
|
||||
|
||||
if (Chromium1 <> nil) then Chromium1.SendCaptureLostEvent;
|
||||
Chromium1.SendCaptureLostEvent;
|
||||
end;
|
||||
|
||||
procedure TChildForm.WMEnterMenuLoop(var aMessage: TMessage);
|
||||
@ -643,11 +647,8 @@ end;
|
||||
|
||||
procedure TChildForm.FormAfterMonitorDpiChanged(Sender: TObject; OldDPI, NewDPI: Integer);
|
||||
begin
|
||||
if (Chromium1 <> nil) then
|
||||
begin
|
||||
Chromium1.NotifyScreenInfoChanged;
|
||||
Chromium1.WasResized;
|
||||
end;
|
||||
Chromium1.NotifyScreenInfoChanged;
|
||||
Chromium1.WasResized;
|
||||
end;
|
||||
|
||||
procedure TChildForm.FormClose(Sender: TObject; var Action: TCloseAction);
|
||||
@ -663,7 +664,11 @@ begin
|
||||
begin
|
||||
FClosing := True;
|
||||
Visible := False;
|
||||
Chromium1.CloseBrowser(True);
|
||||
|
||||
if Chromium1.Initialized then
|
||||
Chromium1.CloseBrowser(True)
|
||||
else
|
||||
CanClose := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -700,6 +705,7 @@ end;
|
||||
|
||||
procedure TChildForm.FormShow(Sender: TObject);
|
||||
begin
|
||||
Chromium1.InitializeDragAndDrop(Panel1);
|
||||
Chromium1.WasHidden(False);
|
||||
Chromium1.SendFocusEvent(True);
|
||||
end;
|
||||
@ -714,7 +720,7 @@ var
|
||||
TempEvent : TCefMouseEvent;
|
||||
TempTime : integer;
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) and (Chromium1 <> nil) then
|
||||
if (GlobalCEFApp <> nil) then
|
||||
begin
|
||||
Panel1.SetFocus;
|
||||
|
||||
@ -744,7 +750,7 @@ var
|
||||
TempPoint : TPoint;
|
||||
TempTime : integer;
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) and (Chromium1 <> nil) then
|
||||
if (GlobalCEFApp <> nil) then
|
||||
begin
|
||||
GetCursorPos(TempPoint);
|
||||
TempPoint := Panel1.ScreenToclient(TempPoint);
|
||||
@ -764,7 +770,7 @@ var
|
||||
TempEvent : TCefMouseEvent;
|
||||
TempTime : integer;
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) and (Chromium1 <> nil) then
|
||||
if (GlobalCEFApp <> nil) then
|
||||
begin
|
||||
if CancelPreviousClick(x, y, TempTime) then InitializeLastClick;
|
||||
|
||||
@ -780,7 +786,7 @@ procedure TChildForm.Panel1MouseUp(Sender: TObject; Button: TMouseButton; Shift:
|
||||
var
|
||||
TempEvent : TCefMouseEvent;
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) and (Chromium1 <> nil) then
|
||||
if (GlobalCEFApp <> nil) then
|
||||
begin
|
||||
TempEvent.x := X;
|
||||
TempEvent.y := Y;
|
||||
|
@ -154,6 +154,13 @@ begin
|
||||
GlobalCEFApp.EnableHighDPISupport := True;
|
||||
//GlobalCEFApp.LogFile := 'debug.log';
|
||||
//GlobalCEFApp.LogSeverity := LOGSEVERITY_INFO;
|
||||
{
|
||||
GlobalCEFApp.FrameworkDirPath := 'c:\cef';
|
||||
GlobalCEFApp.ResourcesDirPath := 'c:\cef';
|
||||
GlobalCEFApp.LocalesDirPath := 'c:\cef\locales';
|
||||
GlobalCEFApp.cache := 'c:\cef\cache';
|
||||
GlobalCEFApp.UserDataPath := 'c:\cef\User Data';
|
||||
}
|
||||
end;
|
||||
|
||||
procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
@ -212,7 +219,7 @@ begin
|
||||
PostMessage(Handle, CEF_AFTERCREATED, 0, 0);
|
||||
end;
|
||||
|
||||
procedure TMainForm.Chromium1BeforePopup(Sender : TObject;
|
||||
procedure TMainForm.Chromium1BeforePopup( Sender : TObject;
|
||||
const browser : ICefBrowser;
|
||||
const frame : ICefFrame;
|
||||
const targetUrl : ustring;
|
||||
@ -342,11 +349,7 @@ begin
|
||||
FCriticalSection.Acquire;
|
||||
|
||||
if (FChildForm <> nil) then
|
||||
begin
|
||||
//FChildForm.ApplyPopupFeatures;
|
||||
//FChildForm.Show;
|
||||
PostMessage(FChildForm.Handle, CEF_SHOWCHILD, 0, 0);
|
||||
end;
|
||||
PostMessage(FChildForm.Handle, CEF_SHOWCHILD, 0, 0);
|
||||
|
||||
FChildForm := TChildForm.Create(self);
|
||||
finally
|
||||
|
@ -4,13 +4,13 @@
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="11"/>
|
||||
<BuildModes Active="Default"/>
|
||||
<Units Count="8">
|
||||
<Units Count="9">
|
||||
<Unit0>
|
||||
<Filename Value="MiniBrowser.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="46"/>
|
||||
<CursorPos Y="54"/>
|
||||
<UsageCount Value="20"/>
|
||||
<UsageCount Value="21"/>
|
||||
<Loaded Value="True"/>
|
||||
<DefaultSyntaxHighlighter Value="Delphi"/>
|
||||
</Unit0>
|
||||
@ -20,11 +20,10 @@
|
||||
<ComponentName Value="MiniBrowserFrm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<TopLine Value="735"/>
|
||||
<CursorPos X="43" Y="749"/>
|
||||
<UsageCount Value="20"/>
|
||||
<UsageCount Value="21"/>
|
||||
<Bookmarks Count="3">
|
||||
<Item0 Y="806" ID="1"/>
|
||||
<Item1 X="49" Y="61" ID="2"/>
|
||||
@ -40,10 +39,10 @@
|
||||
<ComponentName Value="PreferencesFrm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<TopLine Value="69"/>
|
||||
<CursorPos X="86" Y="70"/>
|
||||
<UsageCount Value="20"/>
|
||||
<UsageCount Value="21"/>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
<DefaultSyntaxHighlighter Value="Delphi"/>
|
||||
@ -55,7 +54,7 @@
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<UsageCount Value="20"/>
|
||||
<UsageCount Value="21"/>
|
||||
<DefaultSyntaxHighlighter Value="Delphi"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
@ -86,6 +85,15 @@
|
||||
<TopLine Value="43"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit7>
|
||||
<Unit8>
|
||||
<Filename Value="..\..\..\source\uCEFTypes.pas"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<TopLine Value="280"/>
|
||||
<CursorPos X="51" Y="290"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit8>
|
||||
</Units>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
|
@ -2,7 +2,7 @@
|
||||
"UpdateLazPackages" : [
|
||||
{
|
||||
"ForceNotify" : true,
|
||||
"InternalVersion" : 68,
|
||||
"InternalVersion" : 69,
|
||||
"Name" : "cef4delphi_lazarus.lpk",
|
||||
"Version" : "78.3.4.0"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user