How can I use C# to write a gadget in Windows 7?
Is it pos开发者_JS百科sible?
http://www.codeproject.com/KB/gadgets/CPRepWindowsGadget.aspx
And a search on codeproject shows even more: http://www.codeproject.com/search.aspx?q=gadget&sbo=kw
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):
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).
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.
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".
Use a converter like Script# -- write in C#, "compile" to JavaScript.
Happy coding.
精彩评论