I am trying to use the API for aero peek. With a lot of digging and searching I stumbled upon this piece of code:
[DllImport("dwmapi.dll", EntryPoint = "#113", SetLastError = true)]
internal static extern uint DwmpActivateLivePreview(uint , uint , uint , uint );
But I can't get it to work.. I don't know what the parameters are.. I tried some API intercepting tools but that didn't work out. How can I discover how to properly call this API?
Aero Peek: Hovering over a taskbar thumbnail shows a preview of the entire window. Aero Peek is also available through the "Show desktop" button at the right end of the taskbar, which makes all open windows transparent for a quick view of the desktop. A similar feature was patented during Windows Vista development.
On the system properties window that opens, click on Advanced at the top. Under Performance, click on Settings. Under Visual Effects, by default Enable Peek will be turned on. Uncheck the box to disable it, then click OK at the bottom to save the changes.
If you're running Windows 7, right-click on the taskbar and select Properties. You'll get a similar option “Use Aero Peek to preview the desktop” that allows you to enable or disable Aero Peek.
I eventually solved it my self. I have posted an article on my website about this: http://www.jesconsultancy.nl/tips-and-tricks/aero-apis.html. Unfortunately this is in dutch so here is a bit explaining:
[DllImport("dwmapi.dll", EntryPoint = "#113", SetLastError = true)]
internal static extern uint DwmpActivateLivePreview(uint switch, IntPtr hWnd, IntPtr c, uint d);
DwmpActivateLivePreview(1, Handle, topmostWindowHandle, 1);//activate
DwmpActivateLivePreview(0, Handle, topmostWindowHandle, 1);//deactivate
The first parameter is for activating/deactivating the Aero Peek functionality. The second parameter is the handle that Aero peek focuses to. The other two one I haven't been able to identify yet.
Edit: After some more messing around with this API I figured out the 3th parameter. When setting the TopMost property of a form, the form still shows sometimes underneath of the aero peek effect. If you pass the handle to that form that needs to be on top of the peek effect as the 3th parameter, and the TopMost property of your form is set to true, your form will be on top of the peek effect.
You can exclude a window from the Aero Peek effect. This is described here: http://huddledmasses.org/fun-with-pinvoke-and-aero-peek/
I know this is an older question but, the accepted answer lacks completeness.
Below is the proper usage of the Aero Peek API.
///<summary>
/// These flags are used in conjunction with the Aero Peek API.
/// </summary>
public enum PeekTypes : long
{
/// <summary>
/// This flag is here only for completeness and is not used
/// </summary>
NotUsed = 0,
/// <summary>
/// Denotes that the Peek API is to operate on the desktop
/// </summary>
Desktop = 1,
/// <summary>
/// Denotes that the Peek API is to operate on a window.
/// </summary>
Window = 3
}
/// <summary>
/// This is the *Almighty* Aero Peek API!
/// </summary>
/// <param name="EM">True if we're going into peek mode; False if we're coming out of it.</param>
/// <param name="PH">The handle of the window we want to put into peek mode;
/// IntPtr.Zero if we're coming out of peek mode or peeking on the desktop.</param>
/// <param name="C">The handle of the window calling the API method.</param>
/// <param name="pT">One of the <see cref="PeekTypes"/> enum members.
/// Pass <see cref="PeekTypes.Desktop"/> if you want to peek on the desktop and <see cref="PeekTypes.Window"/> if you want to peek on a window. <see cref="PeekTypes.None"/> is unused but, there for completeness.</param>
/// <param name="hPN0">When going into or out of peek mode, always pass new IntPtr(32) for this parameter.</param>
/// <param name="iFI0">When going into or out of peek mode, always pass 0x3244 for this parameter.</param>
/// <returns></returns>
[DllImport("dwmapi.dll", EntryPoint = "#113", CharSet = CharSet.Auto, PreserveSig = true, SetLastError = true, CallingConvention = CallingConvention.StdCall)]
static extern int InvokeAeroPeek(bool EM, IntPtr PH, IntPtr C, PeekTypes pT, IntPtr hPN0, int x3244);
I spent several months reverse engineering most of the cool Windows 7 taskbar API and this is part of my findings. Take it or leave it, this is the proper way to use the Aero Peek API. My "research" was done in 2008, while Windows 7 was still in beta and leaked preview builds were prevalent. For those that might give a shit, this code should work in Windows 8, too. A simple example follows, below:
InvokeAeroPeek(enterPeekMode, target, caller, pType, new IntPtr(32), 0x3244);
This code is processor agnostic, compile it however you want and it will still work. Win32 and x64 are both welcome.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With