(window Window)
| 568 | } |
| 569 | |
| 570 | func hBitmapFromWindow(window Window) (win.HBITMAP, error) { |
| 571 | hdcMem := win.CreateCompatibleDC(0) |
| 572 | if hdcMem == 0 { |
| 573 | return 0, newError("CreateCompatibleDC failed") |
| 574 | } |
| 575 | defer win.DeleteDC(hdcMem) |
| 576 | |
| 577 | var r win.RECT |
| 578 | if !win.GetWindowRect(window.Handle(), &r) { |
| 579 | return 0, newError("GetWindowRect failed") |
| 580 | } |
| 581 | |
| 582 | hdc := win.GetDC(window.Handle()) |
| 583 | width, height := r.Right-r.Left, r.Bottom-r.Top |
| 584 | hBmp := win.CreateCompatibleBitmap(hdc, width, height) |
| 585 | win.ReleaseDC(window.Handle(), hdc) |
| 586 | |
| 587 | hOld := win.SelectObject(hdcMem, win.HGDIOBJ(hBmp)) |
| 588 | flags := win.PRF_CHILDREN | win.PRF_CLIENT | win.PRF_ERASEBKGND | win.PRF_NONCLIENT | win.PRF_OWNED |
| 589 | window.SendMessage(win.WM_PRINT, uintptr(hdcMem), uintptr(flags)) |
| 590 | |
| 591 | win.SelectObject(hdcMem, hOld) |
| 592 | |
| 593 | return hBmp, nil |
| 594 | } |
| 595 | |
| 596 | // hBitmapFromIcon creates a new win.HBITMAP with given size in native pixels and DPI, and paints |
| 597 | // the icon on it stretched. |
no test coverage detected
searching dependent graphs…