Trying to use Edgewebbrowsers SubscribeToCDPEvent - delphi

Delphi has a demo with EdgeBrowser
I am trying to Subscribe to DevToolsProtocol using the follow.
EdgeBrowser.SubscribeToCDPEvent('Log.enable');
EdgeBrowser.SubscribeToCDPEvent('Log.entryAdded');
but EdgeBrowserDevToolsProtocolEventReceived never fires.
Any help?

EdgeBrowser1.DefaultInterface.OpenDevToolsWindow;
starts DevTools
Remember, the WebBrowser component does not have this command, it only exists in the EdgeBrowser component.

Related

Can you use AddEventListener with CEF4Delphi?

I am using Delphi XE2 and Chromium CEF4Delphi. I am trying to use a web page via the TChromiumWindow component and would like to detect when an element is selected / clicked.
I saw this post..
Delphi Chromium - launch a command in Delphi application when button in web page is clicked by user
Unfortunately, I cant find the function AddEventListenerProc in the CEF4Delphi library. Neither can I find an alternative way to monitor a button / element click.
I would like to use the TChromiumWindow component to act as a "fron-end" to my app and would like to monitor user button clicks etc.
Can anyone help please ? I did try the developer forum but I dont see much activity there and was unable to register.
Many thanks..
The DCEF3 project has a group here : https://groups.google.com/forum/#!forum/delphichromiumembedded
But the CEF4Delphi and OldCEF4Delphi projects have a developers forum here :
https://www.briskbard.com/forum/
That forum has new posts almost every day and I try to answer them as soon as I can, usually in less than 24 hours.
If you have problems creating an account just send me a message and I'll activate your account manually.
The link you posted is very old and many things have changed in CEF since 2012.
There are several ways to detect when a HTML element has been selected, clicked, etc.
You can use a JavaScript event like "onclick" that calls a custom JavaScript extension. That extension would send a process message to the browser process to notify that the user clicked that element.
You can also use the GlobalCEFApp.OnFocusedNodeChanged that is triggered when an HTML element has been focused. This event is executed in the "render" process so you will also need to send a process message to the main browser process that the focused element has changed.
Use the JSRTTIExtension or the JSExtension demos as a template for your app.
They show you how to set a "mouseover" event that calls the "myextension.mouseover" function defined in a custom JS extension. The myextension.mouseover function executes Delphi code and sends a process message to the main browser process with some HTML information that is shown in the status bar.
They also have an example for a "MutationObserver" that calls a generic "myextension.sendresulttobrowser" function in the JS extension that sends the "value" attribute to the browser process.
Build the demo and right-click on the web page when it's fully loaded. Then select the "Set mouseover event" or "Add mutation observer" options to test what I described.

Notify ActiveX that <object> has been removed from DOM

This is a bit necroposting but I'm out of luck here.
How do I get notified in my ActiveX COM that node has been removed from the DOM through parent.innerHTML = '' or parent.removeChild(activeXID)
FireBreath seems to be doing it somehow
FireBreath doesn't really support being removed and added again, but I think it is either with InPlaceDeactivate or SetClientSite somehow; you'd just have to set some breakpoints and play with it. The file you need in FireBreath is FBControl.h

Automatic Typing Textarea/input/form in JavaScript

I've been searching for a way to make a textarea type inside of itself. Unfortunately, even with some google searching, I still don't have a clue? Do you guys know where to start with this?
http://lmgtfy |dot| com is an example, but I'm not sure if they use some other technique...
The lmgtfy people are simply using javascript to change the value of the input. Here is a simple jsfiddle showing the same thing:
http://jsfiddle.net/Caut6/1/
LMGTFY uses javascript. If you visit the site using chrome or some other browser with a debugger, you should be able to pause javascript execution and check out how they do it, then roll or copy your own version.
In Chrome, the pause button is under the Scripts area. Their bundle.js files appears to host the JS you are looking for, it is around 1000 lines of code, but you should be able to see the few functions you need to borrow their implementation.
Hope this helps.

Is there a way to disable the hint for a TOpenDialog in delphi?

