mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2024-11-24 08:02:15 +02:00
Added more conditional cmpilation for Windows
- Fixed bug with space char in OSR mode. - SimpleOSRBrowser demo now follows the destruction sequence steps for browsers in OSR mode.
This commit is contained in:
parent
6ec75477ef
commit
a2ad188dc5
@ -236,7 +236,7 @@ begin
|
||||
TempKeyEvent.focus_on_editable_field := ord(False);
|
||||
|
||||
chrmosr.SendKeyEvent(@TempKeyEvent);
|
||||
Handled := True;
|
||||
Handled := (Msg.wParam = VK_TAB);
|
||||
end;
|
||||
|
||||
WM_KEYUP :
|
||||
|
@ -40,8 +40,6 @@ object ChildForm: TChildForm
|
||||
OnMouseUp = Panel1MouseUp
|
||||
OnResize = Panel1Resize
|
||||
OnMouseLeave = Panel1MouseLeave
|
||||
ExplicitWidth = 800
|
||||
ExplicitHeight = 530
|
||||
end
|
||||
object Chromium1: TChromium
|
||||
OnTitleChange = Chromium1TitleChange
|
||||
|
@ -232,7 +232,7 @@ begin
|
||||
TempKeyEvent.focus_on_editable_field := ord(False);
|
||||
|
||||
Chromium1.SendKeyEvent(@TempKeyEvent);
|
||||
Handled := True;
|
||||
Handled := (Msg.wParam = VK_TAB);
|
||||
end
|
||||
else
|
||||
Handled := False;
|
||||
|
@ -253,7 +253,7 @@ begin
|
||||
if (TempForm is TChildForm) and
|
||||
TChildForm(TempForm).ClientInitialized and
|
||||
not(TChildForm(TempForm).Closing) then
|
||||
PostMessage(TChildForm(screen.CustomForms[i]).Handle, WM_CLOSE, 0, 0);
|
||||
PostMessage(TChildForm(TempForm).Handle, WM_CLOSE, 0, 0);
|
||||
|
||||
dec(i);
|
||||
end;
|
||||
|
@ -13,6 +13,7 @@ object Form1: TForm1
|
||||
OldCreateOrder = False
|
||||
Position = poScreenCenter
|
||||
OnAfterMonitorDpiChanged = FormAfterMonitorDpiChanged
|
||||
OnCloseQuery = FormCloseQuery
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
OnHide = FormHide
|
||||
@ -123,6 +124,8 @@ object Form1: TForm1
|
||||
OnTooltip = chrmosrTooltip
|
||||
OnBeforePopup = chrmosrBeforePopup
|
||||
OnAfterCreated = chrmosrAfterCreated
|
||||
OnBeforeClose = chrmosrBeforeClose
|
||||
OnClose = chrmosrClose
|
||||
OnGetViewRect = chrmosrGetViewRect
|
||||
OnGetScreenPoint = chrmosrGetScreenPoint
|
||||
OnGetScreenInfo = chrmosrGetScreenInfo
|
||||
|
@ -84,6 +84,7 @@ type
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure FormHide(Sender: TObject);
|
||||
procedure FormAfterMonitorDpiChanged(Sender: TObject; OldDPI, NewDPI: Integer);
|
||||
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
|
||||
procedure chrmosrPaint(Sender: TObject; const browser: ICefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer);
|
||||
procedure chrmosrCursorChange(Sender: TObject; const browser: ICefBrowser; cursor: HICON; cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo);
|
||||
@ -94,18 +95,14 @@ type
|
||||
procedure chrmosrPopupSize(Sender: TObject; const browser: ICefBrowser; const rect: PCefRect);
|
||||
procedure chrmosrAfterCreated(Sender: TObject; const browser: ICefBrowser);
|
||||
procedure chrmosrTooltip(Sender: TObject; const browser: ICefBrowser; var text: ustring; out Result: Boolean);
|
||||
procedure chrmosrBeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; var popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var noJavascriptAccess: Boolean; out Result: Boolean);
|
||||
procedure chrmosrClose(Sender: TObject; const browser: ICefBrowser; out Result: Boolean);
|
||||
procedure chrmosrBeforeClose(Sender: TObject; const browser: ICefBrowser);
|
||||
|
||||
procedure SnapshotBtnClick(Sender: TObject);
|
||||
procedure Timer1Timer(Sender: TObject);
|
||||
procedure SnapshotBtnEnter(Sender: TObject);
|
||||
procedure ComboBox1Enter(Sender: TObject);
|
||||
procedure chrmosrBeforePopup(Sender: TObject;
|
||||
const browser: ICefBrowser; const frame: ICefFrame; const targetUrl,
|
||||
targetFrameName: ustring;
|
||||
targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean;
|
||||
var popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo;
|
||||
var client: ICefClient; var settings: TCefBrowserSettings;
|
||||
var noJavascriptAccess: Boolean; out Result: Boolean);
|
||||
|
||||
protected
|
||||
FPopUpBitmap : TBitmap;
|
||||
@ -113,6 +110,8 @@ type
|
||||
FShowPopUp : boolean;
|
||||
FResizing : boolean;
|
||||
FPendingResize : boolean;
|
||||
FCanClose : boolean;
|
||||
FClosing : boolean;
|
||||
FResizeCS : TCriticalSection;
|
||||
|
||||
function getModifiers(Shift: TShiftState): TCefEventFlags;
|
||||
@ -147,14 +146,12 @@ uses
|
||||
{$ENDIF}
|
||||
uCEFMiscFunctions, uCEFApplication;
|
||||
|
||||
// *********************************
|
||||
// ********* ATTENTION !!! *********
|
||||
// *********************************
|
||||
//
|
||||
// There is a known bug in the destruction of TChromium in OSR mode.
|
||||
// If you destroy the TChromium in OSR mode before the application is closed,
|
||||
// add a timer and wait 1-2 seconds after the TChromium's destruction.
|
||||
// After that you can close the app. Hide the application in the task bar if necessary.
|
||||
// This is the destruction sequence in OSR mode :
|
||||
// 1- FormCloseQuery sets CanClose to the initial FCanClose value (False) and calls chrmosr.CloseBrowser(True).
|
||||
// 2- chrmosr.CloseBrowser(True) will trigger chrmosr.OnClose and we have to
|
||||
// set "Result" to false and CEF3 will destroy the internal browser immediately.
|
||||
// 3- chrmosr.OnBeforeClose is triggered because the internal browser was destroyed.
|
||||
// Now we set FCanClose to True and send WM_CLOSE to the form.
|
||||
|
||||
procedure TForm1.AppEventsMessage(var Msg: tagMSG; var Handled: Boolean);
|
||||
var
|
||||
@ -223,7 +220,7 @@ begin
|
||||
TempKeyEvent.focus_on_editable_field := ord(False);
|
||||
|
||||
chrmosr.SendKeyEvent(@TempKeyEvent);
|
||||
Handled := True;
|
||||
Handled := (Msg.wParam = VK_TAB);
|
||||
end;
|
||||
|
||||
WM_KEYUP :
|
||||
@ -290,6 +287,12 @@ begin
|
||||
PostMessage(Handle, CEF_AFTERCREATED, 0, 0);
|
||||
end;
|
||||
|
||||
procedure TForm1.chrmosrBeforeClose(Sender: TObject; const browser: ICefBrowser);
|
||||
begin
|
||||
FCanClose := True;
|
||||
PostMessage(Handle, WM_CLOSE, 0, 0);
|
||||
end;
|
||||
|
||||
procedure TForm1.chrmosrBeforePopup(Sender : TObject;
|
||||
const browser : ICefBrowser;
|
||||
const frame : ICefFrame;
|
||||
@ -308,6 +311,11 @@ begin
|
||||
Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]);
|
||||
end;
|
||||
|
||||
procedure TForm1.chrmosrClose(Sender: TObject; const browser: ICefBrowser; out Result: Boolean);
|
||||
begin
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
procedure TForm1.chrmosrCursorChange(Sender : TObject;
|
||||
const browser : ICefBrowser;
|
||||
cursor : HICON;
|
||||
@ -615,6 +623,18 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
begin
|
||||
CanClose := FCanClose;
|
||||
|
||||
if not(FClosing) then
|
||||
begin
|
||||
FClosing := True;
|
||||
Visible := False;
|
||||
chrmosr.CloseBrowser(True);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
FPopUpBitmap := nil;
|
||||
@ -622,6 +642,8 @@ begin
|
||||
FShowPopUp := False;
|
||||
FResizing := False;
|
||||
FPendingResize := False;
|
||||
FCanClose := False;
|
||||
FClosing := False;
|
||||
FResizeCS := TCriticalSection.Create;
|
||||
end;
|
||||
|
||||
|
@ -43,8 +43,8 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
Winapi.Windows, Winapi.Messages, System.Classes, Vcl.ExtCtrls, Vcl.Controls,
|
||||
Vcl.Graphics, System.SyncObjs, System.SysUtils;
|
||||
{$IFDEF MSWINDOWS}Winapi.Windows, Winapi.Messages, Vcl.ExtCtrls, Vcl.Controls, Vcl.Graphics,{$ENDIF}
|
||||
System.Classes, System.SyncObjs, System.SysUtils;
|
||||
{$ELSE}
|
||||
Windows, Messages, Classes, Controls,
|
||||
ExtCtrls, Graphics, SyncObjs, SysUtils;
|
||||
@ -148,6 +148,9 @@ type
|
||||
property OnMouseDown;
|
||||
property OnMouseMove;
|
||||
property OnMouseUp;
|
||||
property OnKeyDown;
|
||||
property OnKeyPress;
|
||||
property OnKeyUp;
|
||||
property OnResize;
|
||||
property OnStartDock;
|
||||
property OnStartDrag;
|
||||
|
@ -48,7 +48,7 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows, System.Classes, System.UITypes,
|
||||
System.Classes, System.UITypes,
|
||||
{$ELSE}
|
||||
Windows, Classes,
|
||||
{$ENDIF}
|
||||
|
@ -48,7 +48,7 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows, System.Classes, System.UITypes,
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Classes, System.UITypes,
|
||||
{$ELSE}
|
||||
Windows, Classes,
|
||||
{$ENDIF}
|
||||
|
@ -48,7 +48,7 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows, WinApi.Messages, System.Classes, Vcl.Controls, Vcl.Graphics, Vcl.Forms, WinApi.ActiveX,
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages, Vcl.Controls, Vcl.Graphics, Vcl.Forms, WinApi.ActiveX,{$ENDIF} System.Classes,
|
||||
{$ELSE}
|
||||
Windows, Messages, Classes, Controls, Graphics, Forms, ActiveX,
|
||||
{$ENDIF}
|
||||
|
@ -48,9 +48,9 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows, System.Classes, WinApi.Messages,
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages,{$ENDIF} System.Classes,
|
||||
{$ELSE}
|
||||
Windows, Classes, Messages,
|
||||
Windows, Messages, Classes,
|
||||
{$ENDIF}
|
||||
uCEFWindowParent, uCEFChromium, uCEFInterfaces, uCEFConstants;
|
||||
|
||||
|
@ -47,11 +47,6 @@ unit uCEFClient;
|
||||
interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows,
|
||||
{$ELSE}
|
||||
Windows,
|
||||
{$ENDIF}
|
||||
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
||||
|
||||
type
|
||||
|
@ -388,3 +388,4 @@ implementation
|
||||
|
||||
end.
|
||||
|
||||
|
||||
|
@ -43,8 +43,8 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows, System.Classes, Vcl.Controls, System.SysUtils, System.Math,
|
||||
WinApi.ActiveX, WinApi.ShlObj, WinApi.ShellApi, System.StrUtils, System.AnsiStrings,
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows, WinApi.ActiveX, WinApi.ShlObj, WinApi.ShellApi, Vcl.Controls,{$ENDIF}
|
||||
System.Classes, System.SysUtils, System.Math, System.StrUtils, System.AnsiStrings,
|
||||
{$ELSE}
|
||||
Windows, Classes, Controls, SysUtils, Math,
|
||||
ActiveX, ShlObj, Shellapi, StrUtils,
|
||||
|
@ -48,7 +48,7 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows,
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF}
|
||||
{$ELSE}
|
||||
Windows,
|
||||
{$ENDIF}
|
||||
|
@ -48,7 +48,7 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows, System.Classes,
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Classes,
|
||||
{$ELSE}
|
||||
Windows, Classes,
|
||||
{$ENDIF}
|
||||
|
@ -48,7 +48,7 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows, System.Math,
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Math,
|
||||
{$ELSE}
|
||||
Windows, Math,
|
||||
{$ENDIF}
|
||||
|
@ -48,7 +48,8 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows, System.Classes, System.SysUtils, System.UITypes, WinApi.ActiveX, System.Math,
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows, WinApi.ActiveX,{$ENDIF}
|
||||
System.Classes, System.SysUtils, System.UITypes, System.Math,
|
||||
{$ELSE}
|
||||
Windows, Classes, SysUtils, Controls, ActiveX, Math,
|
||||
{$ENDIF}
|
||||
|
@ -112,7 +112,7 @@ implementation
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows, System.SysUtils,
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.SysUtils,
|
||||
{$ELSE}
|
||||
Windows, SysUtils,
|
||||
{$ENDIF}
|
||||
|
@ -48,7 +48,8 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows, WinApi.Messages, System.Classes, Vcl.Controls, Vcl.Graphics, Vcl.Forms, WinApi.ActiveX, System.Math,
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages, Vcl.Controls, Vcl.Graphics, Vcl.Forms, WinApi.ActiveX,{$ENDIF}
|
||||
System.Classes, System.Math,
|
||||
{$ELSE}
|
||||
Windows, Messages, Classes, Controls, Graphics, Forms, ActiveX, Math,
|
||||
{$ENDIF}
|
||||
|
@ -48,7 +48,7 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows, System.Math;
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Math;
|
||||
{$ELSE}
|
||||
Windows, Math;
|
||||
{$ENDIF}
|
||||
|
@ -48,7 +48,7 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows, WinApi.Messages, System.Classes, Vcl.Controls, Vcl.Graphics,
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages, Vcl.Controls, Vcl.Graphics,{$ENDIF} System.Classes,
|
||||
{$ELSE}
|
||||
Windows, Messages, Classes, Controls, Graphics,
|
||||
{$ENDIF}
|
||||
|
@ -48,7 +48,7 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows, WinApi.Messages, System.Classes, Vcl.Controls, Vcl.Graphics, Vcl.Forms,
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages, Vcl.Controls, Vcl.Graphics, Vcl.Forms,{$ENDIF} System.Classes,
|
||||
{$ELSE}
|
||||
Windows, Messages, Classes, Controls, Graphics, Forms,
|
||||
{$ENDIF}
|
||||
|
@ -48,7 +48,7 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows,
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF}
|
||||
{$ELSE}
|
||||
Windows,
|
||||
{$ENDIF}
|
||||
|
@ -75,7 +75,7 @@ implementation
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows, System.SysUtils,
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.SysUtils,
|
||||
{$ELSE}
|
||||
Windows, SysUtils,
|
||||
{$ENDIF}
|
||||
|
@ -48,7 +48,7 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows, System.Classes, System.SysUtils,
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Classes, System.SysUtils,
|
||||
{$ELSE}
|
||||
Windows, Classes, SysUtils,
|
||||
{$ENDIF}
|
||||
|
@ -48,13 +48,10 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
System.Rtti, System.TypInfo, System.Variants, System.SysUtils,
|
||||
System.Classes, System.Math, System.SyncObjs, WinApi.Windows,
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Rtti, System.TypInfo, System.Variants,
|
||||
System.SysUtils, System.Classes, System.Math, System.SyncObjs,
|
||||
{$ELSE}
|
||||
{$IFDEF DELPHI14_UP}
|
||||
Rtti,
|
||||
{$ENDIF}
|
||||
TypInfo, Variants, SysUtils, Classes, Math, SyncObjs, Windows,
|
||||
{$IFDEF DELPHI14_UP}Rtti,{$ENDIF} TypInfo, Variants, SysUtils, Classes, Math, SyncObjs, Windows,
|
||||
{$ENDIF}
|
||||
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
||||
|
||||
|
@ -104,10 +104,7 @@ type
|
||||
implementation
|
||||
|
||||
uses
|
||||
{$IFDEF MSWINDOWS}
|
||||
WinApi.Windows,
|
||||
{$ENDIF}
|
||||
System.SysUtils, System.Math,
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.SysUtils, System.Math,
|
||||
FMX.Platform, FMX.Platform.Win, FMX.Forms,
|
||||
uCEFMiscFunctions, uCEFApplication;
|
||||
|
||||
|
@ -43,7 +43,7 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows, System.Classes, System.Math, WinApi.ShlObj, WinApi.ActiveX;
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows, WinApi.ShlObj, WinApi.ActiveX,{$ENDIF} System.Classes, System.Math;
|
||||
{$ELSE}
|
||||
Windows, Classes, Math, ShlObj, ActiveX;
|
||||
{$ENDIF}
|
||||
|
Loading…
Reference in New Issue
Block a user