[UDF] GuiStatusBar facile avec plusieurs GUI (GuiStatusBarEx.au3) update 02/06/2022

Partagez des fonctions et des UDF AutoIt.
Règles du forum
.
Avatar du membre
Anthony
Niveau 6
Niveau 6
Messages : 292
Enregistré le : lun. 17 janv. 2011 14:08
Localisation : France
Status : Hors ligne

Re: [UDF] GuiStatusBar facile avec plusieurs GUI (GuiStatusBarEx.au3) update 22/04/2020, 04h15

#21

Message par Anthony »

Bonjour à tous et merci mikell je n'en pouvais plus, tu m'as mis sur la voie :bisou: ,

Je pense avoir un début de réponse, il reste les boutons de la gui Child qui disparaissent quand on redim la GUI Parent :shock:

Je met le code actuel

GuiStatusBarEx.au3

Code : Tout sélectionner

#include-once

#include <GuiStatusBar.au3>

#include <ButtonConstants.au3>
#include <Color.au3>
#include <ComboConstants.au3>
#include <Date.au3>
#include <FontConstants.au3>
#include <GuiComboBox.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <ProgressConstants.au3>
#include <WinAPISys.au3>
#include <WinAPITheme.au3>
#include <WindowsConstants.au3>

#include <Array.au3>	; _ArrayDisplay($aArray, "Infos")

; #INDEX# =======================================================================================================================
; Title .........: StatusBarEx
; AutoIt Version : 3.3.14.5
; Date ..........: 24/04/2020, 11h15
; Language ......: English
; Description ...: Functions that assist with StatusBarEx control management.
;                  A status bar Ex is a horizontal window at the bottom of a parent window in which an application can display
;                  various kinds of status information.  The status bar can be divided into parts to display more than one type
;                  of information
; Author(s) .....: Anthony Baillou (Anthony) <https://www.autoitscript.fr/forum/memberlist.php?mode=viewprofile&u=3388>
; ===============================================================================================================================

; #VARIABLES# ===================================================================================================================
Global $exstyle, $StatusBarExGraphic
Global $MultiStatusBarEx[0][6]	; $MultiStatusBarEx[1][6] = [["","","","","",""]]	 ; $hBarEx devient $MultiStatusBarEx ; [["$SethWnd = $hGUI Num","Créé la StatusBar > _GUICtrlStatusBar_Create( $SethWnd)"]]
Global $StatusBarEx_Clock, $ClockStatusBarEx[0][2]
Global $DEBUG_StatusBarEx = '', $DEBUG_StatusBarEx_Sleep = 50	; For DEBUG
; ===============================================================================================================================


; #FUNCTION#=====================================================================================================================
; Author ........: Anthony Baillou
; Modified.......: Anthony Baillou, walkson, mikell
;
; Name ..........: _GUICtrlStatusBarEx_Create
; Description ...: Ajoute une StatusBar dans le Handle d'une GUI
; Syntax ........: _GUICtrlStatusBarEx_Create( $SethWnd, $SetPartsEx, $SetPartsHeightEx, $SetStartColorEx, $SetEndColorEx)
; Parameters ....: $SethWnd             - Handle de la GUI cible.
;                  $SetPartsEx          - [needed] "Pos 1,Pos 2,Pos 3,Pos...".                Eg: "100,50,85,240,75,-1"
;                  $SetPartsHeightEx    - [needed] "Height for parts"                         Eg: 25
;                  $SetStartColorEx     - [optional] "0xRRGGBB".               Default is "". Eg: "0xCCAAFF"
;                  $SetEndColorEx       - [optional] "0xRRGGBB".               Default is "". Eg: "0xFFAACC"
; ===============================================================================================================================
Func _GUICtrlStatusBarEx_Create( $SethWnd="", $SetPartsEx="", $SetPartsHeightEx="", $SetStartColorEx="", $SetEndColorEx="")
   GUISwitch( $SethWnd)

   Local $avar[1][6] = [[$SethWnd, _GUICtrlStatusBar_Create( $SethWnd), $SetPartsHeightEx, "", $SetStartColorEx, $SetEndColorEx]]
   _ArrayAdd( $MultiStatusBarEx, $avar)
;~    _ArrayDisplay( $MultiStatusBarEx, "2D -> " & @ScriptLineNumber)
;~    ConsoleWrite('Line='&@ScriptLineNumber&", $SethWnd="&$MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][0]&", _GUICtrlStatusBar_Create( $SethWnd)="&$MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1]&", Count="&UBound($MultiStatusBarEx, 1)&@CRLF)
   $PartEx = StringSplit( StringReplace( $SetPartsEx, " ", ""), ",")
   Global $hPartsWidthEx[$PartEx[0]], $hPartsPosEx[$PartEx[0]][3]
   For $i = 1 To $PartEx[0]
	  $hPartsWidthEx[$i-1]	= $PartEx[$i]
   Next
   If $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][4] Or $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][5] Then
	  _WinAPI_SetWindowTheme( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1], "", "")
	  Local $size = WinGetClientSize( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][0])
	  _GUICtrlCreateGradient( $SethWnd, $SetStartColorEx, $SetEndColorEx, 0, 0, $size[0], $size[1]-$SetPartsHeightEx)
	  If $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][5] Then _GUICtrlStatusBar_SetBkColor( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1], _WinAPI_SwitchColor( $SetEndColorEx))
   EndIf
   _GUICtrlStatusBar_SetMinHeight( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1], $SetPartsHeightEx)
   _GUICtrlStatusBar_SetParts( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1],-1, $hPartsWidthEx)
   If Not $DEBUG_StatusBarEx = '' Then GUISetState(@SW_SHOW, $SethWnd)
   For $i = 0 To $PartEx[0] -1
	  $hPartsPosEx[$i][0] = GUICtrlCreateButton("This "&$i, -1, -1)			; ID
	  $hPartsPosEx[$i][1] = GUICtrlGetHandle( $hPartsPosEx[$i][0])			; Handle
	  _GUICtrlStatusBar_EmbedControl( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1], $i, $hPartsPosEx[$i][1], 4)
	  Local $var = ControlGetPos( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][0],"",($hPartsPosEx[$i][0]))
	  $hPartsPosEx[$i][2] = $var[0]&","&$var[1]&","&$var[2]&","&$var[3]
	  If Not $DEBUG_StatusBarEx = '' Then Sleep($DEBUG_StatusBarEx_Sleep)
	  GUICtrlDelete($hPartsPosEx[$i][0])
	  If Not $DEBUG_StatusBarEx = '' Then Sleep($DEBUG_StatusBarEx_Sleep)
   Next
   If Not $DEBUG_StatusBarEx = '' Then GUISetState(@SW_HIDE, $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][0])

   GUIRegisterMsg($WM_SIZE, "_WM_SIZE")
   GUIRegisterMsg($WM_PAINT, "WM_PAINT")						; Same ? > GUIRegisterMsg($WM_ACTIVATEAPP, "_WM_ACTIVATEAPP")

;~    ;GUIRegisterMsg($WM_SYSCOMMAND, "_WM_SYSCOMMAND")
;~    ;GUIRegisterMsg($WM_EXITSIZEMOVE, "_WM_EXITSIZEMOVE")
;~    ;GUIRegisterMsg($WM_ACTIVATEAPP, "_WM_ACTIVATEAPP")		; Same ? > GUIRegisterMsg($WM_PAINT, "WM_PAINT")

   Return $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1]	; Old > Return $SethWnd
EndFunc


; #FUNCTION#=====================================================================================================================
; Author ........: Anthony Baillou, walkson
; Modified.......: Anthony Baillou, walkson, mikell
;
; Name ..........: _GUICtrlStatusBarEx_CreateControl
; Description ...:
; Syntax ........: _GUICtrlStatusBarEx_CreateControl( $hWnd, $IndexControl, $Ex_Part, $Ex_Title, $Ex_X, $Ex_Y, $Ex_W, $Ex_H[, $BkColor = ""[, $SetFont = ""]])
; Parameters ....: $hWnd                - Handle de la GUI.
;                  $IndexControl        - Une des valeurs suivantes.
;                                                                                 1 - Button
;                                                                                 2 - Checkbox
;                                                                                 3 - Combobox
;                                                                                 4 - Date
;                                                                                 5 - Input
;                                                                                 6 - Label
;                  $Ex_Part             - N° de section du statusbar.
;                  $Ex_Title            - Texte.
;                  $Ex_X                - X.
;                  $Ex_Y                - Y.
;                  $Ex_W                - Width.
;                  $Ex_H                - Height.
;                  $Ex_Align            - FIXED_LEFT, FIXED_RIGHT, SIZEABLE_LEFT, SIZEABLE_RIGHT ou SIZEABLE_AUTO.
;                  $BkColor             - [optional] RGB. Default is "".
;                  $SetFont             - [optional] "Size|weight|attribute|fontname". Default is "". Eg: "10|$FW_NORMAL|$GUI_FONTNORMAL|Arial"
;                                                                                       Size: eg. 10
;                                                                                       weight:     $FW_DONTCARE = 0
;                                                                                                               $FW_THIN = 100
;                                                                                                               $FW_EXTRALIGHT = 200
;                                                                                                               $FW_LIGHT = 300
;                                                                                                               $FW_NORMAL = 400
;                                                                                                               $FW_MEDIUM = 500
;                                                                                                               $FW_SEMIBOLD = 600
;                                                                                                               $FW_BOLD = 700
;                                                                                                               $FW_EXTRABOLD = 800
;                                                                                                               $FW_HEAVY = 900
;                                                                                       attribute :     $GUI_FONTNORMAL (0) = Normal
;                                                                                                                       $GUI_FONTITALIC (2) = Italic
;                                                                                                                       $GUI_FONTUNDER (4) = Underlined
;                                                                                                                       $GUI_FONTSTRIKE (8) = Strike
;                                                                                       fontname: eg. Arial
;
; Return values .: Control
; ===============================================================================================================================
Func _GUICtrlStatusBarEx_CreateControl( $hWnd="", $IndexControl="", $Ex_Part="", $Ex_Title="", $Ex_X="", $Ex_Y="", $Ex_W="", $Ex_H="", $Ex_Align="", $Style="", $Ex_Style="", $BkColor="", $SetFont="")

		 If $IndexControl < 1 Or $IndexControl > 8 Then Return SetError(1)

		 Local $var							= StringSplit( $hPartsPosEx[$Ex_Part][2], ",")
			   If		$Ex_Align = 'FIXED_LEFT'	Or $Ex_Align = 'SIZEABLE_LEFT'	Then
				  Local $Bar_Ex_X=$var[1]+$Ex_X,				$Bar_Ex_Y=$var[2]+$Ex_Y,	$Bar_Ex_W=$Ex_W,				$Bar_Ex_H=$var[4]+$Ex_H
			   ElseIf	$Ex_Align = 'FIXED_RIGHT'	Or $Ex_Align = 'SIZEABLE_RIGHT'	Then
				  Local $Bar_Ex_X=$var[3]-$Ex_X-$Ex_W+$var[1],	$Bar_Ex_Y=$var[2]+$Ex_Y,	$Bar_Ex_W=$Ex_W,				$Bar_Ex_H=$var[4]+$Ex_H
			   ElseIf	$Ex_Align = 'SIZEABLE_AUTO'									Then
				  Local $Bar_Ex_X=$var[1]+$Ex_X,				$Bar_Ex_Y=$var[2]+$Ex_Y,	$Bar_Ex_W=$var[3]+$Ex_W-$Ex_X,	$Bar_Ex_H=$var[4]+$Ex_H
			   Else
				  Local $Bar_Ex_X=$var[1]+$Ex_X,				$Bar_Ex_Y=$var[2]+$Ex_Y,	$Bar_Ex_W=$var[3]-$Ex_X,		$Bar_Ex_H=$var[4]+$Ex_H
			   EndIf

		 Switch $IndexControl
			   Case 1
					 $id_Ctrl	= GUICtrlCreateButton(		$Ex_Title,	$Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
			   Case 2
					 $id_Ctrl	= GUICtrlCreateCheckbox(	$Ex_Title,	$Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
			   Case 3
					 $id_Ctrl	= GUICtrlCreateCombo(		""		,	$Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
					 $Ex_Split = StringSplit( $Ex_Title,"|")
					 GUICtrlSetData( $id_Ctrl, StringTrimLeft( $Ex_Title, StringLen($Ex_Split[1]&"|")), $Ex_Split[1])
			   Case 4
					 $id_Ctrl	= GUICtrlCreateDate(		$Ex_Title,	$Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
			   Case 5
					 $id_Ctrl	= GUICtrlCreateInput(		$Ex_Title,	$Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
			   Case 6
					 $id_Ctrl	= GUICtrlCreateLabel(		$Ex_Title,	$Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
			   Case 7
					 $id_Ctrl = GUICtrlCreateProgress(					$Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
			   Case 8
					 $id_Ctrl	= GUICtrlCreateInput(		$Ex_Title,	$Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
					 $Ex_Split = StringSplit( $Ex_Title,"|")
					 GUICtrlSetLimit( GUICtrlCreateUpdown( $id_Ctrl), $Ex_Split[2], $Ex_Split[3])	; $id_Ctrl, 15, 5
					 GUICtrlSetData( $id_Ctrl, $Ex_Split[1])

		 EndSwitch

   If $BkColor <> "" Then GUICtrlSetBkColor( $id_Ctrl, $BkColor)	; GUICtrlSetBkColor($id_Ctrl, 0x00FF00)
   Local $SetFontSplit
   If $SetFont <> "" Then
			$SetFontSplit = StringSplit( $SetFont,"|")
				  If Not IsArray( $SetFontSplit) Then  Return SetError(1)
				  If $SetFontSplit[0]		= 4 Then GUICtrlSetFont( $id_Ctrl, $SetFontSplit[1],$SetFontSplit[2],$SetFontSplit[3],$SetFontSplit[4])
   EndIf

   If $Ex_Part = UBOUND( $hPartsPosEx)-1  Then
	  If $Ex_Align = 'FIXED_LEFT'																	Then	GUICtrlSetResizing( -1, $GUI_DOCKLEFT	+	$GUI_DOCKSIZE + $GUI_DOCKBOTTOM)
	  If $Ex_Align = 'FIXED_RIGHT'																	Then	GUICtrlSetResizing( -1, 					$GUI_DOCKSIZE + $GUI_DOCKBOTTOM + $GUI_DOCKRIGHT)
	  If $Ex_Align = 'SIZEABLE_LEFT' Or $Ex_Align = 'SIZEABLE_RIGHT' Or $Ex_Align = 'SIZEABLE_AUTO'	Then	GUICtrlSetResizing( -1, $GUI_DOCKLEFT	+	$GUI_DOCKSIZE + $GUI_DOCKBOTTOM + $GUI_DOCKRIGHT)
   Else
	  GUICtrlSetResizing( $id_Ctrl, $GUI_DOCKLEFT	+ $GUI_DOCKSIZE + $GUI_DOCKBOTTOM)
   EndIf

   For $i = 0 To UBound($MultiStatusBarEx, 1)-1
	  If $hWnd = $MultiStatusBarEx[$i][0] Then
		 _WinAPI_SetWindowPos( $MultiStatusBarEx[$i][1], $HWND_BOTTOM, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE))	; Old > _WinAPI_SetWindowPos($hBarEx, $HWND_BOTTOM, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE))
	  EndIf
   Next

   Return $id_Ctrl
EndFunc


; #FUNCTION#=====================================================================================================================
; Author ........: Anthony Baillou
; Modified.......: Anthony Baillou
;
; Name ..........: _GUICtrlStatusBarEx_CreateFunc
; Description ...: Ajoute une fonction à un objet
; Syntax ........: _GUICtrlStatusBarEx_CreateFunc( $id_Ctrl, $IndexControl, $Options)
; Parameters ....: $id_Ctrl             - Handle du contrôle.
;                  $IndexFunc           - Index de la fonction.
;                  $Options             - Options de la fonction.
; Clock..........: $id_Ctrl, 1, [$Options]
;                                      [0] = Affiche une date et/ou une heure.
;                                            S'il y a une partie de date, l'afficher comme une date courte.
;                                            S'il y a une partie d'une heure, l'afficher comme une heure longue.
;                                            Si présent, les deux parties sont affichées.
;                                      [1] = Affiche une date en utilisant la date au format long spécifié dans les paramètres régionaux de votre ordinateur.
;                                      [2] = Affiche une date en utilisant la date au format court spécifié dans les paramètres régionaux de votre ordinateur.
;                                      [3] = Affiche une heure en utilisant l'heure au format spécifié dans les paramètres régionaux de votre ordinateur.
;                                      [4] = Affiche une heure en utilisant le format 24 heures (hh:mm).
;                                      [5] = Affiche une heure en utilisant le format 24 heures (hh:mm:ss).
; ===============================================================================================================================
Func _GUICtrlStatusBarEx_CreateFunc( $id_Ctrl="", $IndexFunc="", $Options="")
		 If $IndexFunc < 1 Or $IndexFunc > 1 Then Return SetError(1)

		 Switch $IndexFunc
			   Case 1
					 Local $avar[1][2] = [[$id_Ctrl, $Options]]
					 _ArrayAdd( $ClockStatusBarEx, $avar)
					 _BarEx_Func_CLOCK()

		 EndSwitch
EndFunc


; #FUNCTION# ====================================================================================================================
; Author ........: mikell
; Modified.......: Anthony Baillou
; ===============================================================================================================================
Func _GUICtrlCreateGradient( $hWnd, $nStartColor, $nEndColor, $nX, $nY, $nWidth, $nHeight)
   _WinAPI_SetWindowTheme( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1], "", "")
   For $i = 0 To UBound($MultiStatusBarEx, 1)-1
	  If $hWnd = $MultiStatusBarEx[$i][0] And $MultiStatusBarEx[$i][4] Then

		 GUISwitch($MultiStatusBarEx[$i][0])

		 Local $color1R = _ColorGetRed($nStartColor)
		 Local $color1G = _ColorGetGreen($nStartColor)
		 Local $color1B = _ColorGetBlue($nStartColor)

		 Local $nStepR = (_ColorGetRed($nEndColor) - $color1R) / $nHeight
		 Local $nStepG = (_ColorGetGreen($nEndColor) - $color1G) / $nHeight
		 Local $nStepB = (_ColorGetBlue($nEndColor) - $color1B) / $nHeight

		 If $MultiStatusBarEx[$i][3] <> "" Then GUICtrlDelete( $MultiStatusBarEx[$i][3])
		 $MultiStatusBarEx[$i][3] = GuiCtrlCreateGraphic($nX, $nY, $nWidth, $nHeight, $TCS_BOTTOM)

		 For $j = 0 To $nHeight - $nY
			$sColor = "0x" & StringFormat("%02X%02X%02X", $color1R+$nStepR*$j, $color1G+$nStepG*$j, $color1B+$nStepB*$j)
			GUICtrlSetGraphic( $MultiStatusBarEx[$i][3], $GUI_GR_COLOR, $sColor, 0xffffff)
			GUICtrlSetGraphic( $MultiStatusBarEx[$i][3], $GUI_GR_MOVE, 0, $j)
			GUICtrlSetGraphic( $MultiStatusBarEx[$i][3], $GUI_GR_LINE, $nWidth, $j)
		 Next
		 ConsoleWrite(	@ScriptLineNumber& _
						", i$="&$i& _
						", GUI="&$MultiStatusBarEx[$i][0]& _
						", Bar="&$MultiStatusBarEx[$i][1]& _
						", BarHeight="&$MultiStatusBarEx[$i][2]& _
						", ID="&$MultiStatusBarEx[$i][3]& _
						", ColorStart="&$MultiStatusBarEx[$i][4]& _
						", ColorEnd="&$MultiStatusBarEx[$i][5]& _
						", X="&0& _
						", Y="&0& _
						", W="&$nWidth& _
						", H="&$nHeight& @CRLF)

;~ 		 Sleep(1000)
;~ 		 GUICtrlSetState( $MultiStatusBarEx[$i][3], $GUI_DISABLE)
;~ 		 GUICtrlSetState( $MultiStatusBarEx[$i][3], $TCS_BOTTOM)
	  EndIf
   Next
EndFunc


; #FUNCTION# ====================================================================================================================
; Author ........: Anthony Baillou
; Modified.......: Anthony Baillou
; ===============================================================================================================================
Func _BarEx_Func_CLOCK()
   For $i = 0 To UBound($ClockStatusBarEx, 1)-1
	  If Not $StatusBarEx_Clock Then
		 $StatusBarEx_Clock = 1
		 AdlibRegister( "_BarEx_Func_CLOCK", 1000)
	  EndIf
	  GUICtrlSetData( $ClockStatusBarEx[$i][0], _DateTimeFormat( _NowCalc(), $ClockStatusBarEx[$i][1]))
   Next
EndFunc


; #FUNCTION# ====================================================================================================================
; Author ........: mikell
; Modified.......: mikell, Anthony Baillou
; ===============================================================================================================================
Func _WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)
   For $i = 0 To UBound($MultiStatusBarEx, 1)-1
	  If $hWnd = $MultiStatusBarEx[$i][0] Then
		 _GUICtrlStatusBar_Resize( $MultiStatusBarEx[$i][1])
		 Local $size = WinGetClientSize( $MultiStatusBarEx[$i][0])
		 _GUICtrlCreateGradient( $MultiStatusBarEx[$i][0], $MultiStatusBarEx[$i][4], $MultiStatusBarEx[$i][5], 0, 0, $size[0], $size[1]-$MultiStatusBarEx[$i][2])
		 ConsoleWrite(	@ScriptLineNumber& _
						", i$="&$i& _
						", GUI="&$MultiStatusBarEx[$i][0]& _
						", Bar="&$MultiStatusBarEx[$i][1]& _
						", BarHeight="&$MultiStatusBarEx[$i][2]& _
						", ID="&$MultiStatusBarEx[$i][3]& _
						", ColorStart="&$MultiStatusBarEx[$i][4]& _
						", ColorEnd="&$MultiStatusBarEx[$i][5]& _
						", X="&0& _
						", Y="&0& _
						", W="&$size[0]& _
						", H="&$size[1]-$MultiStatusBarEx[$i][2]& @CRLF)
	  EndIf
   Next
   Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE


; #FUNCTION# ====================================================================================================================
; Author ........: mikell
; Modified.......: mikell, Anthony Baillou
; ===============================================================================================================================
Func WM_PAINT($hWnd, $msg, $wParam, $lParam)
;~    GUISwitch( $hWnd)
   For $i = 0 To UBound($MultiStatusBarEx, 1)-1
	  If $hWnd = $MultiStatusBarEx[$i][0] Then
;~ 		 ConsoleWrite( 'Line='&@ScriptLineNumber&', '&$hWnd &"="&$MultiStatusBarEx[$i][0]&'>'&$MultiStatusBarEx[$i][1]&@CRLF)
		 $tRECT = _WinAPI_GetWindowRect($MultiStatusBarEx[$i][1])
		 _WinAPI_RedrawWindow( $MultiStatusBarEx[$i][1], $tRECT, "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW))
	  EndIf
   Next
   Return $GUI_RUNDEFMSG
EndFunc










; #FUNCTION# ====================================================================================================================
; Author ........: mikell
; Modified.......: mikell
; ===============================================================================================================================
;~ Func _WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
;~    #forceref $hWnd, $Msg, $lParam
;~    Switch BitAND($wParam, 0xFFF0)
;~ 	  Case 0xF000   ; $SC_SIZE
;~ 		 $exstyle = _WinAPI_GetWindowLong( $hWnd, -20)
;~ 		 _WinAPI_SetWindowLong( $hWnd, -20, 33554432)
;~    EndSwitch
;~ EndFunc

; #FUNCTION# ====================================================================================================================
; Author ........: mikell
; Modified.......: mikell
; ===============================================================================================================================
;~ Func _WM_EXITSIZEMOVE($hWnd, $msg, $wParam, $lParam)
;~    _WinAPI_SetWindowLong( $hWnd, -20, $exstyle )
;~    Return $GUI_RUNDEFMSG
;~ EndFunc

; #FUNCTION# ====================================================================================================================
; Author ........: mikell
; Modified.......: mikell
; ===============================================================================================================================
;~ Func _WM_ACTIVATEAPP($hWnd, $msg, $wParam, $lParam)
;~    If $wParam = 1 Then _WinAPI_RedrawWindow($hBarEx, "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW))
;~    Return $GUI_RUNDEFMSG
;~ EndFunc


La DEMO actuelle

Code : Tout sélectionner

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.5
 Author:         Anthony Baillou
 Modified:       Anthony Baillou, walkson, mikell
 Date:           24/04/2020, 11h15

 Script Function:
	<GuiStatusBarEx.au3>	(UDF)

#ce ----------------------------------------------------------------------------

#include <GuiStatusBarEx.au3> ; With include <GuiStatusBar.au3>

Local $var1
For $i = 1 To 1000
   If $i = 500 Then
	  $var1 &= 'Combo|'
   Else
	  $var1 &= $i&'|'
   EndIf
Next

; == $hGUI_1 ===================================================================
Local $hGUI_1			= GUICreate("<GuiStatusBarEx.au3> (UDF DEMO Parent $hGUI_1)", 1024, 285, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU))

Local $WinGetPos1, $Pos1
Local $nStartColor_1=0xCCAAAA, $nEndColor_1=0x00f0ff

$hGUI_1_StatusBarEx		= _GUICtrlStatusBarEx_Create( $hGUI_1, "100,50,100,85,240,70,75,-1", 60, $nStartColor_1, $nEndColor_1)	; $hGUI_1_StatusBarEx=_GUICtrlStatusBarEx_Create( $hGUI_1, "75,90,100,85,-1", 60)  > (Parent Handle 1, "Width,of,Parts,..,-1", StatusBarEx 1 Height, Start color gradient, End color gradient)

$hGUI_1_Label_1			= _GUICtrlStatusBar_SetText($hGUI_1_StatusBarEx, "1", 0)					; Set Standard StatusBar, $Label1
$hGUI_1_Label_2			= _GUICtrlStatusBar_SetText($hGUI_1_StatusBarEx, "2", 1)					; Set Standard StatusBar, $Label2
$hGUI_1_Label_3			= _GUICtrlStatusBar_SetText($hGUI_1_StatusBarEx, "3", 2)					; Set Standard StatusBar, $Label3
$hGUI_1_Label_4			= _GUICtrlStatusBar_SetText($hGUI_1_StatusBarEx, "4", 3)					; Set Standard StatusBar, $Label4
$hGUI_1_Label_5			= _GUICtrlStatusBar_SetText($hGUI_1_StatusBarEx, "5", 4)					; Set Standard StatusBar, $Label5
$hGUI_1_Label_6			= _GUICtrlStatusBar_SetText($hGUI_1_StatusBarEx, "6", 5)					; Set Standard StatusBar, $Label6
$hGUI_1_Label_7			= _GUICtrlStatusBar_SetText($hGUI_1_StatusBarEx, "7", 6)					; Set Standard StatusBar, $Label7
$hGUI_1_Label_8			= _GUICtrlStatusBar_SetText($hGUI_1_StatusBarEx, "8", 7)					; Set Standard StatusBar, $Label8

$hGUI_1_Button_1		= _GUICtrlStatusBarEx_CreateControl( $hGUI_1,   1, "1", "Get"          , 12,  0,   0,   0, ""             , ""                            , "", 0xFFFF00,"8.5|$FW_NORMAL|$GUI_FONTNORMAL|Courier new")
$hGUI_1_Checkbox_1		= _GUICtrlStatusBarEx_CreateControl( $hGUI_1,   2, "2", "Checkbox"     , 12,  0,   0,   0, "SIZEABLE_AUTO", ""                            , "", 0x00FF50,"8.5|$FW_NORMAL|$GUI_FONTNORMAL|Courier new")
$hGUI_1_Combo_1			= _GUICtrlStatusBarEx_CreateControl( $hGUI_1,   3, "3", "Combo|"&$var1 , 12,  3,   0,   0, ""             , $CBS_DROPDOWN+$WS_VSCROLL     , "", 0xFFFF00,"8.5|$FW_NORMAL|$GUI_FONTNORMAL|Courier new")
$hGUI_1_Input_UpDown_1	= _GUICtrlStatusBarEx_CreateControl( $hGUI_1,   8, "3", "5|10|0"       , 12, 30,   0, -33, ""             , ""                            , "", 0xFFFF00,"8.5|$FW_NORMAL|$GUI_FONTNORMAL|Courier new")
$hGUI_1_Date_1			= _GUICtrlStatusBarEx_CreateControl( $hGUI_1,   4, "4", "Date"         , 12,  0,   0,   0, "SIZEABLE_AUTO", ""                            , "", 0xFFFFFF,"8.5|$FW_NORMAL|$GUI_FONTNORMAL|Courier new")
$hGUI_1_Input_1			= _GUICtrlStatusBarEx_CreateControl( $hGUI_1,   5, "5", "Input"        , 12,  0,   0,   0, "SIZEABLE_AUTO", ""                            , "", 0xFF9876,"8.5|$FW_NORMAL|$GUI_FONTNORMAL|Courier new")
$hGUI_1_Progress_1		= _GUICtrlStatusBarEx_CreateControl( $hGUI_1,   7, "6", "Progress"     , 12,  0,   0,   0, "SIZEABLE_AUTO", ""                            , "", 0xFFFFFF,"8.5|$FW_NORMAL|$GUI_FONTNORMAL|Courier new")
$hGUI_1_Button_2		= _GUICtrlStatusBarEx_CreateControl( $hGUI_1,   1, "7", "Go"           , 12,  0,  25,   0, "FIXED_LEFT"   , ""                            , "", 0xAAFFAA,"8.5|$FW_NORMAL|$GUI_FONTNORMAL|Courier new")
$hGUI_1_Label_1			= _GUICtrlStatusBarEx_CreateControl( $hGUI_1,   6, "7", "Label1"       , 42,  0, 170,   0, "SIZEABLE_LEFT", $SS_CENTER+$SS_CENTERIMAGE    , "", 0xFFAA00,"8.5|$FW_NORMAL|$GUI_FONTNORMAL|Courier New")
$hGUI_1_Label_2			= _GUICtrlStatusBarEx_CreateControl( $hGUI_1,   6, "7", "Label2"       ,  0,  0,  65,   0, "FIXED_RIGHT"  , $SS_CENTER                    , "", 0xAAAAAA,"8.5|$FW_NORMAL|$GUI_FONTNORMAL|Courier new")

_GUICtrlStatusBarEx_CreateFunc( $hGUI_1_Label_1, 1, 0)	; Clock Option 0

$hGUI_1_Button1			= GUICtrlCreateButton("Show GUI Child with $hGUI_2_StatusBarEx", 100, 80, 800, 50)
GUICtrlSetResizing( -1, $GUI_DOCKLEFT + $GUI_DOCKSIZE + $GUI_DOCKTOP + $GUI_DOCKBOTTOM + $GUI_DOCKRIGHT)

; == $hGUI_2 ===================================================================
Local $hGUI_2			= GUICreate("<GuiStatusBarEx.au3> (UDF DEMO Child $hGUI_2)", 900, 150, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU))

Local $WinGetPos2, $Pos2
Local $nStartColor_2=0x00f0ff, $nEndColor_2=0x00aaaa

$hGUI_2_StatusBarEx		= _GUICtrlStatusBarEx_Create( $hGUI_2, "150, 125, 100, 85, 100, -1", 27, $nStartColor_2, $nEndColor_2)	; $hGUI_2_StatusBarEx=_GUICtrlStatusBarEx_Create( $hGUI_2, "150,125,100,85,100,-1", 60)  > (Parent Handle 2, "Width,of,Parts,..,-1", StatusBarEx 2 Height, Start color gradient, End color gradient)

$hGUI_2_Button_1		= _GUICtrlStatusBarEx_CreateControl( $hGUI_2,   1, "1", "Get"         ,  0,  0,   0,  0, ""             , ""                            , "", 0xFFFF00,"8.5|$FW_NORMAL|$GUI_FONTNORMAL|Courier new")
$hGUI_2_Checkbox_1		= _GUICtrlStatusBarEx_CreateControl( $hGUI_2,   2, "2", "Checkbox"    ,  0,  0,   0,  0, "SIZEABLE_AUTO", ""                            , "", 0x00FFF0,"8.5|$FW_NORMAL|$GUI_FONTNORMAL|Courier new")
$hGUI_2_Combo_1			= _GUICtrlStatusBarEx_CreateControl( $hGUI_2,   3, "3", "Combo|"&$var1,  0,  0,   0, 10, "SIZEABLE_AUTO", $CBS_DROPDOWN+$WS_VSCROLL     , "", 0xFFFF00,"8.5|$FW_NORMAL|$GUI_FONTNORMAL|Courier new")
$hGUI_2_Input_UpDown_1	= _GUICtrlStatusBarEx_CreateControl( $hGUI_2,   8, "4", "5|10|0"      ,  0,  0,   0,  0, ""             , ""                            , "", 0xFFFF00,"8.5|$FW_NORMAL|$GUI_FONTNORMAL|Courier new")
$hGUI_2_Button_2		= _GUICtrlStatusBarEx_CreateControl( $hGUI_2,   1, "5", "Start"       ,  0,  0,  50,  0, "FIXED_LEFT"   , ""                            , "", 0xAAFFAA,"8.5|$FW_NORMAL|$GUI_FONTNORMAL|Courier new")
$hGUI_2_Progress_1		= _GUICtrlStatusBarEx_CreateControl( $hGUI_2,   7, "5", ""            , 57,  0,  70,  0, "SIZEABLE_LEFT", ""                            , "", 0xFFFFFF,"8.5|$FW_NORMAL|$GUI_FONTNORMAL|Courier new")
$hGUI_2_Label_1			= _GUICtrlStatusBarEx_CreateControl( $hGUI_2,   6, "5", "0 %"         , 57,  0,  70,  0, "SIZEABLE_LEFT", $SS_CENTER+$SS_CENTERIMAGE    , "", $GUI_BKCOLOR_TRANSPARENT,"8.5|$FW_NORMAL|$GUI_FONTNORMAL|Courier new")
$hGUI_2_Label_2			= _GUICtrlStatusBarEx_CreateControl( $hGUI_2,   6, "5", "Label2"      ,  0,  0, 185,  0, "FIXED_RIGHT"  , $SS_CENTER+$SS_CENTERIMAGE    , "", 0xAAAAAA,"8.5|$FW_NORMAL|$GUI_FONTNORMAL|Courier new")

_GUICtrlStatusBarEx_CreateFunc( $hGUI_2_Label_2, 1, 3)	; Clock Option 3

; == Show Parent GUI's =========================================================
GUISetState(@SW_SHOW, $hGUI_1)


While 1
   $GUIGetMsg	= GUIGetMsg(1)
   $msg			= $GUIGetMsg[0]

   Switch $msg
	  Case $GUI_EVENT_CLOSE
		 If $GUIGetMsg[1] = $hGUI_1 Then                ; From $hGUI_1
			Exit
		 ElseIf $GUIGetMsg[1] = $hGUI_2 Then    ; From $hGUI_2
			GUISetState(@SW_HIDE, $hGUI_2)
;~ 			GUISwitch($hGUI_1)  ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;~ 			GUISwitch(WinGetHandle(''))
		 EndIf

; == $hGUI_1 ===================================================================
	  Case $hGUI_1_Button1						; From $hGUI_1
		 GUISetState(@SW_SHOW, $hGUI_2)

	  Case $hGUI_1_Button_1						; From $hGUI_1_StatusBarEx
		 MsgBox("", "Return text of the Button 1", "$hGUI_1_Button_1 return: " & @CRLF&@CRLF & GUICtrlRead( $hGUI_1_Button_1), 5)

	  Case $hGUI_1_Checkbox_1					; From $hGUI_1_StatusBarEx
		 If GUICtrlRead($hGUI_1_Checkbox_1) = $GUI_CHECKED Then
			GUICtrlSetData($hGUI_1_Checkbox_1, 'Checked')
		 Else
			GUICtrlSetData($hGUI_1_Checkbox_1, 'Unchecked')
		 EndIf

	  Case $hGUI_1_Combo_1						; From $hGUI_1_StatusBarEx
		 MsgBox( "", "Return text of the Combo1", "$hGUI_1_Combo_1 return: " & @CRLF&@CRLF & GUICtrlRead( $hGUI_1_Combo_1), 5)

	  Case $hGUI_1_Input_UpDown_1				; From $hGUI_1_StatusBarEx
		 MsgBox( "", "Return text of the Input With UpDown", "$hGUI_1_Input_UpDown_1 return: " & @CRLF&@CRLF & GUICtrlRead( $hGUI_1_Input_UpDown_1), 5)

	  Case $hGUI_1_Date_1						; From $hGUI_1_StatusBarEx
		 MsgBox("", "Return text of the Input", "$Combo1 return: " & @CRLF&@CRLF & GUICtrlRead( $hGUI_1_Date_1), 5)

	  Case $hGUI_1_Button_2						; From $hGUI_1_StatusBarEx
		 For $i = 100 To 1 Step -1
			GUICtrlSetData( $hGUI_1_Progress_1, $i)
			GUICtrlSetData( $hGUI_1_Input_1, $i & " %")
			Sleep(10)
		 Next
		 GUICtrlSetData( $hGUI_1_Progress_1, 0)
		 GUICtrlSetData( $hGUI_1_Input_1, "Done")

; == $hGUI_2 ===================================================================
	  Case $hGUI_2_Button_1						; From $hGUI_2_StatusBarEx
		 MsgBox("", "Return text of the Button 1", "$hGUI_2_Button_1 return: " & @CRLF&@CRLF & GUICtrlRead( $hGUI_2_Button_1), 5)

	  Case $hGUI_2_Checkbox_1					; From $hGUI_2_StatusBarEx
		 If GUICtrlRead($hGUI_2_Checkbox_1) = $GUI_CHECKED Then
			GUICtrlSetData($hGUI_2_Checkbox_1, 'Checked')
		 Else
			GUICtrlSetData($hGUI_2_Checkbox_1, 'Unchecked')
		 EndIf

	  Case $hGUI_2_Combo_1						; From $hGUI_2_StatusBarEx
		 MsgBox( "", "Return text of the Combo1", "$hGUI_2_Combo_1 return: " & @CRLF&@CRLF & GUICtrlRead( $hGUI_2_Combo_1), 5)

	  Case $hGUI_2_Input_UpDown_1				; From $hGUI_2_StatusBarEx
		 MsgBox( "", "Return text of the Input With UpDown", "$hGUI_2_Input_UpDown_1 return: " & @CRLF&@CRLF & GUICtrlRead( $hGUI_2_Input_UpDown_1), 5)

	  Case $hGUI_2_Button_2						; From $hGUI_2_StatusBarEx
		 For $i = 0 To 100 Step 1
			GUICtrlSetData( $hGUI_2_Progress_1, $i)
			GUICtrlSetData( $hGUI_2_Label_1, $i & " %")
			Sleep(50)
		 Next
		 GUICtrlSetData( $hGUI_2_Progress_1, 0)
		 GUICtrlSetData( $hGUI_2_Label_1, "0 %")

   EndSwitch

   $WinGetPos1	= WinGetPos($hGUI_1)			; From $hGUI_1_StatusBarEx
   If $Pos1 <>	$WinGetPos1[0]&","&$WinGetPos1[1]&","&$WinGetPos1[2]&","&$WinGetPos1[3] Then
	  $Pos1 =	$WinGetPos1[0]&","&$WinGetPos1[1]&","&$WinGetPos1[2]&","&$WinGetPos1[3]
	  _GUICtrlStatusBar_SetText( $hGUI_1_StatusBarEx, $Pos1, 0)
   EndIf

   $WinGetPos2	= WinGetPos($hGUI_2)			; From $hGUI_2_StatusBarEx
   If $Pos2 <>	$WinGetPos2[0]&","&$WinGetPos2[1]&","&$WinGetPos2[2]&","&$WinGetPos2[3] Then
	  $Pos2 =	$WinGetPos2[0]&","&$WinGetPos2[1]&","&$WinGetPos2[2]&","&$WinGetPos2[3]
	  _GUICtrlStatusBar_SetText( $hGUI_2_StatusBarEx, $Pos2, 0)
   EndIf
WEnd

J'ai été diagnostiqué pour trouble de la concentration, soyez indulgent
Merci à tous pour votre aide.

Mon UDF GuiStatusBar facile
Avatar du membre
walkson
Modérateur
Modérateur
Messages : 1020
Enregistré le : ven. 12 août 2011 19:49
Localisation : Hurepoix
Status : Hors ligne

Re: [UDF] GuiStatusBar facile avec plusieurs GUI (GuiStatusBarEx.au3) update 22/04/2020, 04h15

#22

Message par walkson »

Bonjour,
Je viens de tester votre UDF ci-dessus et je n'ai rien à signaler sinon le scintillement quand on modifie la taille mais c'est pas trop dérangeant. Par contre, le label avec l'heure et la date scintille en continu. Personnellement, j'aurais utilisé un timer qui est "plus fluide" (voir _Timer_SetTimer() dans l'aide)

Au niveau de _GUICtrlStatusBarEx_CreateControl(), il serait bien de pouvoir modifier la couleur de la police en optionnel Size|weight|attribute|fontname|fontcolor (ça améliore le contraste avec le fond). Si vous adoptez ma proposition, n'oubliez pas de mettre à jour l'entête de l'UDF sinon l'utilisateur sera paumé :P
   Local $SetFontSplit
   If $SetFont <> "" Then
       $SetFontSplit = StringSplit($SetFont,"|")
      If Not IsArray($SetFontSplit) Then  Return SetError(1)
      If $SetFontSplit[0] = 4 Then GUICtrlSetFont($StatusBarEx_Object, $SetFontSplit[1],$SetFontSplit[2],$SetFontSplit[3],$SetFontSplit[4])
      If $SetFontSplit[0]     = 5 Then
         GUICtrlSetFont($StatusBarEx_Object, $SetFontSplit[1],$SetFontSplit[2],$SetFontSplit[3],$SetFontSplit[4])
         GUICtrlSetColor($StatusBarEx_Object, $SetFontSplit[5])
      EndIf
   EndIf


J'ai trouvé un code qui modifie la couleur du progressbar (vert, jaune ou rouge)
Global Const $PBST_NORMAL = 0x0001;vert
Global Const $PBST_ERROR = 0x0002;rouge
Global Const $PBST_PAUSED = 0x0003;jaune

; #FUNCTION# ====================================================================================================================
; Name ..........: _GUICtrlStatusBarEx_ColorProgressBar
; Description ...: Sets the state of the progressbar
; Syntax ........: _GUICtrlStatusBarEx_ColorProgressBar($iProgress, $iState)
; Parameters ....: $iProgress           - CtrlID of progressbar or -1 for the last created control.
;                  $iState              - new status of progress:
;                                |$PBM_NORMAL - normal state (green)
;                                |$PBM_ERROR - error state (red)
;                                |$PBM_PAUSED - paused style (yellow)
; Return values .: None
; Author ........: Prog@ndy
; Modified ......:
; Remarks .......: requires WinVista or above
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GUICtrlStatusBarEx_ColorProgressBar($iProgress, $iState)
   GUICtrlSendMsg($iProgress, $PBM_SETSTATE, $iState, 0)
EndFunc
Si je peux me permettre un dernier conseil, faites plusieurs exemples simples et esthétiques, ce sera plus "vendeur". Je rejoints l'opinion de Michel de ne pas trop vous disperser :mrgreen:
Sinon, c'est un beau travail
Cordialement,
Walkson
"Horas non numero nisi serenas " Le canon de midi
(Je ne compte que les heures heureuses)
Avatar du membre
mikell
Spammer !
Spammer !
Messages : 6292
Enregistré le : dim. 29 mai 2011 17:32
Localisation : Deep Cévennes
Status : Hors ligne

Re: [UDF] GuiStatusBar facile avec plusieurs GUI (GuiStatusBarEx.au3) update 22/04/2020, 04h15

#23

Message par mikell »

Vincent tu pourrais tester ça sur ton w7 ?
(rapport au scintillement quand on modifie la taille)

#include-once

#include <GuiStatusBar.au3>

#include <ButtonConstants.au3>
#include <Color.au3>
#include <ComboConstants.au3>
#include <Date.au3>
#include <GuiComboBox.au3>
#include <FontConstants.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WinAPISys.au3>
#include <WinAPISysWin.au3>
#include <WinAPITheme.au3>
#include <WindowsConstants.au3>
#include <WinAPIGdi.au3>

#include <Array.au3> ; _ArrayDisplay($aArray, "Infos")

; #VARIABLES# ===================================================================================================================
Global $exstyle, $StatusBarExGraphic
Global $MultiStatusBarEx[0][6]   ; $MultiStatusBarEx[1][6] = [["","","","","",""]]   ; $hBarEx devient $MultiStatusBarEx ; [["$SethWnd = $hGUI Num","Créé la StatusBar > _GUICtrlStatusBar_Create( $SethWnd)"]]
Global $StatusBarEx_Clock, $ClockStatusBarEx[0][2]
Global $DEBUG_StatusBarEx = '', $DEBUG_StatusBarEx_Sleep = 50  ; For DEBUG

; ===============================================================================================================================

Func _GUICtrlStatusBarEx_Create( $SethWnd="", $SetPartsEx="", $SetPartsHeightEx="", $SetStartColorEx="", $SetEndColorEx="")
   GUISwitch( $SethWnd)

   Local $avar[1][6] = [[$SethWnd, _GUICtrlStatusBar_Create( $SethWnd), $SetPartsHeightEx, "", $SetStartColorEx, $SetEndColorEx]]
   _ArrayAdd( $MultiStatusBarEx, $avar)
;~    _ArrayDisplay( $MultiStatusBarEx, "2D -> " & @ScriptLineNumber)
;~    ConsoleWrite('Line='&@ScriptLineNumber&", $SethWnd="&$MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][0]&", _GUICtrlStatusBar_Create( $SethWnd)="&$MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1]&", Count="&UBound($MultiStatusBarEx, 1)&@CRLF)
   $PartEx = StringSplit( StringReplace( $SetPartsEx, " ", ""), ",")
   Global $hPartsWidthEx[$PartEx[0]], $hPartsPosEx[$PartEx[0]][3]
   For $i = 1 To $PartEx[0]
     $hPartsWidthEx[$i-1]  = $PartEx[$i]
   Next
   If $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][4] Or $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][5] Then
     _WinAPI_SetWindowTheme( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1], "", "")
     Local $size = WinGetClientSize( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][0])
     _GUICtrlCreateGradient( $SethWnd, $SetStartColorEx, $SetEndColorEx, 0, 0, $size[0], $size[1]-$SetPartsHeightEx)
     If $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][5] Then _GUICtrlStatusBar_SetBkColor( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1], _WinAPI_SwitchColor( $SetEndColorEx))
   EndIf
   _GUICtrlStatusBar_SetMinHeight( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1], $SetPartsHeightEx)
   _GUICtrlStatusBar_SetParts( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1],-1, $hPartsWidthEx)
   If Not $DEBUG_StatusBarEx = '' Then GUISetState(@SW_SHOW, $SethWnd)
   For $i = 0 To $PartEx[0] -1
     $hPartsPosEx[$i][0] = GUICtrlCreateButton("This "&$i, -1, -1)         ; ID
     $hPartsPosEx[$i][1] = GUICtrlGetHandle( $hPartsPosEx[$i][0])       ; Handle
     _GUICtrlStatusBar_EmbedControl( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1], $i, $hPartsPosEx[$i][1], 4)
     Local $var = ControlGetPos( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][0],"",($hPartsPosEx[$i][0]))
     $hPartsPosEx[$i][2] = $var[0]&","&$var[1]&","&$var[2]&","&$var[3]
     If Not $DEBUG_StatusBarEx = '' Then Sleep($DEBUG_StatusBarEx_Sleep)
     GUICtrlDelete($hPartsPosEx[$i][0])
     If Not $DEBUG_StatusBarEx = '' Then Sleep($DEBUG_StatusBarEx_Sleep)
   Next
   If Not $DEBUG_StatusBarEx = '' Then GUISetState(@SW_HIDE, $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][0])

   GUIRegisterMsg($WM_SIZE, "_WM_SIZE")
   GUIRegisterMsg($WM_PAINT, "WM_PAINT")     
