简体   繁体   中英

How to write Windows 7 gadget in C#?

How can I use C# to write a gadget in Windows 7?

Is it possible?

Is Sidebar gadgets what you are looking for?

Have a look at this Silverlight trick!

Assuming that "Windows Sidebar Gadgets" are being talked about, this is not possible to do directly . However there are some work-abouts (none of which are supported by Microsoft):

  1. Use Silverlight . However, as I recall, the background can't be "painted transparent" and this will not work with a 64-bit IE (the IE running gadgets isn't always 32-bit by default) as there is no 64-bit Silverlight. This is the same problem plaguing sidebar gadgets that use Flash. (Like Pandora, one could require avid users to launch the 32-bit version of sidebar.exe).

  2. Wrap the gadget window. I started work on a project like this that allowed WPF (in a separate process) to "overlay" the gadget window -- started via COM. Avoids 32/64-bit issues (actually, doesn't matter since it's in a separate process and is CLR, not Silverlight). Some issues with default gadget border, sizing, properties, etc. Concept work only.

  3. Use an embedded HTA to launch a 32-bit IE and grab that handle (can then use/embedd Silverlight if launched the 32-bit version). I didn't have success with this, but it "should work".

  4. Use a converter like Script# -- write in C#, "compile" to JavaScript.

Happy coding.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM