![]() |
|
TWebBrowser butona tiklamak ve Id ogrenmek - Baskı Önizleme +- Delphi Can (https://www.delphican.com) +-- Forum: Delphi (https://www.delphican.com/forumdisplay.php?fid=3) +--- Forum: Delphi ile Web Teknolojileri (https://www.delphican.com/forumdisplay.php?fid=118) +--- Konu Başlığı: TWebBrowser butona tiklamak ve Id ogrenmek (/showthread.php?tid=7311) |
TWebBrowser butona tiklamak ve Id ogrenmek - acetinturk - 23-05-2023 Merhaba, Asagidaki sekilde bir sayfa olusturdum. Asagidaki butonlardan herhangi birine tiklandigi zaman, id'yi delphi icinden okumak istiyorum. Su anda bu islem icin asagidaki MyMessages procedure'ni kullaniyorum. Fakat her zaman saglikli olarak calismiyor. Saglikli olarak calismiyor derken; butonda bastigim yere bagli olarak id'yi döndüruyor ya da döndürmüyor Bunun icin en saglikli yontem nedir? (Delphi 7 kullaniyorum.) Tesekkur ederim. procedure TfrmTest.MyMessages(var Msg: TMsg; var Handled: Boolean); var i, X, Y: Integer; document, E: OleVariant; begin if (Msg.message = WM_LBUTTONDOWN) and IsDialogMessage(WebBrowser1.Handle, Msg) then begin X := LOWORD(Msg.lParam); Y := HIWORD(Msg.lParam); document := WebBrowser1.Document; E := document.elementFromPoint(X, Y); if (E.ClassName = 'button') and (E.Id <> '')then begin ShowMessage(E.Id); end; Handled := False; Exit; end; end; <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <style> html, body { margin: 0; height: 100;} .button { border: none; height: 60px; width: 116px; padding: 2px 2px; padding-top: 1px; padding-bottom: 0px; text-align: left; text-decoration: none; display: inline-block; vertical-align: top; display: table-cell; font-size: 12px; margin: 8px 8px; cursor: pointer; white-space: normal; word-wrap: break-word; } </style> </head> <body style="background-color:Silver;"> <table> <tr> <td class="button"; style="font-size: 14px; background-color: White; color:Black;" id="77p"; ><b>Ilk Urun deneme yanilma icin biraz uzun text yazmayi denedim bu urunde.</b></td> <td class="button"; style="font-size: 14px; background-color: White; color:Black;" id="79p"; ><b>Ikinci Urun0</b></td> <td class="button"; style="font-size: 14px; background-color: White; color:Black;" id="81p"; ><b>Ucuncu Urun</b></td> <td class="button"; style="font-size: 14px; background-color: White; color:Black;" id="83p"; ><b>Dorduncu Urun</b></td> <td class="button"; style="font-size: 14px; background-color: White; color:Black;" id="85p"; ><b>Besinci Urun</b></td> <td class="button"; style="font-size: 14px; background-color: White; color:Black;" id="87p"; ><b>Son Urun</b></td> </tr> </table> </body> </html> TWebBrowser butona tiklamak ve Id ogrenmek - acetinturk - 26-05-2023 Tekrar merhaba, Saniyorum daha iyi bir cozum buldum ve paylasmak istedim. Benim yaptigim testlerde oldukca iyi calisiyor. procedure TfrmTest.MyMessages(var Msg: TMsg; var Handled: Boolean); var E : IHtmlElement; Doc : IHtmlDocument2; function GetID:IHtmlElement; begin Doc := IDispatch(WebBrowser1.Document) as IHtmlDocument2; Assert(Doc <> Nil); Result := doc.activeElement; end; begin if (Msg.message = WM_LBUTTONDOWN) and IsDialogMessage(WebBrowser1.Handle, Msg) then begin E := GetID; if (E.ClassName = 'button') and (E.Id <> '')then begin ShowMessage(E.Id); end; Handled := False; Exit; end; Handled := False; end; Cvp: TWebBrowser butona tiklamak ve Id ogrenmek - hi_selamlar - 26-05-2023 (26-05-2023, Saat: 01:42)acetinturk Adlı Kullanıcıdan Alıntı: Tekrar merhaba, Merhabalar, Kodlarınızı kod bloğu içerisine alırsanız okunaklılığı ve görsel olarak daha iyi olacaktır. [attachment=2357] Kolay gelsin. |