GUIRegisterMsg($WM_EXITSIZEMOVE, "_WM_EXITSIZEMOVE")
GUIRegisterMsg($WM_ENTERSIZEMOVE, "_WM_ENTERSIZEMOVE")

   Return $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1] ; Old > Return $SethWnd
EndFunc

; ===============================================================================================================================
Func _GUICtrlStatusBarEx_CreateControl( $hWnd="", $IndexControl="", $Ex_Part="", $Ex_Title="", $Ex_X="", $Ex_Y="", $Ex_W="", $Ex_H="", $Ex_Align="", $Style="", $Ex_Style="", $BkColor="", $SetFont="")

       If $IndexControl < 1 Or $IndexControl > 8 Then Return SetError(1)

       Local $var                   = StringSplit( $hPartsPosEx[$Ex_Part][2], ",")
            If    $Ex_Align = 'FIXED_LEFT'   Or $Ex_Align = 'SIZEABLE_LEFT'   Then
              Local $Bar_Ex_X=$var[1]+$Ex_X,          $Bar_Ex_Y=$var[2]+$Ex_Y,   $Bar_Ex_W=$Ex_W,           $Bar_Ex_H=$var[4]+$Ex_H
            ElseIf   $Ex_Align = 'FIXED_RIGHT'  Or $Ex_Align = 'SIZEABLE_RIGHT'  Then
              Local $Bar_Ex_X=$var[3]-$Ex_X-$Ex_W+$var[1],  $Bar_Ex_Y=$var[2]+$Ex_Y,   $Bar_Ex_W=$Ex_W,           $Bar_Ex_H=$var[4]+$Ex_H
            ElseIf   $Ex_Align = 'SIZEABLE_AUTO'                           Then
              Local $Bar_Ex_X=$var[1]+$Ex_X,          $Bar_Ex_Y=$var[2]+$Ex_Y,   $Bar_Ex_W=$var[3]+$Ex_W-$Ex_X,   $Bar_Ex_H=$var[4]+$Ex_H
            Else
              Local $Bar_Ex_X=$var[1]+$Ex_X,          $Bar_Ex_Y=$var[2]+$Ex_Y,   $Bar_Ex_W=$var[3]-$Ex_X,      $Bar_Ex_H=$var[4]+$Ex_H
            EndIf

       Switch $IndexControl
            Case 1
                $id_Ctrl   = GUICtrlCreateButton(     $Ex_Title,  $Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
            Case 2
                $id_Ctrl   = GUICtrlCreateCheckbox(   $Ex_Title,  $Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
            Case 3
                $id_Ctrl   = GUICtrlCreateCombo(      ""    ,  $Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
                $Ex_Split = StringSplit( $Ex_Title,"|")
                GUICtrlSetData( $id_Ctrl, StringTrimLeft( $Ex_Title, StringLen($Ex_Split[1]&"|")), $Ex_Split[1])
            Case 4
                $id_Ctrl   = GUICtrlCreateDate(    $Ex_Title,  $Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
            Case 5
                $id_Ctrl   = GUICtrlCreateInput(      $Ex_Title,  $Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
            Case 6
                $id_Ctrl   = GUICtrlCreateLabel(      $Ex_Title,  $Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
            Case 7
                $id_Ctrl = GUICtrlCreateProgress(              $Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
            Case 8
                $id_Ctrl   = GUICtrlCreateInput(      $Ex_Title,  $Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
                $Ex_Split = StringSplit( $Ex_Title,"|")
                GUICtrlSetLimit( GUICtrlCreateUpdown( $id_Ctrl), $Ex_Split[2], $Ex_Split[3]) ; $id_Ctrl, 15, 5
                GUICtrlSetData( $id_Ctrl, $Ex_Split[1])

       EndSwitch

   If $BkColor <> "" Then GUICtrlSetBkColor( $id_Ctrl, $BkColor)  ; GUICtrlSetBkColor($id_Ctrl, 0x00FF00)
   Local $SetFontSplit
   If $SetFont <> "" Then
         $SetFontSplit = StringSplit( $SetFont,"|")
              If Not IsArray( $SetFontSplit) Then  Return SetError(1)
              If $SetFontSplit[0]      = 4 Then GUICtrlSetFont( $id_Ctrl, $SetFontSplit[1],$SetFontSplit[2],$SetFontSplit[3],$SetFontSplit[4])
   EndIf

   If $Ex_Part = UBOUND( $hPartsPosEx)-1  Then
     If $Ex_Align = 'FIXED_LEFT'                                                 Then  GUICtrlSetResizing( -1, $GUI_DOCKLEFT  +  $GUI_DOCKSIZE + $GUI_DOCKBOTTOM)
     If $Ex_Align = 'FIXED_RIGHT'                                                   Then  GUICtrlSetResizing( -1,                $GUI_DOCKSIZE + $GUI_DOCKBOTTOM + $GUI_DOCKRIGHT)
     If $Ex_Align = 'SIZEABLE_LEFT' Or $Ex_Align = 'SIZEABLE_RIGHT' Or $Ex_Align = 'SIZEABLE_AUTO' Then  GUICtrlSetResizing( -1, $GUI_DOCKLEFT  +  $GUI_DOCKSIZE + $GUI_DOCKBOTTOM + $GUI_DOCKRIGHT)
   Else
     GUICtrlSetResizing( $id_Ctrl, $GUI_DOCKLEFT   + $GUI_DOCKSIZE + $GUI_DOCKBOTTOM)
   EndIf

   For $i = 0 To UBound($MultiStatusBarEx, 1)-1
     If $hWnd = $MultiStatusBarEx[$i][0] Then
       _WinAPI_SetWindowPos( $MultiStatusBarEx[$i][1], $HWND_BOTTOM, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE))
     EndIf
   Next

   Return $id_Ctrl
EndFunc

;====================================

Func _GUICtrlStatusBarEx_CreateFunc( $id_Ctrl="", $IndexFunc="", $Options="")
   If $IndexFunc < 1 Or $IndexFunc > 1 Then Return SetError(1)

   Switch $IndexFunc
      Case 1
      Local $avar[1][2] = [[$id_Ctrl, $Options]]
      _ArrayAdd( $ClockStatusBarEx, $avar)
      If Not $StatusBarEx_Clock Then
         $StatusBarEx_Clock = 1
         _BarEx_Func_CLOCK()
         AdlibRegister( "_BarEx_Func_CLOCK", 1000)
      EndIf
   EndSwitch
EndFunc

Func _BarEx_Func_CLOCK()
   For $i = 0 To UBound($ClockStatusBarEx, 1)-1
     GUICtrlSetData( $ClockStatusBarEx[$i][0], _DateTimeFormat( _NowCalc(), $ClockStatusBarEx[$i][1]))
   Next
EndFunc

;======================================

Func _GUICtrlCreateGradient( $hWnd, $nStartColor, $nEndColor, $nX, $nY, $nWidth, $nHeight)
   _WinAPI_SetWindowTheme( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1], "", "")
   For $i = 0 To UBound($MultiStatusBarEx, 1)-1
     If $hWnd = $MultiStatusBarEx[$i][0] And $MultiStatusBarEx[$i][4] Then
       Local $color1R = _ColorGetRed($nStartColor)
       Local $color1G = _ColorGetGreen($nStartColor)
       Local $color1B = _ColorGetBlue($nStartColor)

       Local $nStepR = (_ColorGetRed($nEndColor) - $color1R) / $nHeight
       Local $nStepG = (_ColorGetGreen($nEndColor) - $color1G) / $nHeight
       Local $nStepB = (_ColorGetBlue($nEndColor) - $color1B) / $nHeight

       If $MultiStatusBarEx[$i][3] <> "" Then GUICtrlDelete( $MultiStatusBarEx[$i][3])
       $MultiStatusBarEx[$i][3] = GuiCtrlCreateGraphic($nX, $nY, $nWidth, $nHeight, $TCS_BOTTOM)

       For $j = 0 To $nHeight - $nY
         $sColor = "0x" & StringFormat("%02X%02X%02X", $color1R+$nStepR*$j, $color1G+$nStepG*$j, $color1B+$nStepB*$j)
         GUICtrlSetGraphic( $MultiStatusBarEx[$i][3], $GUI_GR_COLOR, $sColor, 0xffffff)
         GUICtrlSetGraphic( $MultiStatusBarEx[$i][3], $GUI_GR_MOVE, 0, $j)
         GUICtrlSetGraphic( $MultiStatusBarEx[$i][3], $GUI_GR_LINE, $nWidth, $j)
       Next
     EndIf
   Next
EndFunc



; ===============================================================================================================================
Func _WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)
   For $i = 0 To UBound($MultiStatusBarEx, 1)-1
     If $hWnd = $MultiStatusBarEx[$i][0] Then
       GUISwitch($MultiStatusBarEx[$i][0])
       _GUICtrlStatusBar_Resize( $MultiStatusBarEx[$i][1])
       Local $size = WinGetClientSize( $MultiStatusBarEx[$i][0])
       _GUICtrlCreateGradient( $MultiStatusBarEx[$i][0], $MultiStatusBarEx[$i][4], $MultiStatusBarEx[$i][5], 0, 0, $size[0], $size[1]-$MultiStatusBarEx[$i][2])
     EndIf
   Next
   Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE


Func WM_PAINT($hWnd, $msg, $wParam, $lParam)
   For $i = 0 To UBound($MultiStatusBarEx, 1)-1
    ; If $hWnd = $MultiStatusBarEx[$i][0] or $hWnd = $MultiStatusBarEx[$i][1] Then
      $tRECT = _WinAPI_GetWindowRect($MultiStatusBarEx[$i][1])
      _WinAPI_SetWindowPos( $MultiStatusBarEx[$i][1], $HWND_BOTTOM, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE))
     _WinAPI_RedrawWindow( $MultiStatusBarEx[$i][1], $tRECT, "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW))
   ;  EndIf
   Next
   Return $GUI_RUNDEFMSG
EndFunc


Func _WM_ENTERSIZEMOVE($hWnd, $msg, $wParam, $lParam)
   For $i = 0 To UBound($MultiStatusBarEx, 1)-1
     If $hWnd = $MultiStatusBarEx[$i][0] Then
        $exstyle = _WinAPI_GetWindowLong( $hWnd, $GWL_EXSTYLE)
        _WinAPI_SetWindowLong( $hWnd, $GWL_EXSTYLE, $WS_EX_COMPOSITED)
    EndIf
   Next
   Return $GUI_RUNDEFMSG
EndFunc

Func _WM_EXITSIZEMOVE($hWnd, $msg, $wParam, $lParam)
   For $i = 0 To UBound($MultiStatusBarEx, 1)-1
     If $hWnd = $MultiStatusBarEx[$i][0] Then
      _WinAPI_SetWindowLong( $hWnd, $GWL_EXSTYLE, $exstyle )
    EndIf
   Next
   Return $GUI_RUNDEFMSG
EndFunc
 
" L'échec est le fondement de la réussite. " (Lao-Tseu )
" Plus ça rate, plus on a de chances que ça marche " (les Shadoks )
Avatar du membre
Anthony
Niveau 6
Niveau 6
Messages : 292
Enregistré le : lun. 17 janv. 2011 14:08
Localisation : France
Status : Hors ligne

Re: [UDF] GuiStatusBar facile avec plusieurs GUI (GuiStatusBarEx.au3) update 22/04/2020, 04h15

#24

Message par Anthony »

walkson a écrit : sam. 25 avr. 2020 15:42 Au niveau de _GUICtrlStatusBarEx_CreateControl(), il serait bien de pouvoir modifier la couleur de la police en optionnel Size|weight|attribute|fontname|fontcolor (ça améliore le contraste avec le fond). Si vous adoptez ma proposition, n'oubliez pas de mettre à jour l'entête de l'UDF sinon l'utilisateur sera paumé :P
   Local $SetFontSplit
   If $SetFont <> "" Then
       $SetFontSplit = StringSplit($SetFont,"|")
      If Not IsArray($SetFontSplit) Then  Return SetError(1)
      If $SetFontSplit[0] = 4 Then GUICtrlSetFont($StatusBarEx_Object, $SetFontSplit[1],$SetFontSplit[2],$SetFontSplit[3],$SetFontSplit[4])
      If $SetFontSplit[0]     = 5 Then
         GUICtrlSetFont($StatusBarEx_Object, $SetFontSplit[1],$SetFontSplit[2],$SetFontSplit[3],$SetFontSplit[4])
         GUICtrlSetColor($StatusBarEx_Object, $SetFontSplit[5])
      EndIf
   EndIf
Intégré :wink:

Dites moi si çà convient, il me semble que le code que vous utilisez est ancien: $StatusBarEx_Object est devenu $id_Ctrl ainsi que d'autres variables afin de se rapprocher d'une UDF, mes plates excuses :wink:
GuiStatusBarEx.au3
(23.33 Kio) Téléchargé 7070 fois
GuiStatusBarEx - UDF DEMO.au3
(10.87 Kio) Téléchargé 7070 fois
walkson a écrit : sam. 25 avr. 2020 15:42 J'ai trouvé un code qui modifie la couleur du progressbar (vert, jaune ou rouge)
Global Const $PBST_NORMAL = 0x0001;vert
Global Const $PBST_ERROR = 0x0002;rouge
Global Const $PBST_PAUSED = 0x0003;jaune

; #FUNCTION# ====================================================================================================================
; Name ..........: _GUICtrlStatusBarEx_ColorProgressBar
; Description ...: Sets the state of the progressbar
; Syntax ........: _GUICtrlStatusBarEx_ColorProgressBar($iProgress, $iState)
; Parameters ....: $iProgress           - CtrlID of progressbar or -1 for the last created control.
;                  $iState              - new status of progress:
;                                |$PBM_NORMAL - normal state (green)
;                                |$PBM_ERROR - error state (red)
;                                |$PBM_PAUSED - paused style (yellow)
; Return values .: None
; Author ........: Prog@ndy
; Modified ......:
; Remarks .......: requires WinVista or above
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GUICtrlStatusBarEx_ColorProgressBar($iProgress, $iState)
   GUICtrlSendMsg($iProgress, $PBM_SETSTATE, $iState, 0)
EndFunc
Je ne vois pas comment l'intégrer :idea:

Func _GUICtrlStatusBarEx_CreateFunc( $id_Ctrl="", $IndexFunc="", $Options="")
If $IndexFunc < 1 Or $IndexFunc > 1 Then Return SetError(1)

Switch $IndexFunc
Case 1
Local $avar[1][2] = [[$id_Ctrl, $Options]]
_ArrayAdd( $ClockStatusBarEx, $avar)
_BarEx_Func_CLOCK()
Case 2
GUICtrlSendMsg($id_Ctrl, $PBM_SETSTATE, $iState, 0)

EndSwitch
EndFunc
walkson a écrit : sam. 25 avr. 2020 15:42 Si je peux me permettre un dernier conseil, faites plusieurs exemples simples et esthétiques, ce sera plus "vendeur". Je rejoints l'opinion de Michel de ne pas trop vous disperser :mrgreen:
Sinon, c'est un beau travail
Oui plusieurs exemples sont prévu après le crash test, je sais çà fait gros pavé, et comme le dit mikell il faut faire un crash test... Es-ce la bonne méthode ?
Sinon je change.
Je voulais aussi donner la possibilité d'avoir le fond de la GUI et de la StatusBar en une seule étape dans en multi GUI (Le gradient est un plus c'est une option on peut faire une seule couleur de fond pour StartColor et EndColor)
Mais je fais peut-être fausse route et si c'est mieux de la retirer alors je la retirerai :wink:
; #FUNCTION#=====================================================================================================================
; Author ........: Anthony Baillou
; Modified.......: Anthony Baillou, walkson, mikell
;
; Name ..........: _GUICtrlStatusBarEx_Create
; Description ...: Ajoute une StatusBar dans le Handle d'une GUI
; Syntax ........: _GUICtrlStatusBarEx_Create( $hWnd, $SetPartsEx, $SetPartsHeightEx, $SetStartColorEx, $SetEndColorEx)
; Parameters ....: $hWnd                - Handle de la GUI cible.
;                  $SetPartsEx          - [needed] "Pos 1,Pos 2,Pos 3,Pos...".                            Eg: "100,50,85,240,75,-1"
;                  $SetPartsHeightEx    - [needed] "Height for parts"                                     Eg: 25
;                  $SetBackGroundEx     - [optional] "StartColor|EndColor|StatusBarColor". Default is "". Eg: "0xCCAAFF|0xFFAACC|0x00F0FF"
;                                                                                       Order:      "0xRRGGBB".
; ===============================================================================================================================
Modifié en dernier par Anthony le dim. 26 avr. 2020 13:47, modifié 6 fois.
J'ai été diagnostiqué pour trouble de la concentration, soyez indulgent
Merci à tous pour votre aide.

Mon UDF GuiStatusBar facile
Avatar du membre
Anthony
Niveau 6
Niveau 6
Messages : 292
Enregistré le : lun. 17 janv. 2011 14:08
Localisation : France
Status : Hors ligne

Re: [UDF] GuiStatusBar facile avec plusieurs GUI (GuiStatusBarEx.au3) update 22/04/2020, 04h15

#25

Message par Anthony »

mikell a écrit : sam. 25 avr. 2020 22:39 Vincent tu pourrais tester ça sur ton w7 ?
(rapport au scintillement quand on modifie la taille)

#include-once

#include <GuiStatusBar.au3>

#include <ButtonConstants.au3>
#include <Color.au3>
#include <ComboConstants.au3>
#include <Date.au3>
#include <GuiComboBox.au3>
#include <FontConstants.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WinAPISys.au3>
#include <WinAPISysWin.au3>
#include <WinAPITheme.au3>
#include <WindowsConstants.au3>
#include <WinAPIGdi.au3>

#include <Array.au3> ; _ArrayDisplay($aArray, "Infos")

; #VARIABLES# ===================================================================================================================
Global $exstyle, $StatusBarExGraphic
Global $MultiStatusBarEx[0][6]   ; $MultiStatusBarEx[1][6] = [["","","","","",""]]   ; $hBarEx devient $MultiStatusBarEx ; [["$SethWnd = $hGUI Num","Créé la StatusBar > _GUICtrlStatusBar_Create( $SethWnd)"]]
Global $StatusBarEx_Clock, $ClockStatusBarEx[0][2]
Global $DEBUG_StatusBarEx = '', $DEBUG_StatusBarEx_Sleep = 50  ; For DEBUG

; ===============================================================================================================================

Func _GUICtrlStatusBarEx_Create( $SethWnd="", $SetPartsEx="", $SetPartsHeightEx="", $SetStartColorEx="", $SetEndColorEx="")
   GUISwitch( $SethWnd)

   Local $avar[1][6] = [[$SethWnd, _GUICtrlStatusBar_Create( $SethWnd), $SetPartsHeightEx, "", $SetStartColorEx, $SetEndColorEx]]
   _ArrayAdd( $MultiStatusBarEx, $avar)
;~    _ArrayDisplay( $MultiStatusBarEx, "2D -> " & @ScriptLineNumber)
;~    ConsoleWrite('Line='&@ScriptLineNumber&", $SethWnd="&$MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][0]&", _GUICtrlStatusBar_Create( $SethWnd)="&$MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1]&", Count="&UBound($MultiStatusBarEx, 1)&@CRLF)
   $PartEx = StringSplit( StringReplace( $SetPartsEx, " ", ""), ",")
   Global $hPartsWidthEx[$PartEx[0]], $hPartsPosEx[$PartEx[0]][3]
   For $i = 1 To $PartEx[0]
     $hPartsWidthEx[$i-1]  = $PartEx[$i]
   Next
   If $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][4] Or $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][5] Then
     _WinAPI_SetWindowTheme( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1], "", "")
     Local $size = WinGetClientSize( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][0])
     _GUICtrlCreateGradient( $SethWnd, $SetStartColorEx, $SetEndColorEx, 0, 0, $size[0], $size[1]-$SetPartsHeightEx)
     If $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][5] Then _GUICtrlStatusBar_SetBkColor( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1], _WinAPI_SwitchColor( $SetEndColorEx))
   EndIf
   _GUICtrlStatusBar_SetMinHeight( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1], $SetPartsHeightEx)
   _GUICtrlStatusBar_SetParts( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1],-1, $hPartsWidthEx)
   If Not $DEBUG_StatusBarEx = '' Then GUISetState(@SW_SHOW, $SethWnd)
   For $i = 0 To $PartEx[0] -1
     $hPartsPosEx[$i][0] = GUICtrlCreateButton("This "&$i, -1, -1)         ; ID
     $hPartsPosEx[$i][1] = GUICtrlGetHandle( $hPartsPosEx[$i][0])       ; Handle
     _GUICtrlStatusBar_EmbedControl( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1], $i, $hPartsPosEx[$i][1], 4)
     Local $var = ControlGetPos( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][0],"",($hPartsPosEx[$i][0]))
     $hPartsPosEx[$i][2] = $var[0]&","&$var[1]&","&$var[2]&","&$var[3]
     If Not $DEBUG_StatusBarEx = '' Then Sleep($DEBUG_StatusBarEx_Sleep)
     GUICtrlDelete($hPartsPosEx[$i][0])
     If Not $DEBUG_StatusBarEx = '' Then Sleep($DEBUG_StatusBarEx_Sleep)
   Next
   If Not $DEBUG_StatusBarEx = '' Then GUISetState(@SW_HIDE, $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][0])

   GUIRegisterMsg($WM_SIZE, "_WM_SIZE")
   GUIRegisterMsg($WM_PAINT, "WM_PAINT")     
