Thursday, October 13, 2011 4:33 PM
I was wondering if there was documentation about how to make a desktop app "always on top" (this is easy) but also always on top of Metro (like Inspect and Task Manager do).
This is useful for tools that have to be written for the desktop (because of full access to the Win32 API) but that can be relevant in Metro mode.
- Moved by Marilyn-Support EngineerMicrosoft Support Thursday, October 13, 2011 5:00 PM Moved to appropriate forum (From:Windows Developer Preview: General OS questions )
Thursday, October 13, 2011 4:59 PMHello Christian Gavin,
This thread was created in the Windows Developer Preview: General OS forum; the Microsoft Moderation team has moved this thread to the
Tools for Metro Style Apps forum.
Thursday, October 13, 2011 8:49 PMModerator
The application needs to be flagged with accessibility privileges with UIAccess. See: http://msdn.microsoft.com/en-us/library/ms742884.aspx .
This should be reserved for accessibility applications and very targeted test tools. It should not be used for general purpose applications.
Thursday, October 13, 2011 11:38 PM
Thanks, that is exactly what I need!
Friday, October 14, 2011 5:36 PM
I changed the manifest to have UIAccess="true" and require administrator, created a private test certificate, signed the application with that certificate, put it in a location under Program Files, and ran it, but it is still not the topmost application when running Metro.
The dialog box has the "TopMost" style.
Is there anything else I missed to make my application appear on top of Metro (like Task Manager does)?
Thursday, October 27, 2011 12:03 AMModerator
There isn't anything else that needs to be done (my test project was just the standard Win32 Project wizard app plus WS_EX_TOPMOST). I suspect that the app wasn't manifested and signed properly. The cert needs to tie back to a trusted root, so you would need to make sure your test cert was trusted; however, if it weren't there would be an error that "A referral was returned from the server". If you didn't see that, then the problem was more likely in the manifest. Here's how I created my test project:
- Create new Win32 Project
- Finish the wizard with no changes
- Change the CreateWindow call to CreateWindowEx and set WS_EX_TOPMOST
- Go to Project.Properties... Linker.Manifest File
- Change UAC Bypass UI Protection to: Yes (/uiAccess='true')
- Use signtool to sign the test app
- Copy the test app into Program Files
- Run test app
- Bring up the Start screen -> test app is on top
Thursday, October 27, 2011 9:10 AM
Very helpful. thanks.
I verified this works. Just curious why need to copy the exe file to program files folder. Withouth this copy work, the app runs but can not on top of metro style apps.
Thursday, October 27, 2011 4:10 PMModerator
UIAccess apps run with special privileges and must be trusted by the system. Because of that they must run from a location which normal users cannot write to. See http://msdn.microsoft.com/en-us/library/ms742884.aspx for more detail.
Again, these features should be used with care and restricted to accessibility applications and very targeted test tools. Any application using UIAccess should go through a vigorous security review. UIAccess is not appropriate for general purpose applications.
- Marked As Answer by Dan RuderMicrosoft Employee, Moderator Thursday, October 27, 2011 6:12 PM
Thursday, February 02, 2012 11:04 AMHi Rob, I'm implement this function in VS2011 with C#. My step is: 1. create a WinForm project 2. pinvoke CreateWindowEx with WS_EX_TOPMOST style 3. add manifest file for this project 4. change level='highestAvailable' uiAccess='ture' 5. sign the assembly in properties window 6. compile and copy to program file directory but cannot run .exe, could you send me your source code and tell me how to operate in .NET ? Thanks in advance Best regards Chenxu
Monday, February 13, 2012 8:01 PM
We have a .NET app that has a window that needs to be able to go on top of the Metro UI. The window is defined in XAML with the TopMost property set to true. The assembly has an app.manifest embedded requesting uiaccess, and is signed properly. I launch the app from a folder under C:\Program Files (x86)\. Inspecting the window with Spy++ shows that it does indeed have the WS_EX_TOPMOST attribute. Inspecting the process security with process explorer shows that it was granted uiaccess appropriately.
However, when the window is shown, it causes the metro UI to go away. If I bring the Metro UI back up by pressing the Win key, the window does not show on top of the metro UI. Any ideas as to why this does not work?
Monday, February 20, 2012 10:35 PMAny update on this? We are still unable to get our .NET app on top of metro, even with UI access.
Wednesday, February 29, 2012 10:17 PM
How's how I got it working. Note that you'll lose debug capability in the IDE.
- The application must demand uiAccess (app.manifest)
- The application must assert “topmost” window positioning (either in Win32/SetWindowPos or WinForms/WPF’s “Topmost” property, programmatically or otherwise)
- Without making changes to the group policy setting, it must be installed to some trusted location [C:\Windows, C:\Program Files, C:\Program Files (x86)].
- Note: If you want to be able to run it out of an arbitrary location, you must disable the security setting: “User Account Control: Only elevate UIAccess applications that are installed in secure locations”.
- Note2: This is the same as setting HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\ValidateAdminCodeSignatures to 0
- Said application cannot be ran in the debugger
- If it’s a .NET application
- The manifest must be embedded in a post-build step
- The application must have “delayed signing” (meaning it cannot be ran from the built-in debugger, although you can build and attach – this is what Microsoft does)
- The application must be signed with a trusted certificate.
- Said trusted certificate must be installed to the Trusted Root Certificate Authority (this is important! It must not just simply installed)
Hope this helps.
Monday, April 16, 2012 2:50 PM
I follow you and success to write a desktop app(WPF) on top of metro. But I met a problem: if I set "this.ShowInTaskbar = false", my desktop window can not show on top of metro. Why and How to solve this issue? Please help!!
Monday, April 16, 2012 6:44 PMModerator
That probably has something to do with how the ShowInTaskbar property is implemented. My guess is that it sets the owner to a hidden window, but you should ask this on the WPF forum (I moved your duplicate post there).
I'm locking this thread since it is off-topic and keeps getting further off-topic posts added to it.
Please post questions about developing desktop apps in the Windows Desktop Developer Forums. Please post questions specific to the various .Net frameworks in those dedicated forums.