What is the Aero function for previewing the screen state behind a window?

China☆狼群 提交于 2019-12-04 08:51:28
nanda

As I understand you want to get the state (in terms of the display) of the windows behind your application. You can achieve it by doing the following,

HWND hwnd_behind = GetNextWindow(your_window_handle, GW_HWNDNEXT);

HDC hdc = GetWindowDC(hwnd_behind);

RECT rect;
GetWindowRect(hwnd_behind,rect);

HDC bitmap = MakeABitMapDC();

StretchBlt(bitmap,0,0,dW,dH,hdc,0,0,rect.width,rect.height,SRCCOPY);

You can plug this code into handlers which returns the bitmap when windows asks applications for a preview bitmap.

Left the details like "MakeABitMapDC" for the sake of brevity.

I am lost is kinda a big area to see what you don't understand but I will try anyway.

If mean that you don't know what the parameters do in the:

[DllImport ("dwmapi.dll" Entry Point = "# 113", SetLastError = true)] 
internal static external DwmpActivateLivePreview uint (uint a, IntPtr b, uint c, uint d); 

It is basically like this:

  • a: Is the parameter for activating Aero Peek.
  • b: Is the handle the AeroPeek focusses too.
  • c: Is a tricky one. If you pass a handle of a window to that parameter and the TopMost property is set it will appear on top of the AeroPeek.
  • d: I have no idea what d does but the times i have used DwmpActivateLivePreview I always put it on 1.

So the signature is like this:

internal static extern uint DwmpActivateLivePreview(uint active, IntPtr handle, IntPtr onTopHandle, uint d);

The DwmpStartOrStopFlip3D method activates the "Windows + Tab" effect.

[DllImport("dwmapi.dll", EntryPoint = "#105", SetLastError = true)]
internal static extern bool DwmpStartOrStopFlip3D();

Remember though that there is a reason that they are undocumented since they were not meant for us to use them.

If by chance you want to have the Aero Peek effect inside your application you can look at the DwmSetIconicLivePreviewBitmap function located in DWM.

More information here: MSDN: DwmSetIconicLivePreviewBitmap function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!