GUIRegisterMsg($WM_EXITSIZEMOVE, "_WM_EXITSIZEMOVE")
GUIRegisterMsg($WM_ENTERSIZEMOVE, "_WM_ENTERSIZEMOVE")

   Return $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1] ; Old > Return $SethWnd
EndFunc

; ===============================================================================================================================
Func _GUICtrlStatusBarEx_CreateControl( $hWnd="", $IndexControl="", $Ex_Part="", $Ex_Title="", $Ex_X="", $Ex_Y="", $Ex_W="", $Ex_H="", $Ex_Align="", $Style="", $Ex_Style="", $BkColor="", $SetFont="")

       If $IndexControl < 1 Or $IndexControl > 8 Then Return SetError(1)

       Local $var                   = StringSplit( $hPartsPosEx[$Ex_Part][2], ",")
            If    $Ex_Align = 'FIXED_LEFT'   Or $Ex_Align = 'SIZEABLE_LEFT'   Then
              Local $Bar_Ex_X=$var[1]+$Ex_X,          $Bar_Ex_Y=$var[2]+$Ex_Y,   $Bar_Ex_W=$Ex_W,           $Bar_Ex_H=$var[4]+$Ex_H
            ElseIf   $Ex_Align = 'FIXED_RIGHT'  Or $Ex_Align = 'SIZEABLE_RIGHT'  Then
              Local $Bar_Ex_X=$var[3]-$Ex_X-$Ex_W+$var[1],  $Bar_Ex_Y=$var[2]+$Ex_Y,   $Bar_Ex_W=$Ex_W,           $Bar_Ex_H=$var[4]+$Ex_H
            ElseIf   $Ex_Align = 'SIZEABLE_AUTO'                           Then
              Local $Bar_Ex_X=$var[1]+$Ex_X,          $Bar_Ex_Y=$var[2]+$Ex_Y,   $Bar_Ex_W=$var[3]+$Ex_W-$Ex_X,   $Bar_Ex_H=$var[4]+$Ex_H
            Else
              Local $Bar_Ex_X=$var[1]+$Ex_X,          $Bar_Ex_Y=$var[2]+$Ex_Y,   $Bar_Ex_W=$var[3]-$Ex_X,      $Bar_Ex_H=$var[4]+$Ex_H
            EndIf

       Switch $IndexControl
            Case 1
                $id_Ctrl   = GUICtrlCreateButton(     $Ex_Title,  $Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
            Case 2
                $id_Ctrl   = GUICtrlCreateCheckbox(   $Ex_Title,  $Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
            Case 3
                $id_Ctrl   = GUICtrlCreateCombo(      ""    ,  $Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
                $Ex_Split = StringSplit( $Ex_Title,"|")
                GUICtrlSetData( $id_Ctrl, StringTrimLeft( $Ex_Title, StringLen($Ex_Split[1]&"|")), $Ex_Split[1])
            Case 4
                $id_Ctrl   = GUICtrlCreateDate(    $Ex_Title,  $Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
            Case 5
                $id_Ctrl   = GUICtrlCreateInput(      $Ex_Title,  $Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
            Case 6
                $id_Ctrl   = GUICtrlCreateLabel(      $Ex_Title,  $Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
            Case 7
                $id_Ctrl = GUICtrlCreateProgress(              $Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
            Case 8
                $id_Ctrl   = GUICtrlCreateInput(      $Ex_Title,  $Bar_Ex_X, $Bar_Ex_Y, $Bar_Ex_W, $Bar_Ex_H, BitOR( $Style, $Ex_Style))
                $Ex_Split = StringSplit( $Ex_Title,"|")
                GUICtrlSetLimit( GUICtrlCreateUpdown( $id_Ctrl), $Ex_Split[2], $Ex_Split[3]) ; $id_Ctrl, 15, 5
                GUICtrlSetData( $id_Ctrl, $Ex_Split[1])

       EndSwitch

   If $BkColor <> "" Then GUICtrlSetBkColor( $id_Ctrl, $BkColor)  ; GUICtrlSetBkColor($id_Ctrl, 0x00FF00)
   Local $SetFontSplit
   If $SetFont <> "" Then
         $SetFontSplit = StringSplit( $SetFont,"|")
              If Not IsArray( $SetFontSplit) Then  Return SetError(1)
              If $SetFontSplit[0]      = 4 Then GUICtrlSetFont( $id_Ctrl, $SetFontSplit[1],$SetFontSplit[2],$SetFontSplit[3],$SetFontSplit[4])
   EndIf

   If $Ex_Part = UBOUND( $hPartsPosEx)-1  Then
     If $Ex_Align = 'FIXED_LEFT'                                                 Then  GUICtrlSetResizing( -1, $GUI_DOCKLEFT  +  $GUI_DOCKSIZE + $GUI_DOCKBOTTOM)
     If $Ex_Align = 'FIXED_RIGHT'                                                   Then  GUICtrlSetResizing( -1,                $GUI_DOCKSIZE + $GUI_DOCKBOTTOM + $GUI_DOCKRIGHT)
     If $Ex_Align = 'SIZEABLE_LEFT' Or $Ex_Align = 'SIZEABLE_RIGHT' Or $Ex_Align = 'SIZEABLE_AUTO' Then  GUICtrlSetResizing( -1, $GUI_DOCKLEFT  +  $GUI_DOCKSIZE + $GUI_DOCKBOTTOM + $GUI_DOCKRIGHT)
   Else
     GUICtrlSetResizing( $id_Ctrl, $GUI_DOCKLEFT   + $GUI_DOCKSIZE + $GUI_DOCKBOTTOM)
   EndIf

   For $i = 0 To UBound($MultiStatusBarEx, 1)-1
     If $hWnd = $MultiStatusBarEx[$i][0] Then
       _WinAPI_SetWindowPos( $MultiStatusBarEx[$i][1], $HWND_BOTTOM, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE))
     EndIf
   Next

   Return $id_Ctrl
EndFunc

;====================================

Func _GUICtrlStatusBarEx_CreateFunc( $id_Ctrl="", $IndexFunc="", $Options="")
   If $IndexFunc < 1 Or $IndexFunc > 1 Then Return SetError(1)

   Switch $IndexFunc
      Case 1
      Local $avar[1][2] = [[$id_Ctrl, $Options]]
      _ArrayAdd( $ClockStatusBarEx, $avar)
      If Not $StatusBarEx_Clock Then
         $StatusBarEx_Clock = 1
         _BarEx_Func_CLOCK()
         AdlibRegister( "_BarEx_Func_CLOCK", 1000)
      EndIf
   EndSwitch
EndFunc

Func _BarEx_Func_CLOCK()
   For $i = 0 To UBound($ClockStatusBarEx, 1)-1
     GUICtrlSetData( $ClockStatusBarEx[$i][0], _DateTimeFormat( _NowCalc(), $ClockStatusBarEx[$i][1]))
   Next
EndFunc

;======================================

Func _GUICtrlCreateGradient( $hWnd, $nStartColor, $nEndColor, $nX, $nY, $nWidth, $nHeight)
   _WinAPI_SetWindowTheme( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1], "", "")
   For $i = 0 To UBound($MultiStatusBarEx, 1)-1
     If $hWnd = $MultiStatusBarEx[$i][0] And $MultiStatusBarEx[$i][4] Then
       Local $color1R = _ColorGetRed($nStartColor)
       Local $color1G = _ColorGetGreen($nStartColor)
       Local $color1B = _ColorGetBlue($nStartColor)

       Local $nStepR = (_ColorGetRed($nEndColor) - $color1R) / $nHeight
       Local $nStepG = (_ColorGetGreen($nEndColor) - $color1G) / $nHeight
       Local $nStepB = (_ColorGetBlue($nEndColor) - $color1B) / $nHeight

       If $MultiStatusBarEx[$i][3] <> "" Then GUICtrlDelete( $MultiStatusBarEx[$i][3])
       $MultiStatusBarEx[$i][3] = GuiCtrlCreateGraphic($nX, $nY, $nWidth, $nHeight, $TCS_BOTTOM)

       For $j = 0 To $nHeight - $nY
         $sColor = "0x" & StringFormat("%02X%02X%02X", $color1R+$nStepR*$j, $color1G+$nStepG*$j, $color1B+$nStepB*$j)
         GUICtrlSetGraphic( $MultiStatusBarEx[$i][3], $GUI_GR_COLOR, $sColor, 0xffffff)
         GUICtrlSetGraphic( $MultiStatusBarEx[$i][3], $GUI_GR_MOVE, 0, $j)
         GUICtrlSetGraphic( $MultiStatusBarEx[$i][3], $GUI_GR_LINE, $nWidth, $j)
       Next
     EndIf
   Next
EndFunc



; ===============================================================================================================================
Func _WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)
   For $i = 0 To UBound($MultiStatusBarEx, 1)-1
     If $hWnd = $MultiStatusBarEx[$i][0] Then
       GUISwitch($MultiStatusBarEx[$i][0])
       _GUICtrlStatusBar_Resize( $MultiStatusBarEx[$i][1])
       Local $size = WinGetClientSize( $MultiStatusBarEx[$i][0])
       _GUICtrlCreateGradient( $MultiStatusBarEx[$i][0], $MultiStatusBarEx[$i][4], $MultiStatusBarEx[$i][5], 0, 0, $size[0], $size[1]-$MultiStatusBarEx[$i][2])
     EndIf
   Next
   Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE


Func WM_PAINT($hWnd, $msg, $wParam, $lParam)
   For $i = 0 To UBound($MultiStatusBarEx, 1)-1
    ; If $hWnd = $MultiStatusBarEx[$i][0] or $hWnd = $MultiStatusBarEx[$i][1] Then
      $tRECT = _WinAPI_GetWindowRect($MultiStatusBarEx[$i][1])
      _WinAPI_SetWindowPos( $MultiStatusBarEx[$i][1], $HWND_BOTTOM, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE))
     _WinAPI_RedrawWindow( $MultiStatusBarEx[$i][1], $tRECT, "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW))
   ;  EndIf
   Next
   Return $GUI_RUNDEFMSG
EndFunc


Func _WM_ENTERSIZEMOVE($hWnd, $msg, $wParam, $lParam)
   For $i = 0 To UBound($MultiStatusBarEx, 1)-1
     If $hWnd = $MultiStatusBarEx[$i][0] Then
        $exstyle = _WinAPI_GetWindowLong( $hWnd, $GWL_EXSTYLE)
        _WinAPI_SetWindowLong( $hWnd, $GWL_EXSTYLE, $WS_EX_COMPOSITED)
    EndIf
   Next
   Return $GUI_RUNDEFMSG
EndFunc

Func _WM_EXITSIZEMOVE($hWnd, $msg, $wParam, $lParam)
   For $i = 0 To UBound($MultiStatusBarEx, 1)-1
     If $hWnd = $MultiStatusBarEx[$i][0] Then
      _WinAPI_SetWindowLong( $hWnd, $GWL_EXSTYLE, $exstyle )
    EndIf
   Next
   Return $GUI_RUNDEFMSG
EndFunc
 
J'ai refait une petite vidéo, Jusqu'à 2 minutes c'est mon code, après 2 minutes c'est le tiens :wink:
https://youtu.be/t9DfkqIYqT0
J'ai été diagnostiqué pour trouble de la concentration, soyez indulgent
Merci à tous pour votre aide.

Mon UDF GuiStatusBar facile
Avatar du membre
mikell
Spammer !
Spammer !
Messages : 6292
Enregistré le : dim. 29 mai 2011 17:32
Localisation : Deep Cévennes
Status : Hors ligne

Re: [UDF] GuiStatusBar facile avec plusieurs GUI (GuiStatusBarEx.au3) update 26/04/2020, 01h15

#26

Message par mikell »

Hé oui... sur mon vieil OS j'ai besoin des 2 funcs *sizemove pour ne pas l'avoir ce scintillement
Mais sur ton w10 ça vient peut-être juste du fait que j'ai commenté un "IF" dans wm_paint
Faudrait voir ce que va dire walkson mais ça montre bien le problème de compatibilité de certains scripts sur différents OS
" L'échec est le fondement de la réussite. " (Lao-Tseu )
" Plus ça rate, plus on a de chances que ça marche " (les Shadoks )
Avatar du membre
walkson
Modérateur
Modérateur
Messages : 1020
Enregistré le : ven. 12 août 2011 19:49
Localisation : Hurepoix
Status : Hors ligne

Re: [UDF] GuiStatusBar facile avec plusieurs GUI (GuiStatusBarEx.au3) update 26/04/2020, 01h15

#27

Message par walkson »

Bonjour,
J'ai le même résultat que Anthony
J'ai testé le code ci-dessus et en effet les contrôles de la GUI fille disparaissent quand on modifie la GUI mère.
Si on désactive _GUICtrlCreateGradient() dans la fonction SIZE, les contrôles restent apparent.
J'ai essayé de faire un dégradé sur un label avec GDI mais je n'ai pas réussit, le dégradé n'apparait pas bien que j'obtienne le handle du bitmap :?:
Je mets le code à tout hasard (il fonctionne en l'état)
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
#include <StaticConstants.au3>
#include <GuiStatusBar.au3>
#include <WinAPITheme.au3>
#include <Timers.au3>

Example()

Func Example()

   Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBgColor format RRGGBB

   Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
   GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
   GUISetStyle(BitOR($WS_MINIMIZEBOX,  $WS_SIZEBOX, $WS_CAPTION, $WS_SYSMENU))
   $label = GUICtrlCreateLabel("", 0, 0, $iWidth, $iHeight, $SS_BITMAP )
   GradientToControl($label, $iWidth, $iHeight, 0xFF005530, 0xFF005FFF,1)
   $label = GUICtrlCreateInput("texte ici", 20, 50, 100,25)
   $button = GUICtrlCreateButton("OK",125,50,100,25)
   GUICtrlCreateLabel("< LABEL >",260,50,100)
   GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
   GUICtrlSetFont(-1,12,600,4,'courier new')
   Local $aParts[3] = [75, 150, -1]
   Global $g_hStatus = _GUICtrlStatusBar_Create($hGUI)
   _GUICtrlStatusBar_SetParts($g_hStatus, $aParts)
   _GUICtrlStatusBar_SetBkColor($g_hStatus, _WinAPI_SwitchColor( 0x005fff))
   _GUICtrlStatusBar_SetText($g_hStatus, "AAAA", 0)
   _GUICtrlStatusBar_SetText($g_hStatus, "BBB", 1 )
    _GUICtrlStatusBar_SetMinHeight($g_hStatus, 30)
   _WinAPI_SetWindowTheme( $g_hStatus, "", "")
   GUISetState(@SW_SHOW)
   _Timer_SetTimer($hGUI, 1000, "_UpdateStatusBarClock")
   GUIRegisterMsg($WM_SIZE, "_WM_SIZE")
   Do
   Until GUIGetMsg() = $GUI_EVENT_CLOSE
   _Timer_KillAllTimers($hGUI)
   GUIDelete($hGUI)
EndFunc   ;==>Example
Func GradientToControl($label, $iWidth, $iHeight, $Argb_1, $Argb_2, $nbPart = 1)
   GUICtrlSetState($label,128)
   $Hlabel = GUICtrlGetHandle($label)
   _GDIPlus_Startup() ;initialize GDI+
   Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($Hlabel) ;create a graphics object from a window handle
    $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics) ;create a Bitmap object based on a graphics object
    $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap)
   _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
   Local $hBrush = _GDIPlus_LineBrushCreate($iWidth, 0, $iWidth, $iHeight/$nbPart, $Argb_1, $Argb_2, 1) ;create linear gradient brush

   _GDIPlus_GraphicsFillRect($g_hGfxCtxt, 0, 0, $iWidth, $iHeight, $hBrush) ;draw the egg
   _GDIPlus_GraphicsDrawImage($hGraphics, $g_hBitmap, 0, 0)
   $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($g_hBitmap)
   _SendMessage($Hlabel, $STM_SETIMAGE, 0, $hBitmap)
   Local $hObj = _SendMessage($Hlabel, $STM_GETIMAGE)
   If $hObj <> $hBitmap Then
      _WinAPI_DeleteObject($hBitmap)
   EndIf
   _GDIPlus_BrushDispose($hBrush)
   _GDIPlus_GraphicsDispose($hGraphics)
   _GDIPlus_GraphicsDispose($g_hGfxCtxt)
   _GDIPlus_BitmapDispose($g_hBitmap)
   _GDIPlus_Shutdown()
EndFunc
Func _WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)
   _GUICtrlStatusBar_Resize( $g_hStatus)
   Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE
Func _UpdateStatusBarClock($hWnd, $iMsg, $iIDTimer, $iTime)
    #forceref $hWnd, $iMsg, $iIDTimer, $iTime
    _GUICtrlStatusBar_SetText($g_hStatus,@TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2)
EndFunc   ;==>_UpdateStatusBarClock
L'avantage est de ne pas repeindre à chaque redimensionnement... L'inconvénient (quand ça marche) est de mettre le label en premier sinon on n'a plus accès aux autres contrôles de la GUI
Cordialement,
Walkson
"Horas non numero nisi serenas " Le canon de midi
(Je ne compte que les heures heureuses)
Avatar du membre
Anthony
Niveau 6
Niveau 6
Messages : 292
Enregistré le : lun. 17 janv. 2011 14:08
Localisation : France
Status : Hors ligne

Re: [UDF] GuiStatusBar facile avec plusieurs GUI (GuiStatusBarEx.au3) update 26/04/2020, 01h15

#28

Message par Anthony »

Génial çà avance, problème localisé :bisou: c'est la perfection sur Win X et Windows 7 ? je vais mettre à jour le Post 1
viewtopic.php?f=21&t=15370

Code : Tout sélectionner

Func _GUICtrlCreateGradient( $hWnd, $nStartColor, $nEndColor, $nX, $nY, $nWidth, $nHeight)
;~    _WinAPI_SetWindowTheme( $MultiStatusBarEx[UBound($MultiStatusBarEx, 1)-1][1], "", "") <= Vilaine coupable à retirer
   For $i = 0 To UBound($MultiStatusBarEx, 1)-1
;...
walkson a écrit : dim. 26 avr. 2020 19:31 Bonjour,
J'ai le même résultat que Anthony
J'ai testé le code ci-dessus et en effet les contrôles de la GUI fille disparaissent quand on modifie la GUI mère.
Si on désactive _GUICtrlCreateGradient() dans la fonction SIZE, les contrôles restent apparent.
J'ai essayé de faire un dégradé sur un label avec GDI mais je n'ai pas réussit, le dégradé n'apparait pas bien que j'obtienne le handle du bitmap :?:
Je mets le code à tout hasard (il fonctionne en l'état)
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
#include <StaticConstants.au3>
#include <GuiStatusBar.au3>
#include <WinAPITheme.au3>
#include <Timers.au3>

Example()

Func Example()

   Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBgColor format RRGGBB

   Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
   GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
   GUISetStyle(BitOR($WS_MINIMIZEBOX,  $WS_SIZEBOX, $WS_CAPTION, $WS_SYSMENU))
   $label = GUICtrlCreateLabel("", 0, 0, $iWidth, $iHeight, $SS_BITMAP )
   GradientToControl($label, $iWidth, $iHeight, 0xFF005530, 0xFF005FFF,1)
   $label = GUICtrlCreateInput("texte ici", 20, 50, 100,25)
   $button = GUICtrlCreateButton("OK",125,50,100,25)
   GUICtrlCreateLabel("< LABEL >",260,50,100)
   GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
   GUICtrlSetFont(-1,12,600,4,'courier new')
   Local $aParts[3] = [75, 150, -1]
   Global $g_hStatus = _GUICtrlStatusBar_Create($hGUI)
   _GUICtrlStatusBar_SetParts($g_hStatus, $aParts)
   _GUICtrlStatusBar_SetBkColor($g_hStatus, _WinAPI_SwitchColor( 0x005fff))
   _GUICtrlStatusBar_SetText($g_hStatus, "AAAA", 0)
   _GUICtrlStatusBar_SetText($g_hStatus, "BBB", 1 )
    _GUICtrlStatusBar_SetMinHeight($g_hStatus, 30)
   _WinAPI_SetWindowTheme( $g_hStatus, "", "")
   GUISetState(@SW_SHOW)
   _Timer_SetTimer($hGUI, 1000, "_UpdateStatusBarClock")
   GUIRegisterMsg($WM_SIZE, "_WM_SIZE")
   Do
   Until GUIGetMsg() = $GUI_EVENT_CLOSE
   _Timer_KillAllTimers($hGUI)
   GUIDelete($hGUI)
EndFunc   ;==>Example
Func GradientToControl($label, $iWidth, $iHeight, $Argb_1, $Argb_2, $nbPart = 1)
   GUICtrlSetState($label,128)
   $Hlabel = GUICtrlGetHandle($label)
   _GDIPlus_Startup() ;initialize GDI+
   Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($Hlabel) ;create a graphics object from a window handle
    $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics) ;create a Bitmap object based on a graphics object
    $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap)
   _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
   Local $hBrush = _GDIPlus_LineBrushCreate($iWidth, 0, $iWidth, $iHeight/$nbPart, $Argb_1, $Argb_2, 1) ;create linear gradient brush

   _GDIPlus_GraphicsFillRect($g_hGfxCtxt, 0, 0, $iWidth, $iHeight, $hBrush) ;draw the egg
   _GDIPlus_GraphicsDrawImage($hGraphics, $g_hBitmap, 0, 0)
   $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($g_hBitmap)
   _SendMessage($Hlabel, $STM_SETIMAGE, 0, $hBitmap)
   Local $hObj = _SendMessage($Hlabel, $STM_GETIMAGE)
   If $hObj <> $hBitmap Then
      _WinAPI_DeleteObject($hBitmap)
   EndIf
   _GDIPlus_BrushDispose($hBrush)
   _GDIPlus_GraphicsDispose($hGraphics)
   _GDIPlus_GraphicsDispose($g_hGfxCtxt)
   _GDIPlus_BitmapDispose($g_hBitmap)
   _GDIPlus_Shutdown()
EndFunc
Func _WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)
   _GUICtrlStatusBar_Resize( $g_hStatus)
   Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE
