Delphi analog No ID no Name picture click event

Source: Internet
Author: User

Recently wrote your own gadget, need to simulate click on the page picture.


Test page:

Delphi Test Code:

unit unit1;interfaceuses  winapi.windows, winapi.messages, system.sysutils,  system.variants, system.classes, vcl.graphics,mshtml,  vcl.controls, vcl.forms,  vcl.dialogs, vcl.olectrls, shdocvw, vcl.appevnts,  vcl.stdctrls;type   Tform1 = class (Tform)     WebBrowser1: TWebBrowser;     applicationevents1: tapplicationevents;    button1: tbutton;     memo1: tmemo;    procedure formcreate (Sender: tobject);     procedure applicationevents1message (var msg: tagmsg; var handled:  Boolean);     procedure button1click (Sender: tobject);  private     { Private declarations }  public    {  public declarations }  end;var  form1: tform1;implementation{$R  *.dfm}procedure  Tform1.applicationevents1message (Var msg: tagmsg;var handled: boolean);    / /delphi WebBrowser the right-click method is forbidden Begin  with msg do  begin    if  not ischild (Webbrowser1.handle, hwnd)  then exit;    handled  :=  (Message= wm_rbuttondown)  or  (message= wm_rbuttonup)  or  (message= Wm_contextmenu);   end;end;procedure tform1.button1click (Sender: tobject);var   doc: ihtmldocument2;  aaa: ihtmlelement;  i: integer;  s:  string;begin  doc := webbrowser1.document as ihtmldocument2;  if  doc.images.length = 0 then exit;  memo1.clear;  for i :=  0 to doc.images.length-1 d o    with  (Doc.images.item (i,null)  as ihtmlimgelement)  do     begin      s := name;       s := s +  '; '  + href;      s := s +  '; '  + src;      s := s +  '; '  + mimeType;      s := s +  '; '  + dynsrc;      s := s +  '; '  + vrml;      memo1.lines.add (s);       Aaa:=doc.images.item (i,null)  as IHTMLElement ;      aaa.click;     end;end;procedure tform1.formcreate (Sender: tobject);begin      WebBrowser1.Silent :=true;     WebBrowser1.Navigate (Extractfilepath (application.exename)  + ' test.html '); end;end. 

Operating effect:

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/06/1F/wKiom1myB0PwyogeAAYwGY4U19A312.gif-wh_500x0-wm_ 3-wmp_4-s_312217642.gif "title=" Test.gif "alt=" Wkiom1myb0pwyogeaaywgy4u19a312.gif-wh_50 "/>

This article from "So, OK" blog, please be sure to keep this source http://hji116.blog.51cto.com/3417806/1963618

Delphi analog No ID no Name picture click event

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.