I want to set my application to be on desktop level, like Windows Gadgets. Is this possible to achieve?
Thing is, i have borderless application I want to run on desktop.
I tried to find the option, but I found only "always on top" which is opposite of what I want to achieve.
The good old SetWindowPos supports a HWND_BOTTOM to place your application as the last one in the order.
To use it in C# take a look at PInvoke.Net.
Write the app so that it runs as a service in the background, then implement an actual Windows Gadget as a front-end?
i think there is no way to do it same way as always on top. do you want to run your application under icons? the only way to do a really background application is to replace explorer.exe, but then you will not see icons and task bar.
You can implement an actual Windows Gadget using WPF by creating an XBAP. Just add a gadget.xml file and an .html file that contains only an IFRAME that loads the XBAP. That way your WPF application will actually be a gadget and will automatically follow all the rules.
Another option is to use Windows Sidebar Styler. This requires additional software to be installed alongside yours but also allows you to do things you can't do inside the XBAP sandbox without code signing certificates, user authorizaiton, etc.
A third option is to create a gadget that uses something recognizable in the HTML (such as a particular background color), then when your .exe starts up, scan for a hWnd under Explorer that has the attributes you are looking for, inject yourself into the Explorer.exe process, and set your window as a child of it.
A variation of the third option is to not inject into Explorer.exe but rather maintain your Z Index and location (using SetWindowPos) to track the Z Index and location of the hWnd you found.
So many choices...
Related
Gday,
I am currently doing a small Unity project where the game takes place on the desktop, we have a creature that communicates with the player. It is currently severely limited with how it acts/reacts due to the only way that I can figure out how to make popups in the windows system style is through the use of the MessageBox function which is Modal (it suspends the application from running until the MessageBox has been answered or closed).
So I was wondering if there was any way to get the same effect without it suspending the entire application, I've tried looking into Forms however I can't get it to recognise it as a thing in VisualStudios. I have also looked at GUI.Window however doesn't create a window that looks like a Windows style popup.
What do yall reckon?
(Thankyou in advance)
In general, trying to mix Unity and WinForms is a really bad idea. They were built around completely different design philosophies and if you keep going down this path, they're going to keep fighting each other.
The best option here would be to create your own lookalike windows in-game. That would require quite a bit of work and infrastructure to set up at the beginning, but it would also give you full control over the style and behaviour of the dialogs.
Browse the asset store for assets that solve the problem for you. There are a number of dialog type assets you can grab and plug into your unity project to get you running quickly. A lot of them mimic windows features like moving around, scrolling or X to close.
I would like to make an application by wpf which could overlay a specific windows application.
It means, when I run my application and specify Notepad as target application. At that time, anytime Notepad application got focus, my application will take over the focus & prevent user handle directly Notepad.
It is quite simple in case of 2 windows in same application ( we can set owner of child window & showdialog)
So, I wonder that if it is possible to get the handle of window of other application to set owner for our application.
Thanks for any comments or discussion!
In the general sense, yes - it's possible. But you will have to use Platform APIs in order to obtain the handle of Windows that are not in your process.
Here's a list of Window-related Functions in the Win32 Platform API
You may then by able to make your WPF window appear on top of the other window. But just know that depending on your end goal this might not be the best way to achieve your desired results!
I am interested to know how can I do the same thing that the apllication listed below does:
Start Menu Calculator
I want to know how can I create an custom tab in Start Menu Search and then handle it with my WPF application. It should only be enabled until my application is running.( Just like what The calculator does )
I read something about windows API Code Pack and I downloaded it but I don't know how can I use it. I searched through it but I didn't find anything.( If you know how I could do this using with Windows API Code Pack, please write an example that explains how to do it in C#)
The main exe "Start Menu Calculator.exe" installs a windows hook (using SetWindowsHookEx) into explorer.exe. The hook is implemented as usual in SBLib.dll which is then injected into Windows Explorer's memory space.
This hook searches for window handles belonging to the search box. See a discussion around this here:
How do I get a "handle" on the Windows Search textbox? and probably sub classes the search box windows (if you kill the "Start Menu Calculator.exe" process abruptly, it crashes Windows Explorer too... which kinda confirms this)
It then reacts to key presses, and I suppose it butchers up the result window. In the hierarchies of Windows, I think it's a Window named "Desktop Search Open View", you can get to it with SPY++ under "Start Menu", aside the windows mentioned in the msdn forum above.
So, no nice API behind this nice application. Massive hacks instead :-)
I think however, some level of integration is possible, using documented behavior, with the search box. I have not dug further, but there is the notion of federated search in Windows (Windows 7 Federated Search). I don't see if this would be capable of reacting instantaneously to what the user types in though...
As a side note, if you're also looking for a way to run javascript code from C#, there is a question here on SO that says it all: parse and execute JS by C#
When making Start Menu Calculator I initially tried to use federated search and Managed (.NET) code however you can't integrate into the start menu, only the shell search (for web service based search which lets you return custom results based on a search string). The problem is that the federated search is structured such that all the search data is pre-indexed so for the calculator to work I would have had to pre index every possible calculation! The reason it all works this way is to make sure that clicking the start menu is always fast and responsive (you don't want a web service call everytime you press start in the shell).
I ended up hiring someone to write a native windows app that places a IE control into the Start menu search area and passes the searched text in with the source. All the visual stuff is just css made to look like the start menu rendering and the calculations handled in javascript.
So yes, a bit of a hack but it seems to work and I havent had/heard of any crashing issues so far.
Is it possble to Modify the Window's Login screen and add our own buttons/links? For example is it possible to do something like this?
alt text http://www.allaboutmoss.com/wp-content/uploads/2010/04/windowsxp_login.jpg
The above screen has a link and when clicked it should start a win forms application?
For Windows XP, you can build a GINA DLL, and for Vista+ you need to use the new credential providers system. In both cases, you basically have to build the UI from scratch and so it's not really possible to just take the existing UI and add a few controls here and there.
Of course, you could build your own GINA DLL that displays UI that's the same as the standard Windows XP one, with your own additions, but it's not exactly a simple task.
How to put a C# programm (ex WPF or WF) under desctop Icons (like a wallpaper)?
I want my Old Good XP Active Desktop made by a some open source C# programm on my Win 7!)
Something like this - Fences .
They have there "windows" appearing underneath icons. I do not want to manage Icons - just put my window under them... BTW any one knows about such operations in other OS’s (Mac etc)?
And I DO NOT WANT TO MANAGE ALL THE ICONS ON MY OWN LIKE bumptop
I think it is quite possible, try this:
Find handle to window with the class "Progman".
Create some window in your application (or, perhaps, in some separate application, you will see the purpose later) and turn off its borders.
Set the parent of the newly created window to desktop handle.
Set the parent of "Progman" window you have found previousely to the window you created.
Desktop will be put on a window owned by your application and it will be possible to manipulate it in the way you want (namely, put something under it).
Also, do not forget to restore desktop's parent when application owning it is closed.
Look for FindWindow, GetClassName and SetParent at http://www.pinvoke.net/
Short answer is you can't really do it (in managed C# anyway). If it's possible, you would need to use Interop, and you'd likely be calling something that Windows doesn't offer as an API.
... although... as Ole Jak mentioned, Stardock looks to be doing it somehow...
The desktop is its own contained item. The same process handles the icons and the wallpaper "behind" those icons.
You are allowed to change the wallpaper to a different image, and you used to be able to create an Active Desktop where HTML content would be displayed, but this was discontinued in Vista.
What are you actually trying to do? Maybe there's another way to achieve a similar result?
There was DreamScene for vista. You could put a video as explorer background. I dont know if you could run a C# program to output the background video.