Func _UpdateStatusBarClock($hWnd, $iMsg, $iIDTimer, $iTime)
    #forceref $hWnd, $iMsg, $iIDTimer, $iTime
    _GUICtrlStatusBar_SetText($g_hStatus,@TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2)
EndFunc   ;==>_UpdateStatusBarClock
L'avantage est de ne pas repeindre à chaque redimensionnement... L'inconvénient (quand ça marche) est de mettre le label en premier sinon on n'a plus accès aux autres contrôles de la GUI
Par contre c'est sacrément plus fluide, c'est pas mal, je vais méditer mais là dodo :shock:
walkson, es-ce normal ?
$label = GUICtrlCreateLabel("", 0, 0, $iWidth, $iHeight, $SS_BITMAP )
GradientToControl($label, $iWidth, $iHeight, 0xFF005530, 0xFF005FFF,1)
$label = GUICtrlCreateInput("texte ici", 20, 50, 100,25)
Modifié en dernier par Anthony le lun. 27 avr. 2020 03:26, modifié 3 fois.
J'ai été diagnostiqué pour trouble de la concentration, soyez indulgent
Merci à tous pour votre aide.

Mon UDF GuiStatusBar facile
Avatar du membre
walkson
Modérateur
Modérateur
Messages : 1020
Enregistré le : ven. 12 août 2011 19:49
Localisation : Hurepoix
Status : Hors ligne

