使用GDI+绘图时的一个问题
在使用GDI+绘图时使用了双缓冲,虽然绘制的时候不会出现闪烁,但是莫名其妙的是在你不做任何操作的时候Form_Paint事件居然会触发,导致了界面会出现闪烁,代码如下:
Option ExplicitPrivate Sub Form_Load() InitGDIPlus Timer1.Interval = 1 Timer1.Enabled = TrueEnd SubPrivate Sub Form_Paint() Debug.Print Time & ":paint"End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) TerminateGDIPlusEnd SubPrivate Sub Timer1_Timer() Dim gpsMemory As Long Dim bmpMemory As Long Dim bmpBackGround As Long Dim bmpMan As Long Dim bmpCompass As Long Dim Graphics As Long GdipCreateBitmapFromFile StrPtr("d:\2.jpg"), bmpBackGround GdipCreateBitmapFromFile StrPtr("d:\1.jpg"), bmpMan GdipCreateBitmapFromFile StrPtr("d:\compass.png"), bmpCompass GdipCreateBitmapFromScan0 Me.ScaleWidth, Me.ScaleHeight, 0, GpPixelFormat.PixelFormat32bppARGB, ByVal 0, bmpMemory GdipGetImageGraphicsContext bmpMemory, gpsMemory' GdipSetSmoothingMode gpsMemory, SmoothingModeAntiAlias GdipDrawImageRectI gpsMemory, bmpBackGround, 0, 0, Me.ScaleWidth, Me.ScaleHeight GdipDrawImageI gpsMemory, bmpMan, 0, 0 GdipDrawImageI gpsMemory, bmpCompass, 256, 256 GdipCreateFromHWND Me.hwnd, Graphics GdipDrawImage Graphics, bmpMemory, 0, 0 GdipDisposeImage bmpMemory GdipDisposeImage bmpBackGround GdipDisposeImage bmpMan GdipDisposeImage bmpCompass GdipDeleteGraphics gpsMemory GdipDeleteGraphics GraphicsEnd Sub