procedure TfrmIssue.SendBiddingInf;
var
HtmlDoc : IHTMLDocument2;
HtmlForms : IHTMLFormElement;
i: Integer;
InputText: IHTMLInputTextElement;
TypeElement: variant;
strFlag : string;
IsSucc : boolean;
begin
{发送数据}
//当前网页页面文档对象(wbIssue是TWebBrower)
HtmlDoc := wbIssue.document as IHTMLDocument2; //
for i := 0 to HtmlDoc.all.length - 1 do
begin
TypeElement := HtmlDoc.all.item(i, varempty); //判断数据是否已经填写
if (Uppercase(TypeElement.tagName) = 'INPUT') and (Uppercase(TypeElement.type) = 'TEXT') then
begin
InputText := HtmlDoc.all.item(i, varempty) as IHTMLInputTextElement;
if (InputText.name = 'BulletinID') and (InputText.value = '') then
begin
//数据不完整,提示先填写完整再发送
MessageDlg(sNull,mtInformation,[mbOk],0);
Exit;
end;//end of if .. and .. (公告号) end;//end of Input(Text) end;//end of for //发送
HtmlForms := HtmlDoc.forms.item(0, varempty) as IHTMLFormElement;
HtmlForms.submit;
end;
var
HtmlDoc : IHTMLDocument2;
HtmlForms : IHTMLFormElement;
i: Integer;
InputText: IHTMLInputTextElement;
TypeElement: variant;
strFlag : string;
IsSucc : boolean;
begin
{发送数据}
//当前网页页面文档对象(wbIssue是TWebBrower)
HtmlDoc := wbIssue.document as IHTMLDocument2; //
for i := 0 to HtmlDoc.all.length - 1 do
begin
TypeElement := HtmlDoc.all.item(i, varempty); //判断数据是否已经填写
if (Uppercase(TypeElement.tagName) = 'INPUT') and (Uppercase(TypeElement.type) = 'TEXT') then
begin
InputText := HtmlDoc.all.item(i, varempty) as IHTMLInputTextElement;
if (InputText.name = 'BulletinID') and (InputText.value = '') then
begin
//数据不完整,提示先填写完整再发送
MessageDlg(sNull,mtInformation,[mbOk],0);
Exit;
end;//end of if .. and .. (公告号) end;//end of Input(Text) end;//end of for //发送
HtmlForms := HtmlDoc.forms.item(0, varempty) as IHTMLFormElement;
HtmlForms.submit;
end;
我是说一个Form中放一个TWebBrowser,在WebBrowser访问某个网页时,如果
网页中有个Memo控件,我在Memo中输入文本,然后我想让文本折行,按回车键
却没反应,只有用Alt+13才可以,有什么方法可以解决
我无法截获WebBrowser的按键消息!
首先:
uses ActiveX;//引用!!
----------------------------------------------------------------
TfrmChildWeb = class(TForm)
WebBrowser: TWebBrowser;//TwebBrowser!!!
procedure FormCreate(Sender: TObject);//必用的一个事件…
private
FOleInPlaceActiveObject: IOleInPlaceActiveObject;
procedure MsgHandler(var Msg: TMsg; var Handled: Boolean);//自定义的一个处理……
public
end;
----------------------------------------------------------------
过程:
procedure TfrmChildWeb.MsgHandler(var Msg: TMsg; var Handled: Boolean);
var
iOIPAO: IOleInPlaceActiveObject;
Dispatch: IDispatch;
begin
if WebBrowser = nil then begin
Handled := False;
Exit;
end;
Handled := (IsDialogMessage(WebBrowser.Handle, Msg) = True); if (Handled) and (not WebBrowser.Busy) then
begin
if FOleInPlaceActiveObject = nil then
begin
Dispatch := WebBrowser.Application;
if Dispatch <> nil then
begin
Dispatch.QueryInterface(IOleInPlaceActiveObject, iOIPAO);
if iOIPAO <> nil then
FOleInPlaceActiveObject := iOIPAO;
end;
end; if FOleInPlaceActiveObject <> nil then
if ((Msg.message = WM_KEYDOWN) or (Msg.message = WM_KEYUP)) and
((Msg.wParam = VK_BACK) or (Msg.wParam = VK_LEFT) or (Msg.wParam = VK_RIGHT)) then
else
FOleInPlaceActiveObject.TranslateAccelerator(Msg);
end;
end;
procedure TfrmChildWeb.FormCreate(Sender: TObject);
begin
Application.OnMessage := MsgHandler;
end;