Re: [UDF] GuiStatusBar facile avec plusieurs GUI (GuiStatusBarEx.au3) update 27/04/2020, 02h34

#29

Message par walkson »

walkson, es-ce normal ?
$label = GUICtrlCreateLabel("", 0, 0, $iWidth, $iHeight, $SS_BITMAP )
GradientToControl($label, $iWidth, $iHeight, 0xFF005530, 0xFF005FFF,1)
$label = GUICtrlCreateInput("texte ici", 20, 50, 100,25)
Ben non :lol:
Faut que j'arrête le bourbon 30 ans d'age au petit déjeuner :mrgreen:
Cordialement,
Walkson
"Horas non numero nisi serenas " Le canon de midi
(Je ne compte que les heures heureuses)
Avatar du membre
Anthony
Niveau 6
Niveau 6
Messages : 292
Enregistré le : lun. 17 janv. 2011 14:08
Localisation : France
Status : Hors ligne

Re: [UDF] GuiStatusBar facile avec plusieurs GUI (GuiStatusBarEx.au3) update 26/04/2020, 01h15

#30

Message par Anthony »

walkson a écrit : dim. 26 avr. 2020 19:31 J'ai essayé de faire un dégradé sur un label avec GDI mais je n'ai pas réussit, le dégradé n'apparait pas bien que j'obtienne le handle du bitmap :?:
Je mets le code à tout hasard (il fonctionne en l'état)
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
#include <StaticConstants.au3>
#include <GuiStatusBar.au3>
#include <WinAPITheme.au3>
#include <Timers.au3>

Example()

Func Example()

   Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBgColor format RRGGBB

   Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
   GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
   GUISetStyle(BitOR($WS_MINIMIZEBOX,  $WS_SIZEBOX, $WS_CAPTION, $WS_SYSMENU))
   $label = GUICtrlCreateLabel("", 0, 0, $iWidth, $iHeight, $SS_BITMAP )
   GradientToControl($label, $iWidth, $iHeight, 0xFF005530, 0xFF005FFF,1)
   $label = GUICtrlCreateInput("texte ici", 20, 50, 100,25)
   $button = GUICtrlCreateButton("OK",125,50,100,25)
   GUICtrlCreateLabel("< LABEL >",260,50,100)
   GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
   GUICtrlSetFont(-1,12,600,4,'courier new')
   Local $aParts[3] = [75, 150, -1]
   Global $g_hStatus = _GUICtrlStatusBar_Create($hGUI)
   _GUICtrlStatusBar_SetParts($g_hStatus, $aParts)
   _GUICtrlStatusBar_SetBkColor($g_hStatus, _WinAPI_SwitchColor( 0x005fff))
   _GUICtrlStatusBar_SetText($g_hStatus, "AAAA", 0)
   _GUICtrlStatusBar_SetText($g_hStatus, "BBB", 1 )
    _GUICtrlStatusBar_SetMinHeight($g_hStatus, 30)
   _WinAPI_SetWindowTheme( $g_hStatus, "", "")
   GUISetState(@SW_SHOW)
   _Timer_SetTimer($hGUI, 1000, "_UpdateStatusBarClock")
   GUIRegisterMsg($WM_SIZE, "_WM_SIZE")
   Do
   Until GUIGetMsg() = $GUI_EVENT_CLOSE
   _Timer_KillAllTimers($hGUI)
   GUIDelete($hGUI)
EndFunc   ;==>Example
Func GradientToControl($label, $iWidth, $iHeight, $Argb_1, $Argb_2, $nbPart = 1)
   GUICtrlSetState($label,128)
   $Hlabel = GUICtrlGetHandle($label)
   _GDIPlus_Startup() ;initialize GDI+
   Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($Hlabel) ;create a graphics object from a window handle
    $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics) ;create a Bitmap object based on a graphics object
    $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap)
   _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
   Local $hBrush = _GDIPlus_LineBrushCreate($iWidth, 0, $iWidth, $iHeight/$nbPart, $Argb_1, $Argb_2, 1) ;create linear gradient brush

   _GDIPlus_GraphicsFillRect($g_hGfxCtxt, 0, 0, $iWidth, $iHeight, $hBrush) ;draw the egg
   _GDIPlus_GraphicsDrawImage($hGraphics, $g_hBitmap, 0, 0)
   $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($g_hBitmap)
   _SendMessage($Hlabel, $STM_SETIMAGE, 0, $hBitmap)
   Local $hObj = _SendMessage($Hlabel, $STM_GETIMAGE)
   If $hObj <> $hBitmap Then
      _WinAPI_DeleteObject($hBitmap)
   EndIf
   _GDIPlus_BrushDispose($hBrush)
   _GDIPlus_GraphicsDispose($hGraphics)
   _GDIPlus_GraphicsDispose($g_hGfxCtxt)
   _GDIPlus_BitmapDispose($g_hBitmap)
   _GDIPlus_Shutdown()