I have a TOpenDialog component I am creating on runtime and I want to disable the hint that pops up over files when it is used. I have not written any exrta code for this than creating the object, executing the object and extracting the filename,, then freeing the instance.
Can I do what I want to do? If so, how do I do this?
I googled for "opendialog crash tooltip" and the first hit gave me this. The solution for their problem (and probably yours) is this:
[...]
You only need to add this modification to the first form of your application:
uses ActiveX;
initialization
OleInitialize(nil);
finalization
OleUninitialize
end.
Since this is a Windows common dialog, you may have to jump in and hook into the dialogproc and manually try and process the tooltip messages. You can look here for a start about how to customize the common dialogs; http://msdn.microsoft.com/en-us/library/ms646951.aspx. You can also look at creating your own TOpenDialog descendant and override the WndProc protected method to get access to the dialog messages and notifications. I suspect you'd also need to do some deeper hooking and start getting into dealing with the explorer shell. The file list in that dialog is actually an instance of parts of the Windows Explorer shell.
Another question is what is it you're trying to accomplish by hiding this information from the user? Maybe there is some other solution to what you're trying to do rather than disabling some intrinsic functionality?

How do I make a TLinkLabel work in Delphi?

I put a TLinkLabel on my form, filled it in with a caption including a valid HTML link, and got some nice blue underlined text. When I ran the program, I expected it to invoke Firefox (my default browser) and open the link automatically. Apparently that's not the case.
The helpfile says I have to code this in an OnLinkClick event handler. It doesn't say anything about how to do that, though. It'll pass in a string value called "Link". How do I say "invoke the default browser and have it open Link"?
You can call ShellExecute.
I wrote this method for generic calls, and should works in your case.
procedure ShellOpen(const Url: string; const Params: string = '');
begin
ShellAPI.ShellExecute(0, 'Open', PChar(Url), PChar(Params), nil, SW_SHOWNORMAL);
end;
In your code you should call this
procedure TForm1.LinkLabelClick(Sender: TObject);
begin
ShellOpen(LinkLabel.Caption);
end;
I have all sorts of problems with TLinkLabel that ships with delphi 2010.
a) The control does not render as a hyperlink but as a simple label text on the form. b) the cursor does not change to point out this is a link even though I set the Cursor property. c) the OnLinkClick event does not fire at all.
I am working on windows 7.
So, as far as I am concerned, TLinkLabel does nothing as it should and is useless. ShellExecute is the only solution and must be placed in the OnClick event.
TLinkLabel provides a label that looks like a link. It's your job as the programmer to make it act like a link because only you can know what links are supposed to act like in your program. You wanted the label to automatically open the user's default Web browser using the URL in the label, but that's not the only thing links do. For example:
Internet Explorer is not my default browser, but when I click a link in Internet Explorer, I do not expect the linked page to open in Firefox.
When I click a link in the help program, I expect the linked topic to appear in the help program, not in any Web browser at all.
The preference pages in Eclipse are very complicated. Settings on one page are sometimes related to settings on another page. There are links on those pages that take the user directly to the related page. There is no URL and no HTML involved in this case, and yet they're still labels with underlined text.
Some programs try to offer a choice between opening links in new windows versus re-using old windows. You can't implement that feature without knowing which browser is in use. Your program might offer the user a choice to ignore the default browser setting and always use a specific one. To do that, your UI control can't make too many assumptions about what the program is supposed to do.
I'm guessing you're referring to a TLinkLabel control that comes with Delphi. (My versions don't have such a component.) I imagine that the Delphi control is meant to mimic the one in the .Net class library. It can hold multiple links, and each link can do something different.
If you want a control that always does the shell's default action for URLs, then consider using a different TLinkLabel; the one by Alexander Bach does exactly what you expected. It's from Delphi 3, but it should work unmodified in all later versions as well, including Delphi 2009. If you look at the code, you'll see how it works. It simply calls ShellExecute, as Cesar's answer demonstrates.
LOL, it's funny. So instead of setting crHandPoint as cursor, colored and underlined font and filling the OnClick event to standard TLabel we have component that knows link tag and which at all I need to supply with same On(Link)Click event :))
Only thing it is good for is that it makes easier to embed link into some text and that it is using system style of link...
p.s.: really you have to put Some text with link into the Caption and setup OnLinkClick to that ShellExecute...
I use a control called TInternetLabel instead. It does exactly what you want: on click it opens the browser so you don't have to put code in the OnClick event.
I tried this solution but it still gave problems in Delphi XE4, probably becasue ShellOpen does not understand the HTML-code in the Caption.
What worked for me was a combination of Cesar Romero (the basic code), Adam Feistner (The HTML-code in the Caption) and an older solution:
Put the URL in the HINT field.
Change the line: ShellOpen(LinkLabel.Caption);
to
ShellOpen(LinkLabel.Hint);
This worked for me.

Resources