How can I send a mouse onclick message to TWebBrowser in Delphi? The OnClick message must be sent to specific control appears in website.
for Example i have a radio button appears in the website named XXXRB and I want send the message to that Radio button (which is named XXXRB) to select it.
How can I do it?
Regards.
can you call JS from Delphi ?
http://www.delphidabbler.com/articles?article=21
http://jansfreeware.com/articles/delphi-ie-javascript.html
http://www.programmersheaven.com/article/12946-How+to+call+JavaScript+functions+in+a+TWebBrowser+from+Delphi/info.aspx
probably there should be way
http://www.roseindia.net/javascript/javascript-click-method.shtml
To locate the control DOM Object you may try collections such as GetXXXByName or libraries like jQuery or custom JS code.
however that is the question on Internet Epxlorer + JavaScript, not on Delphi.
No need for javascript as Arioch implies.
You can have access to the complete DOM via TWebBrowser.Document.
There are many resources on the net on this subject, this is the most complete one:
http://www.cryer.co.uk/brian/delphi/twebbrowser/read_write_form_elements.htm
if you look around on SO you also will find some snippets.
Related
I currently use a standard TFindDialog in my Delphi application:
How can I change the textbox to a combobox? I'd like to set it up so that the user can easily see and select from the history, like this:
I currently use a standard FindDialog in my Delphi application.
How can I change the text box to a combo box?
You can't, at least not with TFindDialog, as it does not allow the use of a custom dialog template (the underlying FindText() API does, though).
However, there is another workaround for your situation...
In the TFindDialog.OnShow event, use FindWindowEx() to manually find the HWND of the Edit field in the dialog, and then use the Shell's IAutoComplete interface to enable a drop-down list on that HWND. You can write a class that implements the IEnumString interface to provide the entries that you want to appear in that drop-down list (for instance, by wrapping a TStringList that you store your entries in).
See MSDN documentation for more details:
Using Autocomplete
How to Enable Autocomplete Manually
Also see:
This answer to Google like edit/combo control for Delphi?
This answer to Auto append/complete from text file to an edit box delphi
This answer to How to use IAutoComplete together with TStringsAdapter?
I am pulling this attribute directly from Mozilla Firefox's about.xul file which shows the About dialog box for an add-on. It is a relatively simple XUL dialog with no inputs, locale data pulled from DTD entities, string bundle properties and JavaScript.
<!-- omni.ja!/chrome/toolkit/content/mozapps/extensions/about.xul -->
<!-- chrome://mozapps/content/extensions/about.xul -->
<dialog id="genericAbout"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="init();"
buttons="accept"
buttoniconaccept="close"
onaccept="close();">
MDN: Dialogs and Prompts and MDN: dialog both mention something about attributes that are formed by concatenating (pseudo-regexp):
"button" + "(label|accesskey|oncommand)" + "(accept|cancel|disclosure|help|extra[12])"
For example: buttonlabelaccept.
However, I could not find any documentation about the use of icon. The word icon does not even show up on either of the above-mentioned pages! What does it do? What is the correct way to use it?
I'm trying to make my add-on about page more modular, without loading internal files from omni.ja(r), which pulls in a LOT of unnecessary code with it. I am developing a very streamlined version, that will style itself appropriately depending on calling context.
I want it to look like Firefox's official About < addon.name > dialog if called from about:addons context-menu, or from my add-on's status-bar context-menu. I want a slightly different appearance if viewed from within the Options dialog as an iframe inside a XUL. I already have that structure set up. Just tweaking the little quirks.
This is not critical design or feature wise, and indeed the entire API will go away in a few months, but it just bothers me to not really understand this, so I want to figure it out before I let it go an move on to more important things. But I will if I absolutely can't find an answer. But it's one of those stupid little things that will just bother me a disproportionate amount. =D
If you can point me to documentation I may have missed, or even specific Mozilla source code, and a few examples, or a more complete explanation and typical use-cases, that would be great.
If you check the "blame" for about.xul, you'll see that the line was added to fix bug 422763. Judging from the screenshot in the bug, GNOME (Linux) has (had?) a convention of putting icons on dialog buttons, and this attribute allows overriding the default icon (inferred from the button type).
If you search for buttonicon, you'll find the code that handles this attribute in toolkit/content/widgets/dialog.xml.
Is There A Browser-Add-on That Can Create A Temporary Txt File From My Clipboard And Populate The File Submit Dialog?
Guide for firefox:
Get the data from your clipboard with this: paste data from clipboard using document.execCommand("paste"); within firefox extension
Now you can either create a temporary file with something like OS.File: https://developer.mozilla.org/en-US/docs/JavaScript_OS.File/OS.File_for_the_main_thread
Or create a object with something like window.createObjectUrl.
Then assuming the file submit dialog is prompted by a html5 uploader, then you should just set value of that html5 dialog box there are other ways though too, like mozSetDataAt, mozSetFileArray etc, search github for these keywords shows excellent examples:
https://github.com/search?l=javascript&q=mozSetDataAt&type=Code&utf8=%E2%9C%93
https://github.com/search?l=javascript&q=mozSetFileArray&ref=searchresults&type=Code&utf8=%E2%9C%93
You might need to use the mimeType of application/x-moz-file not sure. Definitely experiement with it and share your solution, and ask for help along the way. This is fun stuff.
There are probably other smarter ways to attach into a input type=file, i was trying to do it the other week. I would also be interested if someone else could share some solutions to actually trick the file input element to think the native file dialog was actually used, maybe using XPCOM.
I typically use TOpenDialog with its Filter property for narrowing down available files for the user. I would like to further filter these files down by their content.
For example, the open file dialog should display only files with a ".bin" filename extension and its first 4 magic bytes are 0x7F, 0x45, 0x4C, 0x46 (ELF executable).
The condition will not always necessarily be identifying certain executable formats, but other binary data as well.
Is there a standard way of doing this in Delphi/VCL or do I have to postpone the content inspection until after the user has selected the file?
There's no way to achieve what you want. The system file dialog does not allow you to filter the files that it displays based on their content.
The OnIncludeItem event tantalisingly appears to do what you need. However, it has the following problems.
The event wraps the CDN_INCLUDEITEM notification. This notification is fired by the legacy XP common dialog boxes, but not by the modern common item dialog. So, using the event forces the legacy XP common dialog boxes onto your program. If for no other reason, this has cosmetic downsides.
More significantly, handling CDN_INCLUDEITEM has no impact on files. It only influences non-filesystem shell objects. Form the documentation:
The dialog box always includes items that have both the SFGAO_FILESYSTEM and SFGAO_FILESYSANCESTOR attributes, regardless of the value returned by CDN_INCLUDEITEM.
Related questions:
Is there a way to choose which files are displayed to the user via the standard OPENFILE dialogs?
In Delphi how does the OnIncludeItem event work on TOpenDialog?
I am using dcef3 and Delphi XE2. When the URL changes I would like to detect it and show a delphi message displaying the new URL. Can this be achieved? I am trying to use the URL to pass delphi some commands to execute.
Thank you for your help and apologies for my bad English.
It seems you are looking for the OnAddressChange event. This event is fired when the frame's address has changed. The new URL of the frame you can get from the url parameter.