如何在x3中编写处理代码?
~~~~~~~~~~~~~~~~~~
我使用的webbrowser是在pagecontrol中动态创建的,如果点击网页中的关闭本页按钮,就会提示"could not obtain OLE control window handle",不知道怎么解决?
--------------------------------------------------------------------------------
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
if (Msg.message = WM_CLOSE) then
begin
if msg.hwnd=webbrowser1.Handle then//如果是关闭Webbrowser
begin
PeekMessage(Msg, Msg.Hwnd, 0, 0, PM_REMOVE);
Handled := True; //该消息已处理,不再需要后续处理
end;
end
end;
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
var classname:array[0..254]of char;
begin
if (Msg.message = WM_CLOSE) then
begin
getclassname(msg.hwnd,@classname,sizeof(classname));//取类名
if classname='Shell Embedding' then
begin
PeekMessage(Msg, Msg.Hwnd, 0, 0, PM_REMOVE);
Handled := True; //该消息已处理,不再需要后续处理
end;
end
end;