EndFunc
Func _WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)
   _GUICtrlStatusBar_Resize( $g_hStatus)
   Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE
Func _UpdateStatusBarClock($hWnd, $iMsg, $iIDTimer, $iTime)
    #forceref $hWnd, $iMsg, $iIDTimer, $iTime
    _GUICtrlStatusBar_SetText($g_hStatus,@TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2)
EndFunc   ;==>_UpdateStatusBarClock
L'avantage est de ne pas repeindre à chaque redimensionnement... L'inconvénient (quand ça marche) est de mettre le label en premier sinon on n'a plus accès aux autres contrôles de la GUI
Sous XP çà fait sapin de noël...
J'ai été diagnostiqué pour trouble de la concentration, soyez indulgent
Merci à tous pour votre aide.

Mon UDF GuiStatusBar facile
Avatar du membre
Anthony
Niveau 6
Niveau 6
Messages : 292
Enregistré le : lun. 17 janv. 2011 14:08
Localisation : France
Status : Hors ligne

Re: [UDF] GuiStatusBar facile avec plusieurs GUI (GuiStatusBarEx.au3) update 27/04/2020, 02h34

#31

Message par Anthony »

Mikell test moi çà pour tester si çà marche sur XP s'il te plaît :wink:
Moi XP et WIn X c'est OK
Fichiers joints
GuiStatusBarEx - UDF DEMO.au3
(10.87 Kio) Téléchargé 6874 fois
GuiStatusBarEx.au3
(22.5 Kio) Téléchargé 6876 fois
J'ai été diagnostiqué pour trouble de la concentration, soyez indulgent
Merci à tous pour votre aide.

