fb:porticula NoPaste
bild eines anderen fensters anzeigen
Uploader: | frebas |
Datum/Zeit: | 11.10.2010 11:18:25 |
#include once "windows.bi"
#include once "file.bi"
Declare Function CaptureWindow( ByVal hwndSrc As HWND) As Any Ptr
Screen 16
'COLOR &hFF8000, &h000040
cls
Dim As Any Ptr bild
bild = ImageCreate(48, 48)
Dim fenster As HWND
Dim Shared hInstance As HINSTANCE
fenster = FindWindow("shell_traywnd", "")'taskleiste
fenster = FindWindow(StrPtr("shell_traywnd"), "")
fenster=GetActiveWindow
Print fenster
Do
Cls
'bild = CaptureWindow(fenster)
Paint bild, (1,1)
Pset bild,(1,1)
Put (10, 10), bild
Sleep 1000,1
Loop Until InKey="q"
Function CaptureWindow( ByVal hwndSrc As HWND) As Any Ptr
SetForegroundWindow(hWndSrc)
Sleep 30 'SetForegroundWindow etwas Zeit geben
Dim As RECT r
GetWindowRect(hWndSrc, @r) 'Fenstergroesse feststellen
Dim As Integer b = r.right - r.left
Dim As Integer h = r.bottom - r.top
Dim As Any Ptr img = ImageCreate(b, h)
b = (b+3) and -4 'Bildbreite glatt durch 4 teilbar
Dim As HDC hdcSrc = GetWindowDC(hWndSrc)
Dim As HDC hdcMem = CreateCompatibleDC(hdcSrc)
Dim As HBITMAP hBmp = CreateCompatibleBitmap(hdcSrc, b, h)
SelectObject(hdcMem, hBmp)
BitBlt(hdcMem, 0, 0, b, h, hdcSrc, 0, 0, SRCCOPY)
Dim As BITMAPINFO bmi
With bmi.bmiHeader
.biSize = SizeOf(BITMAPINFOHEADER)
.biWidth = b 'breite
.biHeight = -h '-hoehe (sonst Kopfstand)
.biPlanes = 1
.biCompression = BI_RGB
.biBitCount = 32
End With
If (img) Then 'Bilddaten in das Image kopieren
GetDIBits(hdcMem, hBmp, 0, h, img + 32, @bmi, DIB_RGB_COLORS)
End If
DeleteObject(hBmp)
DeleteDC(hdcMem)
ReleaseDC(hWndSrc, hdcSrc)
Return img
IMAGEDESTROY img
End Function