Home > Net >  The simulator screenshots problems
The simulator screenshots problems

Time:09-18

Screen shot down cut a piece of this no problem,
But I think the window is not in the front, and screenshots of the emulator window,
Window class is qt5qwindowicon

Online to find the methods used, the second sentence results to NULL
Public static Bitmap GetWindow (IntPtr hWnd)
{
IntPtr HSCRDC=GetWindowDC (hWnd);
The Control Control=Control. FromHandle (hWnd);//the control here is NULL, the other can't perform,
IntPtr hbitmap=CreateCompatibleBitmap (HSCRDC, control the Width and the control, Height);
IntPtr hmemdc=CreateCompatibleDC (HSCRDC);
SelectObject (hmemdc hbitmap);
PrintWindow (hWnd, hmemdc, 0);
Bitmap BMP Bitmap=. FromHbitmap (hbitmap);
DeleteDC (HSCRDC);//remove the used objects
DeleteDC (hmemdc);//remove the used objects
Return BMP.
}
  •  Tags:  
  • C#
  • Related