登录 用户中心() [退出] 后台管理 注册
   
您的位置: 首页 >> 开发 vlog >> 主题: 原来 lazarus 下的 Handle 实现是 NSView 的指针     [回主站]     [分站链接]
标题
原来 lazarus 下的 Handle 实现是 NSView 的指针
clq
浏览(6) + 2025-10-10 16:18:56 发表 编辑

关键字:


原来 lazarus 下的 Handle 实现是 NSView 的指针

之前一直在找,无意中发现了...

--------------------------------------------------------

//用新的浏览器控件 WKWebView
procedure TFormWebView.CreateWeb2();
var
WebFrame: NSRect;
//Prefs: WebPreferences;
WebConfig: WKWebViewConfiguration;
begin
// 设置窗体大小
Width := 800;
Height := 600;

//----
// 创建配置
//WebConfig := WKWebViewConfiguration.alloc.init;

// 启用 JavaScript
//WebConfig.preferences.setJavaScriptEnabled(True);
//WebConfig.preferences.setJavaScriptCanOpenWindowsAutomatically(True);

//----

// 创建 WebView
WebFrame := NSMakeRect(0, 0, Width, Height);
//
//WebView3 := WKWebView.alloc.initWithFrame(WebFrame); //不带配置的
WebView3 := WKWebView.alloc.initWithFrame_configuration(WebFrame, CreateWebViewConfig); //带配置的 ,也成功了。不过不用似乎也可以,或者说是配置会保存?

WebView3.setAutoresizingMask(NSViewWidthSizable or NSViewHeightSizable);
NSView(Handle).addSubview(WebView3);
WebView3.setAutoresizingMask(NSViewWidthSizable or NSViewHeightSizable);

//--
//WebView3.allowsBackForwardNavigationGestures := ObjCBOOL(true);
WebView3.setAllowsBackForwardNavigationGestures(true); //这个只是手势前进后退是否允许

//--

//WebView3.loadRequest(NSURLRequest.requestWithURL(NSURL.URLWithString(NSStr(PChar('https://www.baidu.com/')))));
////WebView3.loadRequest(NSURLRequest.requestWithURL(NSURL.URLWithString(NSStr(PChar('https://mail.163.com/')))));

//self.LoadURL2('http://newbt.net');
//self.LoadURL2('https://www.baidu.com');
self.LoadURL2('https://mail.163.com');

end;



总数:0 页次:1/0 首页 尾页  
总数:0 页次:1/0 首页 尾页  


所在合集/目录



发表评论:
文本/html模式切换 插入图片 文本/html模式切换


附件:



NEWBT官方QQ群1: 276678893
可求档连环画,漫画;询问文本处理大师等软件使用技巧;求档softhub软件下载及使用技巧.
但不可"开车",严禁国家敏感话题,不可求档涉及版权的文档软件.
验证问题说明申请入群原因即可.

Copyright © 2005-2020 clq, All Rights Reserved
版权所有
桂ICP备15002303号-1