Luigi Posted September 2, 2014 Share Posted September 2, 2014 (edited) Hi forum, I prefer build a GUI using $WS_EX_COMPOSITED, the double buffer show controls without flicker efect (sometimes), it's write? I try a new script, it use a GDIPlus with COMPOSITE, but some controls (label, button, input...) are not showed... In this little example, have a GUICtrlLabel below GDIGraphic... If mouse is over GDIGraphic, the label is painted with green. If mouse out of GDIGraphic, the label is painted with red. If you do not use COMPOSITE, the GUICtrlLabel is showed... If use COMPOSITE, the GUICtrlLabel is not showed... They (GDIPlus and COMPOSITE) work together? Or is better not use composite with GDIPlus? expandcollapse popup#AutoIt3Wrapper_AU3Check_Parameters= -q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #Tidy_Parameters=/sf #include <Array.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Opt("GUIEventOptions", 1) Opt("MustDeclareVars", 1) Opt("WinWaitDelay", 25) OnAutoItExitRegister("_EXIT_BEFORE") Global $hGui, $hCursor Global $hGraphic, $hPen, $hBitmap, $hBackbuffer Global $hLabel Global $aGui[5] = ["Title", 800, 600, Default, Default] Global $aGraphic[6] = [10, 10, 400, 300] $aGraphic[4] = $aGraphic[0] + $aGraphic[2] $aGraphic[5] = $aGraphic[1] + $aGraphic[3] Global Const $nPI = 3.1415926535897932384626433832795 Global $HOVER = False, $HOVER_OLD $hGui = GUICreate($aGui[0], $aGui[1], $aGui[2], $aGui[3], $aGui[4]) $hLabel = GUICtrlCreateLabel("", $aGraphic[0] - 1, $aGraphic[1] - 1, $aGraphic[2] + 2, $aGraphic[3] + 2, Default, $WS_EX_COMPOSITED) GUICtrlSetBkColor($hLabel, 0xFF0000) GUISetOnEvent($GUI_EVENT_CLOSE, "_EXIT") GUISetState(@SW_SHOWNORMAL) _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($aGraphic[2], $aGraphic[3], $hGraphic) $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) $hPen = _GDIPlus_PenCreate() _GDIPlus_GraphicsClear($hBackbuffer) _GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2) AdlibRegister("_GDIUpdate", 15) _HOVER() While Sleep(10) _HOVER() WEnd Func _box($hToGraphic, $xx, $yy, $ll, $aa) Local $aBox[5][2] $aBox[0][0] = 4 $aBox[1][0] = $xx $aBox[1][1] = $yy $aBox[2][0] = $xx + $ll $aBox[2][1] = $yy $aBox[3][0] = $xx + $ll $aBox[3][1] = $yy + $aa $aBox[4][0] = $xx $aBox[4][1] = $yy + $aa _GDIPlus_GraphicsDrawPolygon($hToGraphic, $aBox) EndFunc ;==>_box Func _EXIT() Exit EndFunc ;==>_EXIT Func _EXIT_BEFORE($sInput = 0) AdlibUnRegister("_GDIUpdate") If IsDeclared("sInput") Then ConsoleWrite("_exit[ " & $sInput & " ]" & @LF) _GDIPlus_GraphicsDispose($hBackbuffer) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hGui) EndFunc ;==>_EXIT_BEFORE Func _GDIUpdate() _GDIPlus_GraphicsClear($hBackbuffer, 0xF0FFFFFF) _box($hBackbuffer, 10, 10, 80, 20) _GDIPlus_GraphicsDrawLine($hBackbuffer, 10, 150, 390, 150, $hPen) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, $aGraphic[0], $aGraphic[1], $aGraphic[2], $aGraphic[3]) EndFunc ;==>_GDIUpdate Func _HOVER() $hCursor = GUIGetCursorInfo($hGui) If ($hCursor[0] < $aGraphic[0] Or $hCursor[0] > $aGraphic[4]) Or ($hCursor[1] < $aGraphic[1] Or $hCursor[1] > $aGraphic[5]) Then If $HOVER_OLD Then $HOVER_OLD = False $HOVER = $HOVER_OLD GUICtrlSetBkColor($hLabel, 0xFF0000) EndIf Else If Not $HOVER_OLD Then $HOVER_OLD = True $HOVER = $HOVER_OLD GUICtrlSetBkColor($hLabel, 0x00FF00) EndIf EndIf EndFunc ;==>_HOVER Edited September 2, 2014 by Detefon Visit my repository Link to comment Share on other sites More sharing options...
UEZ Posted September 2, 2014 Share Posted September 2, 2014 Why not drawing the border also in GDI+? expandcollapse popup#AutoIt3Wrapper_AU3Check_Parameters= -q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #Tidy_Parameters=/sf #include <Array.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Opt("GUIEventOptions", 1) Opt("MustDeclareVars", 1) Opt("WinWaitDelay", 25) OnAutoItExitRegister("_EXIT_BEFORE") Global $hGui, $hCursor Global $hGraphic, $hPen, $hBitmap, $hBackbuffer, $hPen_Border Global $hLabel Global $aGui[5] = ["Title", 800, 600, Default, Default] Global $aGraphic[6] = [10, 10, 400, 300] $aGraphic[4] = $aGraphic[0] + $aGraphic[2] $aGraphic[5] = $aGraphic[1] + $aGraphic[3] Global Const $nPI = 3.1415926535897932384626433832795 Global $HOVER = False, $HOVER_OLD $hGui = GUICreate($aGui[0], $aGui[1], $aGui[2], $aGui[3], $aGui[4]) ;~ $hLabel = GUICtrlCreateLabel("", $aGraphic[0] - 1, $aGraphic[1] - 1, $aGraphic[2] + 2, $aGraphic[3] + 2);, Default, $WS_EX_COMPOSITED) GUICtrlSetBkColor($hLabel, 0xFF0000) GUISetOnEvent($GUI_EVENT_CLOSE, "_EXIT") GUISetState(@SW_SHOWNORMAL) _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($aGraphic[2], $aGraphic[3], $hGraphic) $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) $hPen = _GDIPlus_PenCreate() _GDIPlus_GraphicsClear($hBackbuffer) _GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2) $hPen_Border = _GDIPlus_PenCreate() _GDIPlus_PenSetColor($hPen_Border, 0xFFFF0000) _GDIPlus_GraphicsDrawRect($hGraphic, $aGraphic[0] - 2, $aGraphic[1] - 2, $aGraphic[2] + 2, $aGraphic[3] + 2, $hPen_Border) AdlibRegister("_GDIUpdate", 15) _HOVER() While Sleep(10) _HOVER() WEnd Func _box($hToGraphic, $xx, $yy, $ll, $aa) Local $aBox[5][2] $aBox[0][0] = 4 $aBox[1][0] = $xx $aBox[1][1] = $yy $aBox[2][0] = $xx + $ll $aBox[2][1] = $yy $aBox[3][0] = $xx + $ll $aBox[3][1] = $yy + $aa $aBox[4][0] = $xx $aBox[4][1] = $yy + $aa _GDIPlus_GraphicsDrawPolygon($hToGraphic, $aBox) EndFunc ;==>_box Func _EXIT() Exit EndFunc ;==>_EXIT Func _EXIT_BEFORE($sInput = 0) AdlibUnRegister("_GDIUpdate") If IsDeclared("sInput") Then ConsoleWrite("_exit[ " & $sInput & " ]" & @LF) _GDIPlus_GraphicsDispose($hBackbuffer) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_PenDispose($hPen) _GDIPlus_PenDispose($hPen_Border) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hGui) EndFunc ;==>_EXIT_BEFORE Func _GDIUpdate() _GDIPlus_GraphicsClear($hBackbuffer, 0xF0FFFFFF) _box($hBackbuffer, 10, 10, 80, 20) _GDIPlus_GraphicsDrawLine($hBackbuffer, 10, 150, 390, 150, $hPen) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, $aGraphic[0], $aGraphic[1], $aGraphic[2], $aGraphic[3]) EndFunc ;==>_GDIUpdate Func _HOVER() $hCursor = GUIGetCursorInfo($hGui) If ($hCursor[0] < $aGraphic[0] Or $hCursor[0] > $aGraphic[4]) Or ($hCursor[1] < $aGraphic[1] Or $hCursor[1] > $aGraphic[5]) Then If $HOVER_OLD Then $HOVER_OLD = False $HOVER = $HOVER_OLD _GDIPlus_PenSetColor($hPen_Border, 0xFFFF0000) _GDIPlus_GraphicsDrawRect($hGraphic, $aGraphic[0] - 2, $aGraphic[1] - 2, $aGraphic[2] + 2, $aGraphic[3] + 2, $hPen_Border) ;~ GUICtrlSetBkColor($hLabel, 0xFF0000) EndIf Else If Not $HOVER_OLD Then $HOVER_OLD = True $HOVER = $HOVER_OLD _GDIPlus_PenSetColor($hPen_Border, 0xFF00FF00) _GDIPlus_GraphicsDrawRect($hGraphic, $aGraphic[0] - 2, $aGraphic[1] - 2, $aGraphic[2] + 2, $aGraphic[3] + 2, $hPen_Border) ;~ GUICtrlSetBkColor($hLabel, 0x00FF00) EndIf EndIf EndFunc ;==>_HOVER Br,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Luigi Posted September 2, 2014 Author Share Posted September 2, 2014 @UEZ, thank you again for your reply! I am ask for me the same think a hundred times, but, put the border line inside GDI still leaves me curious... I just know if the two things is compatible or not... If they are compatibles, how the best practice to do... Best regards, Detefon Visit my repository Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now