#INCLUDE "windows.bi"
#INCLUDE "win/gdiplus.bi"
Using GDIPLUS
Dim wc As WNDCLASSEX
Dim  msg As MSG
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
	Static As HDC compHdc,hdc
	Select Case uMsg
		Case WM_CLOSE
			DeleteDC(compHdc)
			PostQuitMessage(0)
		Case WM_CREATE
			Dim As PVOID GpGraphics,pen,path,brush
			Dim As GpPointF points(2)
			points(0).x=40:points(0).y=60
			points(1).x=50:points(1).y=70
			points(2).x=30:points(2).y=90
			hdc=GetDC(GetDesktopWindow)
			compHdc=CreateCompatibleDC(hdc)
			Var bitmap = CreateCompatibleBitmap(hdc,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN))
			SelectObject(compHdc,bitmap)
			DeleteObject(bitmap)
			ReleaseDC(GetDesktopWindow,hdc)
			GdipCreateFromHDC(compHdc,@GpGraphics)
			GdipGraphicsClear(GpGraphics,&hffffffff)
			GdipCreatePen1(&hffff0000,1,Unitpixel,@pen)
			GdipCreatePath(FillModeAlternate,@path)
			GdipAddPathArc(path,175, 50, 50, 50, 0.0, -180.0)
			GdipAddPathLine(path,100, 0, 250, 20)
			GdipStartPathFigure(path)
			GdipAddPathLine(path,50, 20, 5, 90)
			GdipAddPathCurve(path,@points(0), 3)
			GdipAddPathLine(path,50, 150, 150, 180)
			GdipClosePathFigure(path)
			GdipDrawPath(GpGraphics,pen, path)
			GdipCreateSolidFill(&hff0000c8,@brush)
			GdipResetPath(path)
			GdipAddPathLine(path,210, 210, 300, 240)
			GdipAddPathLine(path,300, 260, 230, 260)
			GdipAddPathRectangle(path,250, 235, 20, 40)
			GdipAddPathEllipse(path,210, 275, 40, 30)
			GdipDrawPath(GpGraphics,pen, path)
			GdipFillPath(GpGraphics,brush, path)
			GdipDeletePen(pen)
			GdipDeleteBrush(brush)
			GdipDeletePath(path)
			GdipDeleteGraphics(GpGraphics)
			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,compHdc,ps.rcPaint.left,ps.rcPaint.top,SRCCOPY)
			EndPaint(hWnd,@ps)
			Return 0
		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,325,355,0,0,wc.hInstance,0)

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