Hallo allerseits,
ich habe nach lngerer Pause noch mal versucht mich des leidigen Flickerproblems anzunehmen, leider ohne Erfolg. Es geht darum dass nornamle Labels, sofern sie nur bei einer bestimmten Bedingung angezwigt werden, soolen, bei Refresh einen unschönen Hintergrundblock anzeigen. Dieses liegt wohl anscheinend daran, dass das Hintergrundbild über das Label rübergezeichnet wird. So richtige brauchbare Lösungen habe ich leider bisher nicht gefunden, ausser dass hier mit einem entsprechenden Redraw gearbeitet werden muss. Bei einer If Beding bekomme ich das leider nicht hin, da zeigt er mir erst gar nicht das Hintergrundbild. Vielleicht hat einer eine etwas saubere funktionsfähige Lösung. In diesem Beispiel soll ein Label eingeblendet werden, wenn der Speicher einen bestimmten Wert unterschritten hat.
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <GDIPlus.au3>
#include <MemoryConstants.au3>
_GDIPlus_Startup()
Const $BKGND_FILE = "C:\Users\user1\Pictures\bg\19542_en_1.jpg"
Local $hImage_Bg = _GDIPlus_ImageLoadFromFile($BKGND_FILE)
Local $hTexture = _GDIPlus_TextureCreate($hImage_Bg)
Global $RamLabel, $ramfree
Global $PageFreeLabel, $PageFree
Global $LabelRamknapp = " "
;GUI
Global Const $iW = 800, $iH = 600
$hMain = GUICreate("Test", $iW, $iH)
GUISetBkColor(0x2C6135)
$lblTime = GUICtrlCreatePic("", 0, 0, $iW, $iH)
GUICtrlSetState(-1, $GUI_DISABLE)
;_CheckAvlRam()
GUISetState(@SW_SHOW, $hMain)
AdlibRegister("_CheckAvlRam", 1000)
;Mainloop
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then
_GDIPlus_BrushDispose($hTexture)
_GDIPlus_ImageDispose($hImage_Bg)
_GDIPlus_Shutdown()
GUIDelete()
Exit
EndIf
WEnd
;AdlibRegisterFunktion
Func _CheckAvlRam()
global $aMemStats = MemGetStats()
global $ramfree = Round($aMemStats[$MEM_AVAILPHYSRAM]/1024/1024, 2)
if $ramfree < 8 Then
_showLabel()
else
endif
Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap)
Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hGfx, 4 + (@OSBuild > 5999))
_GDIPlus_GraphicsSetTextRenderingHint($hGfx, 3)
_GDIPlus_GraphicsFillRect($hGfx, 0, 0, $iW, $iH, $hTexture)
Local Const $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
GDIPlus_BrushDispose($hBrush)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_FontDispose($hFont)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_GraphicsDispose($hGfx)
Local Const $hBitmap_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
_GDIPlus_BitmapDispose($hBitmap)
_WinAPI_DeleteObject(GUICtrlSendMsg($lblTime, 0x0172, 0x0000, $hBitmap_GDI)) ;$STM_SETIMAGE = 0x0172, $IMAGE_BITMAP = 0
_WinAPI_DeleteObject($hBitmap_GDI)
EndFunc ;==>_CheckAvlRam
Func _ShowLabel()
Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hGfx, 4 + (@OSBuild > 5999))
_GDIPlus_GraphicsSetTextRenderingHint($hGfx, 3)
_GDIPlus_GraphicsFillRect($hGfx, 0, 0, $iW, $iH, $hTexture)
Local Const $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
Local Const $hFormat = _GDIPlus_StringFormatCreate()
Local Const $hFamily = _GDIPlus_FontFamilyCreate("Arial")
Local Const $hFont = _GDIPlus_FontCreate($hFamily, 50)
Local Const $tLayout = _GDIPlus_RectFCreate(0, 0, $iW, $iH)
_GDIPlus_StringFormatSetAlign($hFormat, 1)
_GDIPlus_StringFormatSetLineAlign($hFormat, 1)
_GDIPlus_GraphicsDrawStringEx($hGfx, StringFormat("Ram bald voll"), $hFont, $tLayout, $hFormat, $hBrush)
EndFunc ;==>_CheckAvlRam
Alles anzeigen
Danke schon mal im Voraus
lg