Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

GDI + Hang + GUIRegisterMsg

$
0
0

Hi guys,

this script is important to me and has a problem that I do not know how to explain:

AutoIt         
#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3>   Global $hGUI, $hGraphics, $hBackbuffer, $hBitmap, $hPen1 Global $iW = 100, $iH = $iW   T1()   Func T1()  HotKeySet("{DEL}", "T2")  _GDIPlus_Startup()  $hGUI = GUICreate("Test", $iW, $iH, 10, 10, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))  GUISetState()  $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)  $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)  $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)  _GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)  DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "handle", $hBackbuffer, "int", 3)  $hPen1 = _GDIPlus_PenCreate(0xFF800010, 4)  GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")  Draw()  GUIRegisterMsg($WM_TIMER, "Draw") ;$WM_TIMER = 0x0113  DllCall("User32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", 500, "int", 0)  While 1   Sleep(100)  WEnd EndFunc   ;==>T1 Func Draw()  _GDIPlus_GraphicsClear($hBackbuffer, 0xFFFFFFFF) ;needed for transparent images  _GDIPlus_GraphicsDrawEllipse($hBackbuffer, 25, 25, 6, 6, $hPen1)  _WinAPI_RedrawWindow($hGUI) EndFunc   ;==>Draw   Func WM_ERASEBKGND($hWnd, $Msg, $wParam, $lParam)  _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iW, $iH)  Return True EndFunc   ;==>WM_ERASEBKGND   Func _Clean()  GUIRegisterMsg($WM_TIMER, "")  GUIRegisterMsg($WM_ERASEBKGND, "")  _GDIPlus_PenDispose($hPen1)  _GDIPlus_BitmapDispose($hBitmap)  _GDIPlus_GraphicsDispose($hBackbuffer)  _GDIPlus_GraphicsDispose($hGraphics)  _GDIPlus_Shutdown()  GUIDelete($hGUI) EndFunc   ;==>_Clean   Func T2()  HotKeySet("{DEL}")  _Clean()  $hGUI = GUICreate("Form1", 250, 250, -1, -1)  GUISetState(@SW_SHOW)  While 1   $nMsg = GUIGetMsg()   Switch $nMsg    Case $GUI_EVENT_CLOSE     _Clean()     T1()   EndSwitch  WEnd EndFunc   ;==>T2

 

 This is only a "stripped" part of code

I need to swith between the normal gui and the gdi gui, the problem are:

- If i switch 11 times ( yes, every eleven times, slow, fast doesn't matter! ) the WM_ERASEBKGND not work anymore, i don't see the GDI but only the bk of the GUI:

Before:

2v2jdhu.jpg

After:

35iqbz6.jpg

 

I have this issue only on XP

- The most important, sometimes during a switch ( it's totally random, can be the first, the fourth i don't know ) the second GUI T2() HANG, i need to close it in task manager. In the event viewer i see error 1002. I don't have any error by autoit. I have this problem both on Xp and 7, compiled or not.

 

I HOPE i have make some mistake in the code, i really don't have idea.

Thanks as always


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>