| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- unit BaseChromeView;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, cefvcl, BaseWebApp, ceflib, RealICQSkinFrm, InterfaceUI, ViewManager,
- superobject;
- type
- TBaseChromeViewForm = class(TRealICQSkinForm, IUIForm)
- Chrome: TChromium;
- procedure ChromeKeyEvent(Sender: TObject; const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: PMsg; out Result: Boolean);
- procedure ChromeBeforeContextMenu(Sender: TObject;
- const browser: ICefBrowser; const frame: ICefFrame;
- const params: ICefContextMenuParams; const model: ICefMenuModel);
- private
- FURL: string;
- FAutoFree: Boolean;
- { Private declarations }
- protected
- procedure WMWindowPosChanging(var Message: TWMWindowPosChanging); message WM_WINDOWPOSCHANGING;
- procedure DoShow; override;
- procedure DoClose(var Action: TCloseAction); override;
- public
- function GetIdentify: Cardinal;
- procedure SetFormInfo(AJson: WideString);
- function GetAutoFree: Boolean;
- procedure SetAutoFree(const Value: Boolean);
- { Public declarations }
- property URL: string read FURL write FURL;
- property AutoFree: Boolean read GetAutoFree write SetAutoFree;
- end;
- var
- BaseChromeViewForm: TBaseChromeViewForm;
- implementation
- uses
- DevToolChromeFrm, ConditionConfig;
- {$R *.dfm}
- { TBaseChromeViewForm }
- procedure TBaseChromeViewForm.ChromeBeforeContextMenu(Sender: TObject;
- const browser: ICefBrowser; const frame: ICefFrame;
- const params: ICefContextMenuParams; const model: ICefMenuModel);
- begin
- model.Clear;
- model.AddItem(Integer(MENU_ID_COPY), '¸´ÖÆ');
- end;
- procedure TBaseChromeViewForm.ChromeKeyEvent(Sender: TObject; const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: PMsg; out Result: Boolean);
- begin
- if TConditionConfig.GetConfig.Dev and (event^.windows_key_code = VK_F12) then
- ShowDevTool(Self, Chrome);
- end;
- procedure TBaseChromeViewForm.DoClose(var Action: TCloseAction);
- begin
- inherited;
- if FAutoFree then
- Action := caFree;
- end;
- procedure TBaseChromeViewForm.DoShow;
- begin
- inherited;
- ChangeUIColor($EADEBA);
- Chrome.Load(URL);
- end;
- function TBaseChromeViewForm.GetAutoFree: Boolean;
- begin
- Result := FAutoFree;
- end;
- function TBaseChromeViewForm.GetIdentify: Cardinal;
- begin
- Result := Handle;
- end;
- procedure TBaseChromeViewForm.SetAutoFree(const Value: Boolean);
- begin
- FAutoFree := Value;
- end;
- procedure TBaseChromeViewForm.SetFormInfo(AJson: WideString);
- var
- AJo: ISuperObject;
- begin
- AJo := SO(AJson);
- if AJo <> nil then
- begin
- if AJo.S['url'] <> '' then
- URL := AJo.S['url'];
- if AJo.S['caption'] <> '' then
- Caption := AJo.S['caption'];
- if AJo.I['width'] > 0 then
- Width := AJo.I['width'];
- if AJo.I['height'] > 0 then
- Height := AJo.I['height'];
- if AJo.B['center'] then
- begin
- // Position := poDesktopCenter;
- Top := (Screen.Height - Height) div 2;
- Left := (Screen.Width - Width) div 2;
- end;
- if AJo.B['unsizeable'] then
- begin
- CanResizeWindow := False;
- end;
- end;
- end;
- procedure TBaseChromeViewForm.WMWindowPosChanging(var Message: TWMWindowPosChanging);
- begin
- if Chrome.Browser <> nil then
- Chrome.Browser.Host.NotifyMoveOrResizeStarted;
- inherited;
- end;
- end.
|