Mon UDF GuiStatusBar facile
Avatar du membre
mikell
Spammer !
Spammer !
Messages : 6292
Enregistré le : dim. 29 mai 2011 17:32
Localisation : Deep Cévennes
Status : Hors ligne

Re: [UDF] GuiStatusBar facile avec plusieurs GUI (GuiStatusBarEx.au3) update 27/04/2020, 02h34

#32

Message par mikell »

Bin oui ça marche, évidemment :P
Par contre walkson a raison, re-créer à chaque fois le gradient dans le wm_size franchement c'est pas top
Hier j'ai testé sensiblement le même truc que lui (à base de _WinAPI_GradientFill(), mais c'est pareil ) . ça marche à condition de créer le gradient avant tous les autres controles de la gui statusbar comprise... et on sent bien que le gpu respire mieux :mrgreen:
Mais j'ai pas essayé de l'intégrer à ton usine à gaz je me suis honteusement dégonflé Image
" L'échec est le fondement de la réussite. " (Lao-Tseu )
" Plus ça rate, plus on a de chances que ça marche " (les Shadoks )
Avatar du membre
Anthony
Niveau 6
Niveau 6
Messages : 292
Enregistré le : lun. 17 janv. 2011 14:08
Localisation : France
Status : Hors ligne

Re: [UDF] GuiStatusBar facile avec plusieurs GUI (GuiStatusBarEx.au3) update 27/04/2020, 02h34

#33

Message par Anthony »

viewtopic.php?f=21&t=15370&p=105040#p105042

Effectivement, j'ai regardé un peu et les GDI :shock:

walkson une idée d'intégration pour que ce soit plus light :mrgreen:
J'ai été diagnostiqué pour trouble de la concentration, soyez indulgent
Merci à tous pour votre aide.

Mon UDF GuiStatusBar facile
Avatar du membre
walkson
Modérateur
Modérateur
Messages : 1020
Enregistré le : ven. 12 août 2011 19:49
Localisation : Hurepoix
Status : Hors ligne

Re: [UDF] GuiStatusBar facile avec plusieurs GUI (GuiStatusBarEx.au3) update 27/04/2020, 02h34

#34

Message par walkson »

Bonjour,
Il y a une erreur au niveau de
Func _GUICtrlStatusBarEx_CreateFunc( $id_Ctrl="", $IndexFunc="", $Options="")
       If $IndexFunc < 1 Or $IndexFunc > 1 Then Return SetError(1)

       Switch $IndexFunc
            Case 1
                Local $avar[1][2] = [[$id_Ctrl, $Options]]
                _ArrayAdd( $ClockStatusBarEx, $avar)
                _BarEx_Func_CLOCK()
            Case 2
                GUICtrlSendMsg($id_Ctrl, $PBM_SETSTATE, $iState, 0)

       EndSwitch
EndFunc
Je crois que vous avez oublié de terminer la fonction ($iState non déclaré)
A part cette erreur, j'ai testé le code du message #1, et je n'ai pas trouver de problème sinon le scintillement du label avec l'heure sur la Gui mère (de manière irrégulière :?: )
Cordialement,
Walkson
"Horas non numero nisi serenas " Le canon de midi
(Je ne compte que les heures heureuses)
Avatar du membre
Anthony
Niveau 6
Niveau 6
Messages : 292
Enregistré le : lun. 17 janv. 2011 14:08
Localisation : France
Status : Hors ligne

Re: [UDF] GuiStatusBar facile avec plusieurs GUI (GuiStatusBarEx.au3) update 27/04/2020, 02h34

#35

Message par Anthony »

walkson a écrit : sam. 25 avr. 2020 15:42 J'ai trouvé un code qui modifie la couleur du progressbar (vert, jaune ou rouge)
Global Const $PBST_NORMAL = 0x0001;vert
Global Const $PBST_ERROR = 0x0002;rouge
Global Const $PBST_PAUSED = 0x0003;jaune

; #FUNCTION# ====================================================================================================================
; Name ..........: _GUICtrlStatusBarEx_ColorProgressBar
; Description ...: Sets the state of the progressbar
; Syntax ........: _GUICtrlStatusBarEx_ColorProgressBar($iProgress, $iState)
; Parameters ....: $iProgress           - CtrlID of progressbar or -1 for the last created control.
;                  $iState              - new status of progress:
;                                |$PBM_NORMAL - normal state (green)
;                                |$PBM_ERROR - error state (red)
;                                |$PBM_PAUSED - paused style (yellow)
; Return values .: None
; Author ........: Prog@ndy
; Modified ......:
; Remarks .......: requires WinVista or above
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GUICtrlStatusBarEx_ColorProgressBar($iProgress, $iState)
   GUICtrlSendMsg($iProgress, $PBM_SETSTATE, $iState, 0)
EndFunc
C'était une supposition, mais ta fonction est parfaite, je n'avais pas bien compris à ce moment là :roll:
viewtopic.php?f=21&t=15370&p=105058#p105022

Code : Tout sélectionner

; #FUNCTION#=====================================================================================================================
; Author ........: Anthony Baillou
; Modified.......: Anthony Baillou
;
; Name ..........: _GUICtrlStatusBarEx_CreateFunc
; Description ...: Ajoute une fonction à un objet
; Syntax ........: _GUICtrlStatusBarEx_CreateFunc( $id_Ctrl, $IndexControl, $Options)
; Parameters ....: $id_Ctrl             - Handle du contrôle.
;                  $IndexFunc           - Index de la fonction.
;                  $Options             - Options de la fonction.
; Clock..........: $id_Ctrl, 1, [$iState]
;                                      [0] = Affiche une date et/ou une heure.
;                                            S'il y a une partie de date, l'afficher comme une date courte.
;                                            S'il y a une partie d'une heure, l'afficher comme une heure longue.
;                                            Si présent, les deux parties sont affichées.
;                                      [1] = Affiche une date en utilisant la date au format long spécifié dans les paramètres régionaux de votre ordinateur.
;                                      [2] = Affiche une date en utilisant la date au format court spécifié dans les paramètres régionaux de votre ordinateur.
;                                      [3] = Affiche une heure en utilisant l'heure au format spécifié dans les paramètres régionaux de votre ordinateur.
;                                      [4] = Affiche une heure en utilisant le format 24 heures (hh:mm).
;                                      [5] = Affiche une heure en utilisant le format 24 heures (hh:mm:ss).
; ===============================================================================================================================
Func _GUICtrlStatusBarEx_CreateFunc( $id_Ctrl="", $IndexFunc="", $iState="")
	  If $IndexFunc < 1 Or $IndexFunc > 1 Then Return SetError(1)

	  Switch $IndexFunc
			Case 1
				  Local $avar[1][2] = [[$id_Ctrl, $iState]]
				  _ArrayAdd( $ClockStatusBarEx, $avar)
				  _GUICtrlStatusBarEx_CLOCK()

	  EndSwitch
EndFunc
Mise à jour
GuiStatusBarEx.au3
(24.71 Kio) Téléchargé 6933 fois
GuiStatusBarEx - UDF DEMO.au3
(11.17 Kio) Téléchargé 6928 fois
J'ai été diagnostiqué pour trouble de la concentration, soyez indulgent
Merci à tous pour votre aide.

Mon UDF GuiStatusBar facile
Avatar du membre
walkson
Modérateur
Modérateur
Messages : 1020
Enregistré le : ven. 12 août 2011 19:49
Localisation : Hurepoix
Status : Hors ligne

Re: [UDF] GuiStatusBar facile avec plusieurs GUI (GuiStatusBarEx.au3) update 27/04/2020, 02h34

#36

Message par walkson »

Bonjour,
Si vous ne corrigez pas l'UDF dans le post 1, il y aura toujours une erreur :roll:
Cordialement,
Walkson
"Horas non numero nisi serenas " Le canon de midi
(Je ne compte que les heures heureuses)
Avatar du membre
Anthony
Niveau 6
Niveau 6
Messages : 292
Enregistré le : lun. 17 janv. 2011 14:08
Localisation : France
Status : Hors ligne

Re: [UDF] GuiStatusBar facile avec plusieurs GUI (GuiStatusBarEx.au3) update 29/04/2020, 04h22

#37

Message par Anthony »

Oups, c'est mis à jour, faut que j'arrête le petit lait le matin :mrgreen:
viewtopic.php?f=21&t=15370&p=104902#p104902
J'ai été diagnostiqué pour trouble de la concentration, soyez indulgent
Merci à tous pour votre aide.

Mon UDF GuiStatusBar facile
JoeBar
Niveau 2
Niveau 2
Messages : 23
Enregistré le : sam. 26 oct. 2019 10:20
Status : Hors ligne

Re: [UDF] GuiStatusBar facile avec plusieurs GUI (GuiStatusBarEx.au3) update 29/04/2020, 04h22

#38

Message par JoeBar »

Salut, il est sympa ton UDF, mais à chaque actualisation de l'heure, ça flicke ...
Avatar du membre
Anthony
Niveau 6
Niveau 6
Messages : 292
Enregistré le : lun. 17 janv. 2011 14:08
Localisation : France
Status : Hors ligne

Re: [UDF] GuiStatusBar facile avec plusieurs GUI (GuiStatusBarEx.au3) update 01/05/2020, 14h45

#39

Message par Anthony »

JoeBar a écrit : jeu. 30 avr. 2020 10:11 Salut, il est sympa ton UDF, mais à chaque actualisation de l'heure, ça flicke ...
Il est très probable que votre OS soit Win 7 :?:
Cette mise à jour règle t'elle le problème ? (voir post #1)

Mise à jour, suppression de l'ancienne version (AdlibRegister) de l'heure et mise à jour avec (_Timer_SetTimer), merci walkson :mrgreen:
J'ai été diagnostiqué pour trouble de la concentration, soyez indulgent
Merci à tous pour votre aide.

Mon UDF GuiStatusBar facile
Avatar du membre
mikell
Spammer !
Spammer !
Messages : 6292
Enregistré le : dim. 29 mai 2011 17:32
Localisation : Deep Cévennes
Status : Hors ligne

Re: [UDF] GuiStatusBar facile avec plusieurs GUI (GuiStatusBarEx.au3) update 01/05/2020, 14h45

#40

Message par mikell »

Ce qui marche très bien chez moi (même avec le AdlibRegister) c'est ça
Reste à le tester avec w7 et avec les OS ultramodernes Image

$new_heure = _DateTimeFormat( _NowCalc(), $ClockStatusBarEx[$i][1])
ControlSetText($MultiStatusBarEx[$i][0], "", $ClockStatusBarEx[$i][0], $new_heure)
" L'échec est le fondement de la réussite. " (Lao-Tseu )
" Plus ça rate, plus on a de chances que ça marche " (les Shadoks )
Répondre