How can I implement ActiveX Document on C#/.NET? (ActiveX Document can draw itself in IE)
Update: I need a solution for drawing my own document type in IE windows (like MS Word or MS Excel draw its documents in IE).
You need to dive into OLE for that purpose.
Things like IOleDocument, IOleInPlaceSite (see MSDN for that). Figure out which interfaces are needed for the client (as IE would be the container and will need to communicate with your interface implementations), and how the communication is going on, e.g. what gets called when.It's not rocket science, but I believe still a fair amount of work.
Look at http://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.domdocument.aspx, it's .NET wrapper for DOM Document
My first thought is that you could use a WPF Page, which can be hosted in a WPF window or in IE.
From MSDN:
Encapsulates a page of content that can be
navigated to and hosted by Windows
Internet Explorer, NavigationWindow,
and Frame.
This is possible but it is tough.. What is bad is the lack of documentation... Microsoft has no interest in supporting this scenario. Another difficult part is debugging the boundaries between the HTML/DOM and the ActiveX control.
For what you're doing, it sounds like Silverlight would be a better choice. It only supports a subset of .Net, but it supports drawing graphics. It'll be a lot easier for you to find documentation. And it will run on non-Windows computers.
But maybe you need something Silverlight doesn't do (like audio input support). If thats the case, there's various blogs on the subject of varying quality. Here are the two that stood out as most helpful to me:
http://www.codeproject.com/KB/cs/CreateActiveXDotNet.aspx
http://blog.ianchivers.com/wordpress/?p=22
I do recommend using OleView to inspect the type libraries you produce, and make sure its what you expect. You can also do this to see how to break event properties into get/set functions, which is something I had to do to debug some scenarios.
Also be cognizant of the difference of "attaching debugger to process" with scripted or managed debugging. At some point you'll attach with one when you think you've used the other.
Related
Recently I’ve been working on a windows wallpaper manager. It will scan multiple directories for images and have a settings window to customize. In addition, I want to bypass the built-in wallpaper and instead use a windows form based off the ideas discussed here: Setting a Windows form to be bottommost to allow for greater control over image placement. I have built the file operations to find the wallpapers, and various other support operations.
However, I am stumped on how to implement a windows form properly. Not just the one in the Stack Overflow post above. So far none of my CompSci classes (7 so far) have discussed GUIs, and thus I have no knowledge to work from. I turned to the internet to learn how to work with GUIs. While I learned plenty to start a thread, or show a form, I was never able to find anything that described the proper way to engineer an application with a GUI. All I have learned in respect to engineering the application is to limit the number of threads, and try to separate the GUI from the non-GUI related code (if that makes sense).
Like I have said, I have no clue what I am doing. If someone would be willing to give me pointers or even a link to something on this subject, that would be amazing!
EDIT: I have been using this as a learning exercise, and I have mostly been learning from trial and error, probably mostly error
To draw on the true desktop, you need to get a handle to it: GetDesktopWindow is the function to use. But to change the wallpaper you do not draw on the desktop, but instead you use the dedicated API for handling the desktop wallpaper: SystemParametersInfo(SPI_SETDESKWALLPAPER, ...). There is also the legacy COM Shell interface, IActiveDesktop and IActiveDesktop::SetWallpaper.
As you can see, none of the APIs to manipulate the desktop and the wallpaper are managed (C#, .Net) so you will have to jump through some hoops to get this working from C#. If your goal is to learn C# style UI, I would recommend to stick to the 'blessed' way of doing this (winforms, WPF etc) and do not try to jump straight to p-Invoke and COM interop. Perhaps you can pick another project, eg. display the images/pictures in a carousel in a form.
If you're curious still, Google for C# and SystemParametersInfo or IActiveDesktop and you'll find examples of how to do this from managed C#, many examples right here on StackOverflow.
Bonus: of course Raymond Chen has a blog on this topic: How do I put a different wallpaper on each monitor?.
I use UI Spy and Spy++ to view windows text of some windows, but none offers a result. As people said, some windows are built up and executed by some components, say they are embedded inside those components. Except the two tools to view the window handles, text, could you introduce me other tools or ways to get a window text or handle without using hooks ?
Edit: I also use Spy Object to retrieve windows objects information and search from ancestors till I can meet the right object but this tool to the particular windows I am watching is incapable to do the job because it also reports incorrect parents positions in ancestor hierarchy, I try out the MAAS and UI-Automation without luck, Thank you for you help.
Edit3: I don't like their windows'ideas of internal designs (I mean only they-designers- know how to untie the knots)
Usually the Accessibility APIs are used, the ones used for text-to-speech screen readers for blind users. In your question you mentioned MAAS, did you mean MSAA (Microsoft Active Accessibility)? If not, that's where I'd look next.
http://white.codeplex.com/ is a great framework which does such things.
White is a framework for automating rich client applications based on Win32, WinForms, WPF, Silverlight and SWT (Java) platforms. It is .NET based and does not require the use of any proprietary scripting languages. Tests/automation programs using White can be written with whatever .NET language, IDE and tools you are already using. White provides a consistent object-oriented API, hiding the complexity of Microsoft's UIAutomation library (on which White is based) and windows messages. Only stable versions of White are released, so all releases are production-ready.
I'm interested in creating a UPnP control point in Silverlight. To me that implies that I'll need to use COM interop with Microsoft's upnp.dll (and the SL application will have to be out of browser and platform specific). Is there any source code available in C# that shows how to create a control point with Microsoft's stack? If there are other options available I'd like to hear about it, from reading around the web it appears the MS stack is buggy.
Here is something I stumbled upon today. Maybe it's still a help.
http://www.codeproject.com/KB/IP/upnplib.aspx
A VB.NET example, though no C#, it looks interesting too:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=6104&lngWId=10
What are the limitations of WPF web browser control? Is it good enough for a real-life browser implementation? And is it a fully managed implementation?
The WPF WebBrowser control is just an interop layer hosting the IE ActiveX control. It should be very robust, and usable for a real-life browser (since it's really IE). It is not a managed implementation.
Its main limitations are due to the fact that it's using an HwndHost internally. This means that it has the WPF/Native airspace issues, as well as some minor issues with event handling.
It is good enough for Real-life use, and I agree with Reeds view on the matter.
Additionaly, If a person does not have certain IE files on their computer the control is rendered useless. Here are a few observed limitations I have found:
I have found with the WebBrowser controls is it's hatred of IE6 on a computer whilst trying to perform JavaScript insertions within the control. (Very machine-specific though, so you could say lack of total compatibility?)
The fact that you will need to actually reference the main assemblies of IE to get certain functionality, such as getting something more useful than a HtmlElement.
The lack of support for some of its 2.0 counterparts functions, such as to Suppress Script Errors.
Doesn't work nicely with the WPF layout system
Again due to the fact that its a wrapper for IE, all the compatibility issues in things like CSS stay put, as well as most, if not all the IE issues that exist.
All in all, the control could be greatly improved, and to honest it would be fantastic to see the .NET team make a fully managed version of this component.
Cheers,
Kyle
Adding to the answers by #Kyle and #Reed, below are my observations as limitations.
We can't render PDF in this WebBrowser control.
Underneath engine is IE. We can't replace IE engine with latest Microsoft Edge.
I've been using Google's Annotated Time Line Visualization component for the last couple of weeks and I love it! I've been able to make plots with about 10k points without much trouble.
Do you know of a desktop component I could plug into my application that delivers the same WOW factor that Google's component does? I don't care what the language/toolkit is. I prefer C#,Java,Ruby,C++ or Python... (in that order) however any other's would apply. I also prefer it to be free and open source, but if it's not that's OK as well.
Thanks for your time!
Note: This doesn't have to be cross-platform. Windows is fine.
Edit (2009-08-07):
Even if I can only plot 10k points, I am fine with that. I would just like a desktop control that delivers the same "wow" factor and works in a similar manner (zooming, scrolling, annotations, etc) that the Google component does.
Edit (2009-09-03):
I really prefer the language to be C#. I started a bounty to see if anyone can find some good ones. I want it to be almost identical to Google's Annotated Timeline Component. I would use Google's Component, but I want a desktop component... and I don't want to run into performance limitations because of the browser. Using Adobe Air is out of the question.
Edit (2009-09-03):
Do not recommend Visifire. I have evaluated it, and it doesn't support zooming. Remember, it must be very close to Google's component in terms of functionality and "wow" factor.
This WPF-based chart control at codeproject may put you in the right direction. It's got smooth panning/zooming/scrolling :
WPF Chart Control With Pan, Zoom and More By John Stewien
If you're needing to plot millions of points, you're going to run into performance issues quickly if the control doesn't have a mechanism for loading/sampling only what it needs to display. Even then, that's a very large number of data point to want to access in one control.
Hm i am not sure if this is what you are looking for, but for java there is the very good library JFreeChart which is not exactly as interactive as the one you mentioned but it is really easy to use and pretty flexible for you to subclass and tweak to your preference.
Perhaps you could take a look at matplotlib. It's a python based library, however it's very flexible in that it can take it's input from a variety of sources.
An alternative is to embed a web browser control in you wpf application. You'll probably need access to the DOM, so you might have to use the WebBrowser in a WinForm. A good article descibing how this is done can be found here.
Microsoft also has free chart control you can get at http://www.microsoft.com/downloads/details.aspx?FamilyId=130F7986-BF49-4FE5-9CA8-910AE6EA442C&displaylang=en. It's pretty good--especially for being free.
I have used Dundas charts in the past. They are excellent but pricey. There are several other vendors with good chart controls including DotNetCharting, Telerik, Component Art, and Infragistics.