[..] Projet MultiStatusBar sur une seule GUI

Aide et conseils concernant AutoIt et ses outils.
Règles du forum
.
Répondre
Avatar du membre
Anthony
Niveau 7
Niveau 7
Messages : 321
Enregistré le : lun. 17 janv. 2011 14:08
Localisation : France
Status : Hors ligne

[..] Projet MultiStatusBar sur une seule GUI

#1

Message par Anthony »

Bonjour à tous,

J'éssaie de donner la possibilité de pouvoir disposer de 2 ou plusieurs StatusBar dans une seule et même GUI, comme avec ce code.
#include <Array.au3>
#include <Date.au3>
#include <DateTimeConstants.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <WinAPISysWin.au3>
#include <WinAPITheme.au3>
#include <WindowsConstants.au3>

; Création de la GUI principale
Global $hGui = GUICreate("Fenêtre Principale", 700, 100, -1, -1, $WS_OVERLAPPEDWINDOW)

; Forcer le positionnement initial
_MY_WM_SIZE_Handler($hGui, $WM_SIZE, 0, 0)

; Affichage
GUISetState(@SW_SHOW, $hGui)

; Boucle principale
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

GUIDelete($hGui_Chiffre_D_Affaire)
GUIDelete($hGui_Chiffre_Mois)
GUIDelete($hGui)

Func _MY_WM_SIZE_Handler($hWnd, $iMsg, $wParam, $lParam)

   If Not IsDeclared( "hGui_Chiffre_D_Affaire") Then

      Local $aSize = WinGetClientSize($hWnd)

     ; ********** Barre d'état "Chiffre d'affaire" **********
      Global $a_Chiffre_D_Affaire = ["Chiffre d'affaire", "Jour 0€", "Semaine 0€", "Mois 0€", "Année 0€", "Date et heure: "]
      Local $LabelWidth = $aSize[0] / UBound( $a_Chiffre_D_Affaire)
      Local $a_Chiffre_D_Affaire_Parts[ UBound( $a_Chiffre_D_Affaire)]

      For $i = 0 To UBound( $a_Chiffre_D_Affaire) - 1
         $a_Chiffre_D_Affaire_Parts[$i] = $LabelWidth
      Next

      Global $hGui_Chiffre_D_Affaire = GUICreate( "", $aSize[0], 22, 0, $aSize[1] - 22, $WS_CHILD, 0, $hWnd)
      Global $hStatus_Chiffre_D_Affaire = _GUICtrlStatusBar_Create( $hGui_Chiffre_D_Affaire, $a_Chiffre_D_Affaire_Parts, $a_Chiffre_D_Affaire)
      _WinAPI_SetWindowTheme( $hStatus_Chiffre_D_Affaire, "", "")

      GUISetState( @SW_SHOW, $hGui_Chiffre_D_Affaire)

     ; ********** Barre d'état "Chiffre par mois" **********
      Global $a_Mois = ["Jan 0€", "Fév 0€", "Mar 0€", "Avr 0€", "Mai 0€", "Juin 0€", "Juil 0€", "Août 0€", "Sep 0€", "Oct 0€", "Nov 0€", "Déc 0€"]
      Local $LabelWidth = $aSize[0] / UBound( $a_Mois)
      Local $a_Mois_Parts[ UBound($a_Mois)]

      For $i = 0 To UBound($a_Mois) - 1
         $a_Mois_Parts[$i] = $LabelWidth
      Next

      Global $hGui_Chiffre_Mois = GUICreate( "", $aSize[0], 22, 0, $aSize[1] - 44, $WS_CHILD, 0, $hWnd)
      Global $hStatus_Mois = _GUICtrlStatusBar_Create( $hGui_Chiffre_Mois, $a_Mois_Parts, $a_Mois)
      _WinAPI_SetWindowTheme( $hStatus_Mois, "", "")

      GUISetState( @SW_SHOW, $hGui_Chiffre_Mois)

      GUIRegisterMsg( $WM_SIZE, "_MY_WM_SIZE_Handler")
   EndIf

   If $hWnd = $hGui Then
      Local $aSize = WinGetClientSize( $hWnd)

      WinMove( $hGui_Chiffre_D_Affaire, "", 1, $aSize[1] - 22, $aSize[0] - 1, 22)
      WinMove( $hGui_Chiffre_Mois, "", 1, $aSize[1] - 44, $aSize[0] - 1, 22)
      _GUICtrlStatusBar_Resize( $hStatus_Chiffre_D_Affaire)
      _GUICtrlStatusBar_Resize( $hStatus_Mois)
   EndIf

   Return $GUI_RUNDEFMSG

EndFunc
C'est trop restreint, j'ai donc pensé à mon UDF GuiStatusBarEx https://www.autoitscript.fr/forum/viewt ... 21&t=15370

Je le cache pas j'ai déjà commencé quelque chose, mais sans succès ...
#include <GuiStatusBarEx.au3>

; == Création de la fenêtre principale ==
Local $hGui = GUICreate("Fenêtre Principale", 720, 200, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU))

