I want to create a form with a twebbrowser and a tedit box, more if needed.
Then lets say, I want the browser to be on google.com and when I type in the search bar I want it to type in the tedit as well. Best would be at the same time but it is fine if i click away it will fill in the tedit box as well. i just want to understand how this work, Type on the site and have the edit boxed automatically typed as well.
anyone can help me?
There is no event in TWebBrowser (so far as I know) that fires as you edit the location (I don't think TWebBrowser has a search bar so I presume that's what you mean).
When I have tried to keep a host app in sync with a TWebBrowser I have used the OnBeforeNavigate2 event.
I haven't tried this, but I bookmarked the web site a while ago.
Calling into Delphi from JavaScript
The article discusses how to call delphi-code from the TWebBrowser. You implements an external object extension by declaring an interface, and then registers it with the browser control. Doing that, you should be able to invoke delphi methods by using JavaScript in the web site.
You have to be in control of the source that is shown in the TWebBrowser, so the google example wouldn't work. ...unless you manipulate the html-source by injecting custom code before you show it in the TWebBrowser, of cource.
I hope this may put you the right track...
Reading your comment, you may consider to do it the other way around:
Type the search in the TEdit (and handle all the logging you need), and then navigate the TWebBrowser to this url: 'http://www.google.com/search?q=' + Edit1.Text
Related
I am currently working on a project with a really easy task : When I press a button, the form I'm currently in is printed (like a print screen).
I use the method Self.Print; in the said button and everything works fine. My buttons, labels and TextBoxes all get printed. The problem is, I have a RichEdit in the form I'm trying to print and when the page come out of the printer, the RichEdit is blank.
I know there is much better ways to print informations from a form, but this is the current way that the button has to work.
I've found some forums with topics from 2003 that said it was either not possible or I had to use the RichEdit.Print method but this means having 2 pages coming out of the printer instead of one.
Is there a better way to print the whole package?
RichEdit1.Print(RichEdit1.Text);
PrintDialog1.Execute;//Choose your printer from list
I use Delphi 7 on Vista. So far, I have implemented a simple browser (using TWebBrowser) but I would like to automatically enter information when the web page asks for it. For example, I want to tell my app to go to Google, detect the Search field, enter a search phrase, and then click the Search button and then get the result.
Can someone shed some light on how this is done?
You need to use the DOM to do this. The best online resource for learning this in a Delphi setting is at Brian Cryer's site. Take a look at How to read and write form elements.
In the google instance you could simply call the search URL directly yourself.
Eg. This URL searches for 'jam'
http://www.google.ie/search?q=jam&ie=UTF-8&oe=UTF-8&hl=en&client=safari
Get your code to change jam for your search string and go to that URL. I hope this is what you are looking for.
How do I programatically send keys to a TWebBrowser to fill in data fields like Name and address?
If you want to fake input you need to use the SendInput API.
However, that's going to require you to make sure that field in question has the input focus. I suspect you would be better off poking the data in through the DOM (IWebBrowser2.Document).
I guess you want just to fill in some data in some edit boxes.
If yes, this might be useful for you http://delphi.about.com/od/twebbrowser/a/submit_web_form_2.htm
The most robust way would be to use the DOM as suggested previously. However if you end up going via the simulated input route, the Delphi SendKeys unit will make things much easier.
Article and download available here: http://delphi.about.com/od/adptips2004/a/bltip1104_3.htm
I am writing an application that needs to read a data field on another Delphi program and I do not have access to the source code of the 3rd party program. The data field contains the "foreign key" to a record I need to retrieve or create in my application.
I would appreciate any links to knowledge or components that will help me with my program.
I'm assuming that you are trying to "screen scrape" a text field from another app. You can use FindWindow to get a handle that that window, then dig through the child windows to find the control that you're looking for (WinDowse by Greatis will be very helpful here for exploring manually). Finally, send a WM_GetText message to the control that has the data. Here is an example of how to do this: About.Com article on digging and scraping with Internet Explorer.
Edit: D'oh! WM_GetText is already wrapped in the VCL with the GetWindowText function defined in windows.pas. ex:
GetWindowText(Wnd, PC, sizeof(PC));
I am using a Listbox and Telerik Scheduler in my web page. I need to drag an item from listbox to scheduler control. How can I do that?
I know this question is quite old now, but I thought I'd provide an answer to help others that arrive here.
RadScheduler (like all Telerik controls) provides a rich client-side API that makes it possible to write some JavaScript to handle drag-and-drop scenarios. There is a complete demo showing you how to drag-and-drop between a RadGrid and RadScheduler online:
http://demos.telerik.com/aspnet-ajax/scheduler/examples/draganddropintegration/defaultcs.aspx
In this example, you see how to use RadGrid's RowDropping client-side event and RadScheduler's client-side API to determine where an item has been dropped. Ajax is then used to add the appointment to the Scheduler.
To adapt this for a ListBox, you need to have a similar event that can be fired when your ListBox item is dropped. Unfortunately, the default listbox will not provide that, but you can use something like the RadListBox (which has more client-side events, including OnClientDropping). Here, ListBox drag-drop is integrated with a RadTreeView:
http://demos.telerik.com/aspnet-ajax/listbox/examples/applicationscenarios/treeviewdraganddrop/defaultcs.aspxt
I hope that helps.