Рисование с прозрачностью в окне

Пример рисования (анимации) с прозрачностью с помощью библиотеки GDI+. 
Платформы: Windows
Автор: Станислав Будинов, создано в 2011 году.

прозрачность

#INCLUDE "windows.bi"
#INCLUDE "win/gdiplus.bi"
Using GDIPLUS
Dim wc As WNDCLASSEX
Dim  msg As MSG
Dim Shared WNDhdc As HDC
Dim ULONG_PTR_01 As ULONG_PTR
Dim GDIPLUSSTARTUPINPUT_01 As GDIPLUSSTARTUPINPUT
GDIPLUSSTARTUPINPUT_01.GdiplusVersion = 1
If (GDIPLUSSTARTUP(@ULONG_PTR_01, @GDIPLUSSTARTUPINPUT_01, NULL) <> 0) Then
    Print "FAIL"
Endif

Function WndProc(hWnd As HWND,uMsg As UINT,wParam As WPARAM,lParam As LPARAM) As Integer
    Dim ps As PAINTSTRUCT
    Dim GpGraphics As PVOID
    Dim pen As PVOID
    Dim brush As PVOID
    Static x As Single
    Select Case uMsg
        Case WM_CLOSE
            KillTimer(hwnd,1)
            DeleteObject(WNDhdc)
            End
        Case WM_CREATE
            Var hdc=GetDC(GetDesktopWindow)
            Var compHdc=CreateCompatibleDC(hdc)
            Var bitmap = CreateCompatibleBitmap(hdc,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN))
            SelectObject(compHdc,bitmap)
            DeleteObject(bitmap)
            ReleaseDC(GetDesktopWindow,hdc)
            WNDhdc=compHdc
            SetTimer(hWnd,1,10,0)
        Case WM_TIMER
            x+=0.5:If x>=150 Then x=0
            GdipCreateFromHDC(WNDhdc,@GpGraphics)
            GdipSetSmoothingMode(GpGraphics,SmoothingModeHighQuality)
            GdipGraphicsClear(GpGraphics,&hFFF00FFF)
            GdipCreatePen1(&hFF000000,4,UnitWorld,@pen)
            GdipDrawLine(GpGraphics,pen , 0, 0, 220, 220)
            GdipCreateSolidFill(&hB000FFD4,@brush)          
            GdipFillRectangle(GpGraphics,brush,x,x,50,50)
            GdipSetSolidFillColor(brush,&hC0FFFFFF )
            GdipFillRectangleI(GpGraphics,brush,20,50,170,100)
            GdipDeleteGraphics(GpGraphics)
            GdipDeletePen(pen)
            GdipDeleteBrush(brush)
            InvalidateRect(hWnd,0,0)
        Case WM_PAINT
            BeginPaint(hWnd,@ps)
            BitBlt(ps.hdc,ps.rcPaint.left,ps.rcPaint.top,ps.rcPaint.right-ps.rcPaint.left,ps.rcPaint.bottom-ps.rcPaint.top,WNDhdc,ps.rcPaint.left,ps.rcPaint.top,SRCCOPY)
            EndPaint(hWnd,@ps)
        Case Else
            Return DefWindowProc(hWnd,uMsg,wParam,lParam)
    End Select
End Function

With wc
    .hInstance=GetModuleHandle(0)
    .cbSize=SizeOf(WNDCLASSEX)
    .style=CS_HREDRAW Or CS_VREDRAW
    .lpfnWndProc=@WndProc
    .lpszClassName=StrPtr("class")
    .hCursor=LoadCursor(NULL,IDC_ARROW)
End With
RegisterClassEx(@wc)
CreateWindowEx(0,wc.lpszClassName,"DrawGDI+",WS_OVERLAPPEDWINDOW Or WS_VISIBLE,200,200,230,250,0,0,wc.hInstance,0)

While GetMessage(@msg,0,0,0)
    TranslateMessage(@msg)
    DispatchMessage(@msg)
Wend