C
cgfhz
Unregistered / Unconfirmed
GUEST, unregistred user!
在简单的页面中触发多个on_change事件没有问题,如果on_change需要取数据库信息的时候,只能触发第一个on_change事件,后面都无效!
请高手指教,还有网上有用fireEvent处理事件的,不知道可行否?
代码如下:
procedure ExtractLinks(WebBrowser: IWebBrowser2);
var
vFrame, ret: OleVariant;
ilFrameIndex, ilFramesCount: integer;
pDoc, HTMLDocument: IHTMLDocument2;
pWindow: IHTMLWindow2;
pFrames: IHTMLFramesCollection2;
spdisp:idispatch;
HtmlInputEle: IHTMLInputElement;
ev: IDispatch;
vi, vi2, vr: OleVariant;
dispparamsNoArgs: DISPPARAMS;
begin
if(SUCCEEDED(WebBrowser.Document.QueryInterface(
IID_IHTMLDocument2, HTMLDocument))) then
begin
pFrames:=(HTMLDocument.get_frames as IHTMLFramesCollection2);
ilFramesCount := pFrames.get_length;
TVariantArg(vFrame).vt := VT_UINT;
for ilFrameIndex := 1 to ilFramesCount - 1do
begin
TVariantArg(vFrame).lVal := ilFrameIndex;
spDisp := pFrames.item(vFrame);
if (SUCCEEDED(spDisp.QueryInterface(IID_IHTMLWindow2, pWindow))) then
begin
pDoc := pWindow.get_document;
if pDoc.title = '数据录入' then
begin
HtmlInputEle:=(pDoc.all.item('test1',0) as IHTMLInputElement);
if HtmlInputEle <> nil then
begin
HtmlInputEle.select;
HtmlInputEle.value :='111';
vi2 := HtmlInputEle.get_onchange;
ev := IDispatch(vi2);
dispparamsNoArgs.rgvarg := nil;
dispparamsNoArgs.rgdispidNamedArgs := nil;
dispparamsNoArgs.cArgs := 0;
dispparamsNoArgs.cNamedArgs := 0;
ev.Invoke(
DISPID_VALUE,
GUID_NULL,
LOCALE_USER_DEFAULT,
DISPATCH_METHOD,
dispparamsNoArgs,
@vr,
nil,
nil);
end;
HtmlInputEle:=(pDoc.all.item('test2',0) as IHTMLInputElement);
if HtmlInputEle <> nil then
begin
HtmlInputEle.select;
HtmlInputEle.value :='222';
vi2 := HtmlInputEle.get_onchange;
ev := IDispatch(vi2);
dispparamsNoArgs.rgvarg := nil;
dispparamsNoArgs.rgdispidNamedArgs := nil;
dispparamsNoArgs.cArgs := 0;
dispparamsNoArgs.cNamedArgs := 0;
ev.Invoke(
DISPID_VALUE,
GUID_NULL,
LOCALE_USER_DEFAULT,
DISPATCH_METHOD,
dispparamsNoArgs,
@vr,
nil,
nil);
end;
end;
end;
end;
end;
end;
请高手指教,还有网上有用fireEvent处理事件的,不知道可行否?
代码如下:
procedure ExtractLinks(WebBrowser: IWebBrowser2);
var
vFrame, ret: OleVariant;
ilFrameIndex, ilFramesCount: integer;
pDoc, HTMLDocument: IHTMLDocument2;
pWindow: IHTMLWindow2;
pFrames: IHTMLFramesCollection2;
spdisp:idispatch;
HtmlInputEle: IHTMLInputElement;
ev: IDispatch;
vi, vi2, vr: OleVariant;
dispparamsNoArgs: DISPPARAMS;
begin
if(SUCCEEDED(WebBrowser.Document.QueryInterface(
IID_IHTMLDocument2, HTMLDocument))) then
begin
pFrames:=(HTMLDocument.get_frames as IHTMLFramesCollection2);
ilFramesCount := pFrames.get_length;
TVariantArg(vFrame).vt := VT_UINT;
for ilFrameIndex := 1 to ilFramesCount - 1do
begin
TVariantArg(vFrame).lVal := ilFrameIndex;
spDisp := pFrames.item(vFrame);
if (SUCCEEDED(spDisp.QueryInterface(IID_IHTMLWindow2, pWindow))) then
begin
pDoc := pWindow.get_document;
if pDoc.title = '数据录入' then
begin
HtmlInputEle:=(pDoc.all.item('test1',0) as IHTMLInputElement);
if HtmlInputEle <> nil then
begin
HtmlInputEle.select;
HtmlInputEle.value :='111';
vi2 := HtmlInputEle.get_onchange;
ev := IDispatch(vi2);
dispparamsNoArgs.rgvarg := nil;
dispparamsNoArgs.rgdispidNamedArgs := nil;
dispparamsNoArgs.cArgs := 0;
dispparamsNoArgs.cNamedArgs := 0;
ev.Invoke(
DISPID_VALUE,
GUID_NULL,
LOCALE_USER_DEFAULT,
DISPATCH_METHOD,
dispparamsNoArgs,
@vr,
nil,
nil);
end;
HtmlInputEle:=(pDoc.all.item('test2',0) as IHTMLInputElement);
if HtmlInputEle <> nil then
begin
HtmlInputEle.select;
HtmlInputEle.value :='222';
vi2 := HtmlInputEle.get_onchange;
ev := IDispatch(vi2);
dispparamsNoArgs.rgvarg := nil;
dispparamsNoArgs.rgdispidNamedArgs := nil;
dispparamsNoArgs.cArgs := 0;
dispparamsNoArgs.cNamedArgs := 0;
ev.Invoke(
DISPID_VALUE,
GUID_NULL,
LOCALE_USER_DEFAULT,
DISPATCH_METHOD,
dispparamsNoArgs,
@vr,
nil,
nil);
end;
end;
end;
end;
end;
end;