What is the best way to display Flash content in a C# WinForms application? I would like to create a user control (similar to the current PictureBox) that will be able to display images and flash content.
It would be great to be able to load the flash content from a stream of sorts rather than a file on disk.
While I haven't used a flash object inside a windows form application myself, I do know that it's possible.
In Visual studio on your toolbox, choose to add a new component.
Then in the new window that appears choose the "COM Components" tab to get a list in which you can find the "Shockwave Flash Object"
Once added to the toolbox, simply use the control as you would use any other "standard" control from visual studio.
three simple commands are available to interact with the control:
AxShockwaveFlash1.Stop()
AxShockwaveFlash1.Movie = FilePath &
"\FileName.swf"
AxShockwaveFlash1.Play()
which, I think, are all self explanatory.
It would be great to be able to load
the flash content from a stream of
sorts rather than a file on disk.
I just saw you are also looking for a means to load the content from a stream,
and because I'm not really sure that is possible with the shockwave flash object I will give you another option (two actually).
the first is the one I would advise you to use only when necessary, as it uses the full blown "webbrowser component" (also available as an extra toolbox item), which is like trying to shoot a fly with a bazooka.
of course it will work, as the control will act as a real browser window (actually the internet explorer browser), but its not really meant to be used in the way you need it.
the second option is to use something I just discovered while looking for more information about playing flash content inside a windows form. F-IN-BOX is a commercial solution that will also play content from a given website URL. (The link provided will direct you to the .NET code you have to use).
Sven, you reached the same conclusion as I did: I found the Shockwave Flash Object, all be it from a slightly different route, but was stumped on how to load the files from somewhere other than file on disk/URL. The F-IN-BOX, although just a wrapper of the Shockwave Flash Object seems to provide much more functionality, which may just help me!
Shooting flys with bazookas may be fun, but an embeded web brower is not the path that I am looking for. :)
There was a link on Adobe's site that talked about "Embedding and Communicating with the Macromedia Flash Player in C# Windows Applications" but they seem to have removed it :(
Related
I haven't looked into it very much but am struggling to find relevant information on the topic. I basically want to create a browser that applies a filter to a webpage by changing colors in a webpage. My guess is that I will have to change the html once loaded or something, would this work? Do I have other options?
PS. I don't just want to make every color darker, I would more like to invert the colors.
Edit:
If any you were wondering, I am talking about the XAML browser component that can be used in a Windows Phone application.
I think the simplest way to do that is to inject some Javascript into your page once it has loaded.
To do that, you need to set the IsScriptEnabled to true on your WebBrowser control and then subscribe to the Navigated event.
When that event occurs you can inject some JS codeby using the WebBrowser.InvokeScript method.
Here is an example of JS code that darken the page : JavaScript: Invert color on all elements of a page
If you are talking about in a PC internet browser, you can find an add-on to execute Javascript automatically, such as Greasemonkey for Firefox. If you are talking about Windows Phone's Internet Explorer, I don't really know what you could do there, as I don't think they allow add-ons.
I'm working on a tool that generates output that I'd like the user to be able to conveniently send to Skype or other running applications rather than simply saving it if required.
Back when I used Acorn's RiscPC, the recommended style of the 'Save As' feature was a small dialog with an icon that represented the file, that you could drag to a folder to save, or drag to another application to send it to that app rather than saving it.
Right now, users need to save the file, then find the file in Windows Explorer and drag it to Skype from there. Sure I could easily add a 'Show in folder' icon, but it would be much neater to simply drag it straight to Skype.
Anyone know how to do this, or if it's been done before I can have a look at?
I should emphasize, I'm not specifically talking about dragging stuff to Skype, I could look at the Skype API for that, I'm talking about simulating a drag generally, as if it were a file dragged from explorer.
If you're using WinForms, here is a CodeProject article that shows you bi-directional drag and drop to and from Explorer/your application. Look here for WPF.
Hope this helps!
I'm being slowly driven mad at work having to manually gather data contained within an ActiveX object running in Internet Explorer 8. It's essentially a ticket system containing some key customer details etc. which I must copy and paste a lot more than is healthy.
Where would I start looking for a solution that will allow me to grab the data I want and navigate the ActiveX system programmatically?
Ideally I'd be thinking of writing something in Java or C# but I'm open to any suggestions!
Unless the ActiveX you are interested in exposes information through public interface (in which case you can injected JavaScript on page to read data) you'll have to use some form of screen scraping. If the control has regular input controls it should not be too hard, but if everything rendered directly you may need OCR the images...
Injecting script:
use WebBrowser control and "eval" your script on the page - some communication sample is here http://msdn.microsoft.com/en-us/library/a0746166%28v=VS.85%29.aspx, eventually you'll need InvokeScript - http://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.invokescript%28v=VS.85%29.aspx
use normal IE automation http://msdn.microsoft.com/en-us/library/aa752084%28v=vs.85%29.aspx.
for one-time use "javascript:" in address bar or just developer tools (F12).
utilize XSS vulnerabilities of the site (half kidding, don't forget to fix whatever you find afterwards if you own the site, as for reporting errors to third party consult your conscience)
I have an Internet Explorer window open. The title of this window will always be "test123"
how do I save the source of the contents of the window as an HTML file?
Please note that the process should not be to open a URL and read the HTML into a variable. I absolutely HAVE TO do it the way I described since I need to login to a site to be able to view the HTML that I want to save.
**if it makes it easier to do this through my winform and putting a webbrowser control on it, that is fine as well.
You can attach to virtually any Windows app, using managed code and the UI Automation classes. Not a lot of people know about this stuff.
Microsoft shipped a class library and runtime that allows applications to automate other Windows on the system. You can do things like click buttons, read textboxes, activate menus, and so on. Here's a quick intro.
It should be relatively simple to attach to an IE Window, and then programmatically tickle the File...Save As... menu option.
I did this the other day for a Paint.NET app. It took much less time that I thought it would.
But I agree it's probably easier to use a WebBrowser control in a regular app, to programmatically retrieve content. You could also use the System.Net.WebClient class to do it, if you don't need to show the HTML content.
If you embed a WebBrowser control inside of your WinForm you can do this:
webBrowser1.Navigate("http://StackOverflow.com");
string pageHtml = webBrowser1.Document.GetElementsByTagName("html")[0].InnerHtml;
This will return all of the HTML in the page navigated to.
I was wondering if anyone knows of an existing sample or an approach to achieve the desired functionality.
Basically, what I'm looking for is a web browser like skeleton. The idea is that the main screen of my application is shown in the left tab. This tab can never be closed. On this screen is an overview of various application components such as activities, events, contacts, etc.
When the user clicks on a specific contact/event/activity a new tab is created and auto-focused. The user can view and edit the information. When they are done they can close the tab.
The ability to have multiple tabs open is important.
Also, keyboard shortcuts to easily navigate between tabs would be great, but not absolutely essential at this point.
Note: I don't need to access any web content.
Really what I'm looking for, at least what I think I'm looking for, is a shell of a modern web browser. Does something like this exist? Is there a good approach to building such an application?
Note: I'm new to Windows GUI development, so I apologize if this is a rudimentary question. I was unable to find anything meaningful while searching MSDN and other resources.
Thanks!
What it sounds like is not really a Web Browser shell at all, simply the relative appearance of one functionality-wise.
What you can do is use a TabControl control. This can be altered to suit your needs quite perfectly in my view.
An example of a modified TabControl is as follows: [ From here ]
There are a number of things that can be done with a TabControl (as with any other component) to make it suit what you need.
Here are some links that you may find helpful:
Flat Tab Control - As per the picture
MSDN
Video on using a Tab Control
C# Corner