Local $aSize = WinGetClientSize( $hGui)

Global $a_Array = ["CA", "Jour 10000€", "Sem 10000€", "Mois 10000€", "Année 100000€", "Calendrier", "Date et heure:"]
Local $v_Parts = "", $Width = $aSize[0] / UBound( $a_Array) - 18

For $i = 1 To UBound( $a_Array) -1
   If $i = 1            Then $v_Parts &= "20" & ","
   If 2 <= $i And $i <= 5  Then $v_Parts &= $Width & ","
   If $i = 5            Then $v_Parts &= "180" & ","
   If $i = 6            Then $v_Parts &= "-1"
Next

ConsoleWrite( "$v_Parts = " & StringReplace( $v_Parts, ",", "," & @TAB) & @CRLF)

Local $hStatusBar = _GUICtrlStatusBarEx_Create( $hGui, $v_Parts, 24, Default)

; == Ajout des labels ==
Global $a_hLabel[UBound( $a_Array)] ; = 6
For $i = 0 To UBound( $a_Array)-1
   If $i <> 5 Then $a_hLabel[$i] = _GUICtrlStatusBarEx_CreateControl( $hGui, 6, $i, $a_Array[$i], 0, 0, 0, 0, "SIZEABLE_AUTO", $SS_CENTER + $SS_CENTERIMAGE, "", 0xE8E8E8, "8.5|$FW_BOLD|$GUI_FONTNORMAL|Arial|0x000000")
Next

$a_hLabel[5] = _GUICtrlStatusBarEx_CreateControl( $hGui,   4, 5, "Date", 2, 2, -4, -4, "SIZEABLE_AUTO", $DTS_LONGDATEFORMAT, "", 0xFFFFFF,"8.5|$FW_NORMAL|$GUI_FONTNORMAL|Courier new|0x0000FF")

_GUICtrlStatusBarEx_CreateFunc( $a_hLabel[6], 1, 9)   ; _GUICtrlStatusBarEx_CreateFunc( $id_Ctrl, $IndexControl, $Options)

;~ _ArrayDisplay( $a_hLabel, @ScriptLineNumber & " $a_hLabel")

GUISetState(@SW_SHOW, $hGui)

;~ Local $hStatusBar2 = _GUICtrlStatusBarEx_Create( $hGui, $v_Parts, 60, Default)

; == Boucle principale ==
While 1
   $GUIGetMsg = GUIGetMsg(1)
   $msg = $GUIGetMsg[0]
   Switch $msg
      Case $GUI_EVENT_CLOSE
         If $GUIGetMsg[1] = $hGui Then Exit

      Case $a_hLabel[0]
       ConsoleWrite( "$a_hLabel[0] ID = " & $a_hLabel[0] & @CRLF)
      Case $a_hLabel[1]
       ConsoleWrite( "$a_hLabel[1] ID = " & $a_hLabel[1] & @CRLF)
      Case $a_hLabel[2]
       ConsoleWrite( "$a_hLabel[2] ID = " & $a_hLabel[2] & @CRLF)
      Case $a_hLabel[3]
       ConsoleWrite( "$a_hLabel[3] ID = " & $a_hLabel[3] & @CRLF)
      Case $a_hLabel[4]
       ConsoleWrite( "$a_hLabel[4] ID = " & $a_hLabel[4] & @CRLF)
     Case $a_hLabel[5]                 ; From $hGUI_1_StatusBarEx
       MsgBox("", "Return text of the Input", "$Combo1 return: " & @CRLF&@CRLF & GUICtrlRead( $a_hLabel[5]), 5)
     Case $a_hLabel[6]                 ; From $hGUI_1_StatusBarEx
       MsgBox("", "Return text of the Input", "$Combo1 return: " & @CRLF&@CRLF & GUICtrlRead( $a_hLabel[6]), 5)

   EndSwitch
WEnd
Merci d'avance.
Je suis diagnostiqué pour trouble de la concentration, soyez indulgent
Merci à tous pour votre aide.
UDF: GuiStatusBarEx --- 2025/03/17 --- Une StatusBar complète, rapide et simple
Code: Code-Texte fusion --- Une GUI pour fusionner des GCodes pour CNC 3018
Cool: Base64 Compression Tool --- des fichiers dans vos scripts
Avatar du membre
Anthony
Niveau 7
Niveau 7
Messages : 321
Enregistré le : lun. 17 janv. 2011 14:08
Localisation : France
Status : Hors ligne

Re: [..] Projet MultiStatusBar sur une seule GUI

#2

Message par Anthony »

Pour les intéressé j'ai mis ma progression ici : https://www.autoitscript.fr/forum/viewt ... 60#p108739
Je suis diagnostiqué pour trouble de la concentration, soyez indulgent
Merci à tous pour votre aide.
UDF: GuiStatusBarEx --- 2025/03/17 --- Une StatusBar complète, rapide et simple
Code: Code-Texte fusion --- Une GUI pour fusionner des GCodes pour CNC 3018
Cool: Base64 Compression Tool --- des fichiers dans vos scripts
Répondre