Leider flackert das Ganze
Es sollte jedoch möglich sein einen zusätzlichen Buffer (DoubleBuffering)
zu verwenden.
Leider weiß ich nicht wie das Umzusetzten ist und hab bisher nur Beispiele
mit GDI gefunden.
Wie würde das mit GDI+ aussehen ?
Hier mein flackernder Testcode:
Code: Alles auswählen
Import "gdiplus.lib"
GdiplusStartup(*Token,*Input,*Output)
GdiplusShutdown(*Token)
GdipCreateFromHDC(HDC.i,*Graphics)
GdipDeleteGraphics(*Graphics)
GdipCreateSolidFill(Color.i,*Brush)
GdipCreatePen1(Color.i,Width.f,Unit.i,*Pen)
GdipDeletePen(*Pen)
GdipDeleteBrush(*Brush)
GdipFillRectangle(*Graphics,*Brush,X.f,Y.f,Width.f,Height.f)
GdipDrawRectangle(*Graphics,*Pen,X.f,Y.f,Width.f,Height.f)
EndImport
Structure GdiplusStartupInput
GdiplusVersion.i
*DebugEventCallback
SuppressBackgroundThread.i
SuppressExternalCodecs.i
EndStructure
Enumeration
#UnitWorld
#UnitDisplay
#UnitPixel
#UnitPoint
#UnitInch
#UnitDocument
#UnitMillimeter
EndEnumeration
Procedure.i WindowProc(Window.i,Message.i,wParam.i,lParam.i)
Protected PS.PAINTSTRUCT
Protected Graphics.i
Protected Pen.i
Protected PenRed.i
Protected Brush.i
Protected ii.i
Static i.f = 50
Select Message
Case #WM_PAINT
i + 0.5
If i > 200
i = 50
EndIf
ii = i
BeginPaint_(Window,@PS)
If GdipCreateFromHDC(PS\hdc,@Graphics) = #S_OK
If GdipCreatePen1($FF0000000,2,#UnitPixel,@Pen) = #S_OK
GdipCreatePen1(ii | $FFFF000F,i/10,#UnitPixel,@PenRed)
GdipCreateSolidFill($FF000000,@Brush)
GdipFillRectangle(Graphics,Brush,0,0,400,400)
GdipDrawRectangle(Graphics,PenRed,50,50,i,i)
GdipDeleteBrush(Brush)
GdipDeletePen(Pen)
EndIf
GdipDeleteGraphics(Graphics)
EndIf
EndPaint_(Window,@PS)
InvalidateRect_(Window,#Null,#Null)
Sleep_(1)
ProcedureReturn 0
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
Procedure.i Window()
Protected Window.i
Protected Event.i
Protected GDI_Startup.GdiplusStartupInput
Protected GDI_Token.i
Window = OpenWindow(#PB_Any,#Null,#Null,400,400,"GDI-Test",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
If Window
GDI_Startup\GdiplusVersion = 1
GDI_Startup\SuppressExternalCodecs = #True
If GdiplusStartup(@GDI_Token,@GDI_Startup,#Null) = #S_OK
SetWindowCallback(@WindowProc())
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
EndIf
EndIf
EndProcedure
Window()