Grant1842
asked on
(Advanced Expert Question Here) Get position of clicked text in twebbrowser and go to it in SynEdit(RichEdit)
I have a synedit(richedit) and a twebbrowser on a form. I have html code in the richedit.
I load the html from the rich edit into twebbrowser;
I want to click on any text or object (image)in the twebbrowser and go to that place in the code on the richedit.
I am looking for example code to do this in Delphi p7.
I load the html from the rich edit into twebbrowser;
I want to click on any text or object (image)in the twebbrowser and go to that place in the code on the richedit.
I am looking for example code to do this in Delphi p7.
I will try to take a closer look at this later this afternoon. I am only writing this to let you know that someone else is looking into it.
ASKER
This is a Hard question Does anyone have an Ideal How to do this.
Maybe with this :
http://www.programmersheaven.com/mb/delphikylix/314808/314808/webbrowser-clicked-hyperlink/?S=B20000
we could add an onclick event on every object of the page...
http://www.programmersheaven.com/mb/delphikylix/314808/314808/webbrowser-clicked-hyperlink/?S=B20000
we could add an onclick event on every object of the page...
ASKER
I am getting Service Unavailable when I click that link
oh ? it works for me...
here is the code related to this article
here is the code related to this article
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, MSHTMLEvents, MSHTML_TLB;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
procedure FormCreate(Sender: TObject);
procedure WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
private
HTMLAnch : OleVariant;
AnchEvents : Array Of TMSHTMLHTMLAnchorEvents2;
Function LinkOnClick(Sender: TObject; const pEvtObj: IHTMLEventObj) : WordBool;
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
WebBrowser1.Navigate('F:\NCS_HTML\File3.html');
end;
Function TForm1.LinkOnClick(Sender: TObject; const pEvtObj: IHTMLEventObj) : WordBool;
Begin
pEvtObj.srcElement.innerText := 'Clicked';
End;
procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
Var aa : Byte;
begin
HTMLAnch := WebBrowser1.OleObject.document.getElementsByTagName('A');
For aa := 0 To HTMLAnch.length-1 Do
Begin
SetLength(AnchEvents, Length(AnchEvents)+1);
AnchEvents[aa] := TMSHTMLHTMLAnchorEvents2.Create(Self);
AnchEvents[aa].Connect(HTMLAnch.item(aa));
AnchEvents[aa].onclick := LinkOnClick;
End;
end;
end.
ASKER
THanks for that . THe site was down the other day for me when I clicked on it I see its up now.
ASKER
I tried that and its not really what I need.........
Thanks.
With the example you posted It seems to me there should be a way to at least get in a BLOCK OF CODE or RANGE of where you clicked.
It is useless to have a twebbrowser in edit mode if you can not detect where you clicked and get close to it in the richedt so you can work on your code..........
Any experts here have an ideal to get this done ?
Thanks.
With the example you posted It seems to me there should be a way to at least get in a BLOCK OF CODE or RANGE of where you clicked.
It is useless to have a twebbrowser in edit mode if you can not detect where you clicked and get close to it in the richedt so you can work on your code..........
Any experts here have an ideal to get this done ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your reply.
I have allready tried TEmbeddedWB and its many example but I have failed to find a way to catch the click and go to the region in the richedit source.
I have allready tried TEmbeddedWB and its many example but I have failed to find a way to catch the click and go to the region in the richedit source.
Ah, I bellieve it should give you the means of finding out where the user clicked. Beyond that you will need to scan your source (in the rich edit) to find the location. This can be a lot more difficult than it would first appear. A simple search for text will not do.
1) You will need to verify that you can get the click event from the TEmbeddedWB.
2) figure out a way to parse the source to find the relevant code.
It sounds like you are working on a web authoring tool. Knowing what you are aiming for would help. What type of page is this? Pure HTML? ASPX? What?
1) You will need to verify that you can get the click event from the TEmbeddedWB.
2) figure out a way to parse the source to find the relevant code.
It sounds like you are working on a web authoring tool. Knowing what you are aiming for would help. What type of page is this? Pure HTML? ASPX? What?
ASKER
Thanks for your help. I am working on editing joomla 1.5 templets. so it is mixed PHP/HTML.
Did you get the click event?
ASKER
Have not had time to look into it. I am currently looking into the GECKO html engine. I think it will take a couple of modules one for the active x to interface to the GECKO engine and One to get the code back into the rich edit.
THanks for your help with these questions. If the GECKO works I will accept you answer on the other question.
THanks for your help with these questions. If the GECKO works I will accept you answer on the other question.
ASKER
Solution was found useing A Custom Twebbrowser.
No need for the GECKO stuff.
No need for the GECKO stuff.
- Delphi Programming
- Internet & Delphi Programming