반응형
Delphi XE2를 사용하는 MacOS에서 Webview가 표시되지 않음
Delphi에서 사용할 Webview 인터페이스를 변환하기 시작했습니다. 웹킷 라이브러리를로드 할 수 있었고 호출 된 인터페이스 메서드가 올바르게 작동하는 것처럼 보이지만 기본 양식에 Webview를 표시 할 수없는 것 같습니다.
아래는 선언 된 내 인터페이스입니다.
WebFrameClass = interface(NSObjectClass)
['{7BE750C8-DFEC-4870-851A-12DBCB0B78F6}']
end;
WebFrame = interface(NSObject)
['{BCFA04BE-41AB-4B78-89C0-3330F12C7695}']
procedure loadRequest(request: NSURLRequest); cdecl;
end;
TWebFrame = class(TOCGenericImport<WebFrameClass, WebFrame>) end;
WebViewClass = interface(NSViewClass)
['{0D9F44B7-09FD-4E35-B96E-8DB71B9A2537}']
{class} function canShowMIMEType(MIMEType: NSString): Boolean; cdecl;
end;
WebView = interface(NSView)
['{C36D8016-2FCB-49F0-BA1C-C9913A37F9AC}']
procedure clos; cdecl;
procedure setHostWindow(hostWindow: NSWindow); cdecl;
function initWithFrame(frame: NSRect; frameName: NSString; groupName: NSString): Pointer; cdecl;
function mainFrame: WebFrame; cdecl;
end;
TWebView = class(TOCGenericImport<WebViewClass, WebView>) end;
그리고 다음은 WebView를 구성하는 코드입니다.
procedure TForm2.Button1Click(Sender: TObject);
var
PWebView: Pointer;
FwkMod: HMODULE;
MyWebView: WebView;
urlStr: NSURL;
urlreq: NSURLRequest;
const
WebKitFWK: string = '/System/Library/Frameworks/WebKit.framework/WebKit';
begin
FwkMod := System.SysUtils.LoadLibrary(PWideChar(WebKitFWK));
PWebView := TWebView.Alloc.initWithFrame(MakeNSRect(10, 10, 300, 300), nil, nil);
MyWebView := TWebView.Wrap(PWebView);
urlStr := TNSURL.Create;
urlstr.initWithString(NSSTR('http://google.com.au/'));
urlreq := TNSURLRequest.Create;
urlreq.initWithURL(urlstr);
MyWebView.mainFrame.loadRequest(urlreq);
end;
코드는 예외를 발생시키지 않고 실행되지만 표시되기를 원하지 않습니다. Delphi에서 다르게 수행해야하는 것은 무엇입니까? 목표 C에 대해 찾은 예는 매우 간단합니다.
내가 본 몇 가지 객관적인 C 예제는 IBOutlets를 언급합니다. 이것이 Delphi와 관련이없는 것 같습니다.
WebView OSX Xcode 프로젝트가 시작시 URL을로드하도록하는 방법은 무엇입니까?
감사.
Getting the NSWindow of a FMX form
TForm 참조를 NSWindow
set Host Window 로 변환 합니다.
MyWebView.setHostWindow(MyNSWindow)
procedure TForm2.Button1Click(Sender: TObject);
var
[...]
ObjTOC: TOCLocal;
MyNSWindow : NSWindow;
[...]
ObjTOC := (FmxHandleToObjC(Form2.Handle) as TOCLocal);
MyNSWindow := NSWindow(TOCLocalAccess(ObjTOC).Super);
PWebView := TWebView.Alloc.initWithFrame(MakeNSRect(10, 10, 300, 300), nil, nil);
MyWebView := TWebView.Wrap(PWebView);
MyWebView.setHostWindow(MyNSWindow);
[...]
MyWebView.mainFrame.loadRequest(urlreq);
end;
Have you considered Chromium Embedded port for Delphi?
참고URL : https://stackoverflow.com/questions/9731817/webview-not-displaying-in-macos-using-delphi-xe2
반응형
'IT박스' 카테고리의 다른 글
MySQL의 날짜 간의 월 차이 (0) | 2020.10.25 |
---|---|
Bash의 숨겨진 기능 (0) | 2020.10.25 |
예외가 발생하면 Akka Actor가 종료되지 않음 (0) | 2020.10.25 |
PHP의 비동기 함수 호출 (0) | 2020.10.25 |
HTTP OPTIONS 요청에 응답하는 방법은 무엇입니까? (0) | 2020.10.25 |