You've already forked CEF4Delphi
mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-06-22 22:17:48 +02:00
- add Open Jpeg functionality
This commit is contained in:
@ -94,20 +94,20 @@
|
|||||||
border: 2px solid #aaa;
|
border: 2px solid #aaa;
|
||||||
color: #aaa;
|
color: #aaa;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
width:100px;
|
width: 100px;
|
||||||
margin:20px;
|
margin: 20px;
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#openJpegButton:hover {
|
#openJpegButton:hover {
|
||||||
border: 2px solid #fff;
|
border: 2px solid #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
#canvas {
|
#canvas {
|
||||||
width: 720px;
|
width: 720px;
|
||||||
height: 405px;
|
height: 405px;
|
||||||
background: black;
|
background: black;
|
||||||
margin:20px;
|
margin: 20px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
@ -127,10 +127,25 @@
|
|||||||
<canvas id="canvas"></canvas>
|
<canvas id="canvas"></canvas>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
let img = new Image();
|
||||||
|
let canvas = document.getElementById("canvas");
|
||||||
|
canvas.width = 720;
|
||||||
|
canvas.height = 405;
|
||||||
|
let ctx = canvas.getContext('2d');
|
||||||
|
|
||||||
|
img.onload = () => {
|
||||||
|
ctx.drawImage(img, 0, 0, 720, 405);
|
||||||
|
}
|
||||||
|
|
||||||
function setAppCaption(caption) {
|
function setAppCaption(caption) {
|
||||||
document.getElementById("title").innerHTML = caption;
|
document.getElementById("title").innerHTML = caption;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.getElementById('openJpegButton').addEventListener('mousedown', (e) => {
|
||||||
|
if (e.button == 0) myextension.openjpeg();
|
||||||
|
})
|
||||||
|
|
||||||
document.getElementById('winMin').addEventListener('mousedown', (e) => {
|
document.getElementById('winMin').addEventListener('mousedown', (e) => {
|
||||||
if (e.button == 0) myextension.minimize();
|
if (e.button == 0) myextension.minimize();
|
||||||
})
|
})
|
||||||
|
@ -230,6 +230,16 @@
|
|||||||
<Operation>1</Operation>
|
<Operation>1</Operation>
|
||||||
</Platform>
|
</Platform>
|
||||||
</DeployClass>
|
</DeployClass>
|
||||||
|
<DeployClass Name="UWP_DelphiLogo150">
|
||||||
|
<Platform Name="Win64">
|
||||||
|
<RemoteDir>Assets</RemoteDir>
|
||||||
|
<Operation>1</Operation>
|
||||||
|
</Platform>
|
||||||
|
<Platform Name="Win32">
|
||||||
|
<RemoteDir>Assets</RemoteDir>
|
||||||
|
<Operation>1</Operation>
|
||||||
|
</Platform>
|
||||||
|
</DeployClass>
|
||||||
<DeployClass Name="Android_LauncherIcon96">
|
<DeployClass Name="Android_LauncherIcon96">
|
||||||
<Platform Name="Android">
|
<Platform Name="Android">
|
||||||
<RemoteDir>res\drawable-xhdpi</RemoteDir>
|
<RemoteDir>res\drawable-xhdpi</RemoteDir>
|
||||||
@ -260,16 +270,6 @@
|
|||||||
<Operation>1</Operation>
|
<Operation>1</Operation>
|
||||||
</Platform>
|
</Platform>
|
||||||
</DeployClass>
|
</DeployClass>
|
||||||
<DeployClass Name="UWP_DelphiLogo150">
|
|
||||||
<Platform Name="Win64">
|
|
||||||
<RemoteDir>Assets</RemoteDir>
|
|
||||||
<Operation>1</Operation>
|
|
||||||
</Platform>
|
|
||||||
<Platform Name="Win32">
|
|
||||||
<RemoteDir>Assets</RemoteDir>
|
|
||||||
<Operation>1</Operation>
|
|
||||||
</Platform>
|
|
||||||
</DeployClass>
|
|
||||||
<DeployClass Name="DebugSymbols">
|
<DeployClass Name="DebugSymbols">
|
||||||
<Platform Name="OSX32">
|
<Platform Name="OSX32">
|
||||||
<RemoteDir>Contents\MacOS</RemoteDir>
|
<RemoteDir>Contents\MacOS</RemoteDir>
|
||||||
@ -328,13 +328,13 @@
|
|||||||
</Platform>
|
</Platform>
|
||||||
</DeployClass>
|
</DeployClass>
|
||||||
<DeployClass Name="ProjectiOSInfoPList">
|
<DeployClass Name="ProjectiOSInfoPList">
|
||||||
<Platform Name="iOSDevice32">
|
<Platform Name="iOSDevice64">
|
||||||
<Operation>1</Operation>
|
<Operation>1</Operation>
|
||||||
</Platform>
|
</Platform>
|
||||||
<Platform Name="iOSSimulator">
|
<Platform Name="iOSSimulator">
|
||||||
<Operation>1</Operation>
|
<Operation>1</Operation>
|
||||||
</Platform>
|
</Platform>
|
||||||
<Platform Name="iOSDevice64">
|
<Platform Name="iOSDevice32">
|
||||||
<Operation>1</Operation>
|
<Operation>1</Operation>
|
||||||
</Platform>
|
</Platform>
|
||||||
</DeployClass>
|
</DeployClass>
|
||||||
@ -567,7 +567,7 @@
|
|||||||
<Operation>1</Operation>
|
<Operation>1</Operation>
|
||||||
</Platform>
|
</Platform>
|
||||||
</DeployClass>
|
</DeployClass>
|
||||||
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
|
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
|
||||||
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
|
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
|
||||||
<ProjectRoot Platform="iOSDevice" Name="$(PROJECTNAME).app"/>
|
<ProjectRoot Platform="iOSDevice" Name="$(PROJECTNAME).app"/>
|
||||||
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
|
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
|
||||||
@ -576,7 +576,7 @@
|
|||||||
<ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
|
<ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
|
||||||
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
|
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
|
||||||
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
|
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
|
||||||
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
|
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
|
||||||
</Deployment>
|
</Deployment>
|
||||||
<Platforms>
|
<Platforms>
|
||||||
<Platform value="Win32">True</Platform>
|
<Platform value="Win32">True</Platform>
|
||||||
|
@ -2,7 +2,7 @@ object CTBForm: TCTBForm
|
|||||||
Left = 0
|
Left = 0
|
||||||
Top = 0
|
Top = 0
|
||||||
BorderStyle = bsNone
|
BorderStyle = bsNone
|
||||||
Caption = 'CTBForm'
|
Caption = 'CEF4 Custom Title Bar'
|
||||||
ClientHeight = 628
|
ClientHeight = 628
|
||||||
ClientWidth = 994
|
ClientWidth = 994
|
||||||
Color = clBtnFace
|
Color = clBtnFace
|
||||||
@ -18,25 +18,13 @@ object CTBForm: TCTBForm
|
|||||||
OnShow = FormShow
|
OnShow = FormShow
|
||||||
PixelsPerInch = 96
|
PixelsPerInch = 96
|
||||||
TextHeight = 13
|
TextHeight = 13
|
||||||
object StatusBar1: TStatusBar
|
|
||||||
Left = 0
|
|
||||||
Top = 609
|
|
||||||
Width = 994
|
|
||||||
Height = 19
|
|
||||||
Panels = <
|
|
||||||
item
|
|
||||||
Width = 1000
|
|
||||||
end>
|
|
||||||
ExplicitTop = 570
|
|
||||||
ExplicitWidth = 978
|
|
||||||
end
|
|
||||||
object CEFWindowParent1: TCEFWindowParent
|
object CEFWindowParent1: TCEFWindowParent
|
||||||
Left = 0
|
Left = 0
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 994
|
Width = 994
|
||||||
Height = 609
|
Height = 628
|
||||||
Align = alClient
|
Align = alClient
|
||||||
TabOrder = 1
|
TabOrder = 0
|
||||||
ExplicitTop = 30
|
ExplicitTop = 30
|
||||||
ExplicitWidth = 978
|
ExplicitWidth = 978
|
||||||
ExplicitHeight = 540
|
ExplicitHeight = 540
|
||||||
@ -66,6 +54,7 @@ object CTBForm: TCTBForm
|
|||||||
Top = 352
|
Top = 352
|
||||||
end
|
end
|
||||||
object Timer2: TTimer
|
object Timer2: TTimer
|
||||||
|
Enabled = False
|
||||||
Interval = 1
|
Interval = 1
|
||||||
OnTimer = Timer2Timer
|
OnTimer = Timer2Timer
|
||||||
Left = 624
|
Left = 624
|
||||||
|
@ -57,18 +57,21 @@ uses
|
|||||||
|
|
||||||
const
|
const
|
||||||
MINIBROWSER_SHOWTEXTVIEWER = WM_APP + $100;
|
MINIBROWSER_SHOWTEXTVIEWER = WM_APP + $100;
|
||||||
|
MINIBROWSER_JSBINPARAM = WM_APP + $103;
|
||||||
|
|
||||||
MINIBROWSER_CONTEXTMENU_SETJSEVENT = MENU_ID_USER_FIRST + 1;
|
MINIBROWSER_CONTEXTMENU_SETJSEVENT = MENU_ID_USER_FIRST + 1;
|
||||||
MINIBROWSER_CONTEXTMENU_JSVISITDOM = MENU_ID_USER_FIRST + 2;
|
MINIBROWSER_CONTEXTMENU_JSVISITDOM = MENU_ID_USER_FIRST + 2;
|
||||||
MINIBROWSER_CONTEXTMENU_MUTATIONOBSERVER = MENU_ID_USER_FIRST + 3;
|
MINIBROWSER_CONTEXTMENU_MUTATIONOBSERVER = MENU_ID_USER_FIRST + 3;
|
||||||
MINIBROWSER_CONTEXTMENU_SHOWDEVTOOLS = MENU_ID_USER_FIRST + 4;
|
MINIBROWSER_CONTEXTMENU_SHOWDEVTOOLS = MENU_ID_USER_FIRST + 4;
|
||||||
|
|
||||||
MOUSEOVER_MESSAGE_NAME = 'mouseover';
|
MOUSEOVER_MESSAGE_NAME = 'mousestate';
|
||||||
CUSTOMNAME_MESSAGE_NAME = 'customname';
|
WINDOW_MINIMIZE_MESSAGE = 'minimize';
|
||||||
|
WINDOW_MAXIMIZE_MESSAGE = 'maximize';
|
||||||
|
WINDOW_CLOSE_MESSAGE = 'close';
|
||||||
|
BINARY_PARAM_JS = 'JSBinaryParameter';
|
||||||
|
|
||||||
type
|
type
|
||||||
TCTBForm = class(TForm)
|
TCTBForm = class(TForm)
|
||||||
StatusBar1: TStatusBar;
|
|
||||||
CEFWindowParent1: TCEFWindowParent;
|
CEFWindowParent1: TCEFWindowParent;
|
||||||
Chromium1: TChromium;
|
Chromium1: TChromium;
|
||||||
Timer1: TTimer;
|
Timer1: TTimer;
|
||||||
@ -124,6 +127,8 @@ type
|
|||||||
procedure BrowserDestroyMsg(var aMessage: TMessage); message CEF_DESTROY;
|
procedure BrowserDestroyMsg(var aMessage: TMessage); message CEF_DESTROY;
|
||||||
procedure ShowTextViewerMsg(var aMessage: TMessage);
|
procedure ShowTextViewerMsg(var aMessage: TMessage);
|
||||||
message MINIBROWSER_SHOWTEXTVIEWER;
|
message MINIBROWSER_SHOWTEXTVIEWER;
|
||||||
|
procedure EvalJSBinParamMsg(var aMessage: TMessage);
|
||||||
|
message MINIBROWSER_JSBINPARAM;
|
||||||
procedure WMMove(var aMessage: TWMMove); message WM_MOVE;
|
procedure WMMove(var aMessage: TWMMove); message WM_MOVE;
|
||||||
procedure WMMoving(var aMessage: TMessage); message WM_MOVING;
|
procedure WMMoving(var aMessage: TMessage); message WM_MOVING;
|
||||||
public
|
public
|
||||||
@ -140,7 +145,8 @@ implementation
|
|||||||
{$R *.dfm}
|
{$R *.dfm}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
uCEFv8Handler, uTestExtension, uCEFMiscFunctions;
|
uCefBinaryValue, uCefProcessMessage, uCEFv8Handler, uTestExtension,
|
||||||
|
uCEFMiscFunctions;
|
||||||
|
|
||||||
|
|
||||||
// Please, read the code comments in the JSExtension demo (uJSExtension.pas) before using this demo!
|
// Please, read the code comments in the JSExtension demo (uJSExtension.pas) before using this demo!
|
||||||
@ -210,7 +216,7 @@ procedure TCTBForm.Chromium1AfterCreated(Sender: TObject;
|
|||||||
const browser: ICefBrowser);
|
const browser: ICefBrowser);
|
||||||
begin
|
begin
|
||||||
PostMessage(Handle, CEF_AFTERCREATED, 0, 0);
|
PostMessage(Handle, CEF_AFTERCREATED, 0, 0);
|
||||||
CTBForm.executeJS(Chromium1.Browser.MainFrame);
|
CTBForm.executeJS(Chromium1.browser.MainFrame);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCTBForm.Chromium1BeforeContextMenu(Sender: TObject;
|
procedure TCTBForm.Chromium1BeforeContextMenu(Sender: TObject;
|
||||||
@ -245,11 +251,10 @@ begin
|
|||||||
if (frame <> nil) and frame.IsValid then
|
if (frame <> nil) and frame.IsValid then
|
||||||
begin
|
begin
|
||||||
TempJSCode := 'document.body.addEventListener("mousedown", function(evt){' +
|
TempJSCode := 'document.body.addEventListener("mousedown", function(evt){' +
|
||||||
'myextension.mousestate(getComputedStyle(evt.target).webkitAppRegion)'
|
'myextension.mousestate(getComputedStyle(evt.target).webkitAppRegion)' +
|
||||||
+ '});'+chr(13);
|
'});' + chr(13);
|
||||||
|
|
||||||
TempJSCode := TempJSCode +
|
TempJSCode := TempJSCode + ' setAppCaption("' + CTBForm.caption + '");';
|
||||||
' setAppCaption("'+CTBForm.caption +'");' ;
|
|
||||||
|
|
||||||
frame.ExecuteJavaScript(TempJSCode, 'about:blank', 0);
|
frame.ExecuteJavaScript(TempJSCode, 'about:blank', 0);
|
||||||
end;
|
end;
|
||||||
@ -283,10 +288,63 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCTBForm.EvalJSBinParamMsg(var aMessage: TMessage);
|
||||||
|
var
|
||||||
|
TempMsg: ICefProcessMessage;
|
||||||
|
TempOpenDialog: TOpenDialog;
|
||||||
|
TempStream: TFileStream;
|
||||||
|
TempBinValue: ICefBinaryValue;
|
||||||
|
TempBuffer: TBytes;
|
||||||
|
TempSize: NativeUInt;
|
||||||
|
TempPointer: pointer;
|
||||||
|
begin
|
||||||
|
TempOpenDialog := nil;
|
||||||
|
TempStream := nil;
|
||||||
|
|
||||||
|
try
|
||||||
|
try
|
||||||
|
TempOpenDialog := TOpenDialog.Create(nil);
|
||||||
|
TempOpenDialog.Filter := 'JPEG files (*.jpg)|*.JPG';
|
||||||
|
|
||||||
|
if TempOpenDialog.Execute then
|
||||||
|
begin
|
||||||
|
TempStream := TFileStream.Create(TempOpenDialog.FileName, fmOpenRead);
|
||||||
|
TempSize := TempStream.Size;
|
||||||
|
|
||||||
|
if (TempSize > 0) then
|
||||||
|
begin
|
||||||
|
SetLength(TempBuffer, TempSize);
|
||||||
|
TempSize := TempStream.Read(TempBuffer, TempSize);
|
||||||
|
|
||||||
|
if (TempSize > 0) then
|
||||||
|
begin
|
||||||
|
TempPointer := @TempBuffer[0];
|
||||||
|
TempBinValue := TCefBinaryValueRef.New(TempPointer, TempSize);
|
||||||
|
TempMsg := TCefProcessMessageRef.New(BINARY_PARAM_JS);
|
||||||
|
|
||||||
|
if TempMsg.ArgumentList.SetBinary(0, TempBinValue) then
|
||||||
|
Chromium1.SendProcessMessage(PID_RENDERER, TempMsg);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
except
|
||||||
|
on e: exception do
|
||||||
|
if CustomExceptionHandler('TCTBForm.EvalJSBinParamMsg', e) then
|
||||||
|
raise;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
if (TempOpenDialog <> nil) then
|
||||||
|
FreeAndNil(TempOpenDialog);
|
||||||
|
if (TempStream <> nil) then
|
||||||
|
FreeAndNil(TempStream);
|
||||||
|
SetLength(TempBuffer, 0);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCTBForm.Chromium1LoadEnd(Sender: TObject; const browser: ICefBrowser;
|
procedure TCTBForm.Chromium1LoadEnd(Sender: TObject; const browser: ICefBrowser;
|
||||||
const frame: ICefFrame; httpStatusCode: Integer);
|
const frame: ICefFrame; httpStatusCode: Integer);
|
||||||
begin
|
begin
|
||||||
CTBForm.executeJS(Chromium1.Browser.MainFrame);
|
CTBForm.executeJS(Chromium1.browser.MainFrame);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCTBForm.Chromium1ProcessMessageReceived(Sender: TObject;
|
procedure TCTBForm.Chromium1ProcessMessageReceived(Sender: TObject;
|
||||||
@ -310,7 +368,6 @@ begin
|
|||||||
|
|
||||||
if (message.Name = MOUSEOVER_MESSAGE_NAME) then
|
if (message.Name = MOUSEOVER_MESSAGE_NAME) then
|
||||||
begin
|
begin
|
||||||
StatusBar1.Panels[0].Text := message.ArgumentList.GetString(0);
|
|
||||||
|
|
||||||
tp := Mouse.CursorPos;
|
tp := Mouse.CursorPos;
|
||||||
tp := CTBForm.ScreenToClient(tp);
|
tp := CTBForm.ScreenToClient(tp);
|
||||||
@ -318,16 +375,36 @@ begin
|
|||||||
if message.ArgumentList.GetString(0) = 'drag' then
|
if message.ArgumentList.GetString(0) = 'drag' then
|
||||||
begin
|
begin
|
||||||
mouseDrag := True;
|
mouseDrag := True;
|
||||||
|
Timer2.Enabled := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Result := True;
|
Result := True;
|
||||||
end
|
end;
|
||||||
|
|
||||||
|
if (message.Name = WINDOW_MINIMIZE_MESSAGE) then
|
||||||
|
begin
|
||||||
|
CTBForm.WindowState := wsMinimized;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if (message.Name = WINDOW_MAXIMIZE_MESSAGE) then
|
||||||
|
begin
|
||||||
|
if CTBForm.WindowState = wsNormal then
|
||||||
|
begin
|
||||||
|
CTBForm.WindowState := wsMaximized;
|
||||||
|
end
|
||||||
|
else if CTBForm.WindowState = wsMaximized then
|
||||||
|
CTBForm.WindowState := wsNormal;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if (message.Name = WINDOW_CLOSE_MESSAGE) then
|
||||||
|
begin
|
||||||
|
CTBForm.close;
|
||||||
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCTBForm.FormShow(Sender: TObject);
|
procedure TCTBForm.FormShow(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
StatusBar1.Panels[0].Text := 'Initializing browser. Please wait...';
|
|
||||||
|
|
||||||
Chromium1.DefaultURL := 'file:///app_view.html';
|
Chromium1.DefaultURL := 'file:///app_view.html';
|
||||||
|
|
||||||
@ -356,9 +433,7 @@ end;
|
|||||||
|
|
||||||
procedure TCTBForm.ShowTextViewerMsg(var aMessage: TMessage);
|
procedure TCTBForm.ShowTextViewerMsg(var aMessage: TMessage);
|
||||||
begin
|
begin
|
||||||
// This form will show the HTML received from JavaScript
|
|
||||||
// SimpleTextViewerFrm.Memo1.Lines.Text := FText;
|
|
||||||
// SimpleTextViewerFrm.ShowModal;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCTBForm.Timer1Timer(Sender: TObject);
|
procedure TCTBForm.Timer1Timer(Sender: TObject);
|
||||||
@ -366,14 +441,14 @@ begin
|
|||||||
Timer1.Enabled := False;
|
Timer1.Enabled := False;
|
||||||
if not(Chromium1.CreateBrowser(CEFWindowParent1, '')) and
|
if not(Chromium1.CreateBrowser(CEFWindowParent1, '')) and
|
||||||
not(Chromium1.Initialized) then
|
not(Chromium1.Initialized) then
|
||||||
begin
|
begin
|
||||||
Timer1.Enabled := True;
|
Timer1.Enabled := True;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCTBForm.BrowserCreatedMsg(var aMessage: TMessage);
|
procedure TCTBForm.BrowserCreatedMsg(var aMessage: TMessage);
|
||||||
begin
|
begin
|
||||||
StatusBar1.Panels[0].Text := '';
|
|
||||||
CEFWindowParent1.UpdateSize;
|
CEFWindowParent1.UpdateSize;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
@ -430,7 +505,10 @@ begin
|
|||||||
MouseLBtnDown := (GetKeyState(VK_LBUTTON) < 0);
|
MouseLBtnDown := (GetKeyState(VK_LBUTTON) < 0);
|
||||||
|
|
||||||
if not MouseLBtnDown then
|
if not MouseLBtnDown then
|
||||||
|
begin
|
||||||
mouseDrag := False;
|
mouseDrag := False;
|
||||||
|
Timer2.Enabled := False;
|
||||||
|
end;
|
||||||
|
|
||||||
if mouseDrag then
|
if mouseDrag then
|
||||||
begin
|
begin
|
||||||
@ -438,8 +516,6 @@ begin
|
|||||||
CTBForm.top := tpc.y - tp.y;
|
CTBForm.top := tpc.y - tp.y;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// StatusBar1.Panels[0].Text := IntToStr(tp.x) + ' ' + IntToStr(tp.y) + ' ' +
|
|
||||||
// BoolToStr(MouseLBtnDown) + ' ' + BoolToStr(mouseDrag);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -53,6 +53,9 @@ uses
|
|||||||
type
|
type
|
||||||
TTestExtension = class
|
TTestExtension = class
|
||||||
class procedure mousestate(const data: string);
|
class procedure mousestate(const data: string);
|
||||||
|
class procedure minimize();
|
||||||
|
class procedure maximize();
|
||||||
|
class procedure close();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -81,5 +84,68 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class procedure TTestExtension.minimize();
|
||||||
|
var
|
||||||
|
TempMessage : ICefProcessMessage;
|
||||||
|
TempFrame : ICefFrame;
|
||||||
|
begin
|
||||||
|
try
|
||||||
|
TempMessage := TCefProcessMessageRef.New(WINDOW_MINIMIZE_MESSAGE);
|
||||||
|
|
||||||
|
|
||||||
|
// Sending a message back to the browser. It'll be received in the TChromium.OnProcessMessageReceived event.
|
||||||
|
// TCefv8ContextRef.Current returns the v8 context for the frame that is currently executing Javascript.
|
||||||
|
|
||||||
|
TempFrame := TCefv8ContextRef.Current.Browser.MainFrame;
|
||||||
|
|
||||||
|
if (TempFrame <> nil) and TempFrame.IsValid then
|
||||||
|
TempFrame.SendProcessMessage(PID_BROWSER, TempMessage);
|
||||||
|
finally
|
||||||
|
TempMessage := nil;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TTestExtension.maximize();
|
||||||
|
var
|
||||||
|
TempMessage : ICefProcessMessage;
|
||||||
|
TempFrame : ICefFrame;
|
||||||
|
begin
|
||||||
|
try
|
||||||
|
TempMessage := TCefProcessMessageRef.New(WINDOW_MAXIMIZE_MESSAGE);
|
||||||
|
|
||||||
|
|
||||||
|
// Sending a message back to the browser. It'll be received in the TChromium.OnProcessMessageReceived event.
|
||||||
|
// TCefv8ContextRef.Current returns the v8 context for the frame that is currently executing Javascript.
|
||||||
|
|
||||||
|
TempFrame := TCefv8ContextRef.Current.Browser.MainFrame;
|
||||||
|
|
||||||
|
if (TempFrame <> nil) and TempFrame.IsValid then
|
||||||
|
TempFrame.SendProcessMessage(PID_BROWSER, TempMessage);
|
||||||
|
finally
|
||||||
|
TempMessage := nil;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TTestExtension.close();
|
||||||
|
var
|
||||||
|
TempMessage : ICefProcessMessage;
|
||||||
|
TempFrame : ICefFrame;
|
||||||
|
begin
|
||||||
|
try
|
||||||
|
TempMessage := TCefProcessMessageRef.New(WINDOW_CLOSE_MESSAGE);
|
||||||
|
|
||||||
|
|
||||||
|
// Sending a message back to the browser. It'll be received in the TChromium.OnProcessMessageReceived event.
|
||||||
|
// TCefv8ContextRef.Current returns the v8 context for the frame that is currently executing Javascript.
|
||||||
|
|
||||||
|
TempFrame := TCefv8ContextRef.Current.Browser.MainFrame;
|
||||||
|
|
||||||
|
if (TempFrame <> nil) and TempFrame.IsValid then
|
||||||
|
TempFrame.SendProcessMessage(PID_BROWSER, TempMessage);
|
||||||
|
finally
|
||||||
|
TempMessage := nil;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Reference in New Issue
Block a user