Delphi 是否可以设置WebBrowser文档图像-边框、对齐、hSpace和vSpace?

Delphi 是否可以设置WebBrowser文档图像-边框、对齐、hSpace和vSpace?,delphi,browser,Delphi,Browser,执行此代码时,src和alt设置正确,但边框、对齐、hspace和vspace产生EOleException错误的变量类型 是否可以使用webbrowser设置边框,对齐,hspace和vspace,如果可以,如何设置? 有没有办法找出正确的变量类型 iDoc := ( WebBrowser1.Document as IHTMLDocument2 ); iDoc.execCommand( 'InsertImage', False, 0 ); iImageIndex := WebBrowser1.

执行此代码时,
src
alt
设置正确,但
边框
对齐
hspace
vspace
产生
EOleException
错误的变量类型

是否可以使用webbrowser设置
边框
对齐
hspace
vspace
,如果可以,如何设置?
有没有办法找出正确的变量类型

iDoc := ( WebBrowser1.Document as IHTMLDocument2 );
iDoc.execCommand( 'InsertImage', False, 0 );
iImageIndex := WebBrowser1.OleObject.Document.Images.Length - 1;
iImageFileName := ExtractFileName( iImageFilePath );
// Change the src path to a relative path 
iSrc := ChangeFilePath( iImageFilePath, '..\Images\' );
iImageTextAlternative := FormInsertImage.AlternateText1.Text;
// Set Src 
WebBrowser1.OleObject.Document.Images.Item( iImageIndex ).src := iSrc;
// Set a text alternative to the graphic 
WebBrowser1.OleObject.Document.Images.Item( iImageIndex ).Alt := iImageTextAlternative;
// Set border 
WebBrowser1.OleObject.Document.Images.Item( iImageIndex ).border := FormInsertImage.Border1.EditValue;
// Set align 
WebBrowser1.OleObject.Document.Images.Item( iImageIndex ).align := FormInsertImage.Alignment1.EditValue;
// Set hSpace 
WebBrowser1.OleObject.Document.Images.Item( iImageIndex ).hSpace := FormInsertImage.hSpace1.EditValue;
// Set vSpace 
WebBrowser1.OleObject.Document.Images.Item( iImageIndex ).vSpace := FormInsertImage.vSpace1.EditValue;
编辑-现在可以工作了…

iDocument := ( TopicWebBrowser1.Document as IHTMLDocument2 );
if Assigned( iDocument ) then
begin
  // Insert the image
  iDocument.execCommand( 'InsertImage', False, 0 );
  while TopicWebBrowser1.ReadyState < READYSTATE_COMPLETE do
    Application.ProcessMessages;
  HTMLElementCollection := ( TopicWebBrowser1.Document as IHTMLDocument2 ).images;
  iImageIndex := TopicWebBrowser1.OleObject.Document.images.Length - 1;
  HTMLImgElement := ( HTMLElementCollection.Item( iImageIndex, 0 ) as IHTMLImgElement );
  // Set the src, alt, border, align, hspace and vspace             HTMLImgElement.src := ChangeFilePath( FormInsertImage.PictureName1.Text, '..\Images\' );
  // Change the src path to a relative path 
  HTMLImgElement.alt := FormInsertImage.AlternateText1.Text;
  HTMLImgElement.border := FormInsertImage.Border1.EditValue;
  HTMLImgElement.align := FormInsertImage.Alignment1.EditValue;
  HTMLImgElement.hspace := FormInsertImage.hspace1.EditValue;
  HTMLImgElement.vspace := FormInsertImage.vspace1.EditValue;
end;
i文档:=(主题WebBrowser1.作为IHTMLDocument2的文档);
如果已分配(i文档),则
开始
//插入图像
execCommand('InsertImage',False,0);
而TopicWebBrowser1.ReadyState
试试这样的方法

procedure TForm1.Button1Click(Sender: TObject);
var
  I: Integer;
  HTMLImgElement: IHTMLImgElement;
  HTMLElementCollection: IHTMLElementCollection;
begin
  WebBrowser1.Navigate('http://www.example.com');
  while WebBrowser1.ReadyState < READYSTATE_COMPLETE do
    Application.ProcessMessages;

  HTMLElementCollection := (WebBrowser1.Document as IHTMLDocument2).images;

  for I := 0 to HTMLElementCollection.length - 1 do
  begin
    HTMLImgElement := (HTMLElementCollection.item(I, 0) as IHTMLImgElement);
    HTMLImgElement.src := 'c:\someimage.jpg';
    HTMLImgElement.alt := 'Alternative text ...';
    HTMLImgElement.border := '5';
    HTMLImgElement.align := 'middle';
    HTMLImgElement.hspace := 5;
    HTMLImgElement.vspace := 5;
  end;
end;
procedure TForm1.按钮1点击(发送方:TObject);
变量
I:整数;
HTMLImgElement:IHTMLImgElement;
HTMLElementCollection:IHTMlementCollection;
开始
WebBrowser1.导航('http://www.example.com');
而WebBrowser1.ReadyState