[R] Rendre un StatusBar transparent

Aide sur les Interfaces Graphique Utilisateurs (GUI).
Règles du forum
.
Répondre
Hugues
Niveau 8
Niveau 8
Messages : 597
Enregistré le : ven. 21 sept. 2012 18:12
Status : Hors ligne

[R] Rendre un StatusBar transparent

#1

Message par Hugues »

Bonjour,

J'aimerai savoir s"il est possible de rendre transparent un StatusBar?
Je sais que l'on peut chnager sa couleur de fond mais ça ne me convient pas, car la couleur de fond de mon GUI changera (preference utilisateur).

Merci par avance.
Modifié en dernier par Hugues le dim. 02 févr. 2014 19:28, modifié 1 fois.
Avatar du membre
TopXm
Niveau 6
Niveau 6
Messages : 260
Enregistré le : mer. 25 mai 2011 16:37
Localisation : Cognac !!!
Status : Hors ligne

Re: [..] Rendre un StatusBar transparent

#2

Message par TopXm »

Hello :)

Si j'ai bien capté, tu veux la même BackColor sur ta GUI et la StatusBar :)
► Afficher le texteSetSameBackColor
Hugues
Niveau 8
Niveau 8
Messages : 597
Enregistré le : ven. 21 sept. 2012 18:12
Status : Hors ligne

Re: [..] Rendre un StatusBar transparent

#3

Message par Hugues »

Merci mais, c'est pas tout à fait ça car je viens de me rendre compte que j'ai pas tout dit... :oops:

En fait j'utilise un dégradé de couleur de Mikell sur mon GUI ^^, c'est pour cela que je veux que ma statusbar soit transparent.
Avatar du membre
mikell
Spammer !
Spammer !
Messages : 6292
Enregistré le : dim. 29 mai 2011 17:32
Localisation : Deep Cévennes
Status : Hors ligne

Re: [..] Rendre un StatusBar transparent

#4

Message par mikell »

Pas trouvé pour la transparence mais tu peux bricoler à partir du code précédent
► Afficher le texte
" L'échec est le fondement de la réussite. " (Lao-Tseu )
" Plus ça rate, plus on a de chances que ça marche " (les Shadoks )
Hugues
Niveau 8
Niveau 8
Messages : 597
Enregistré le : ven. 21 sept. 2012 18:12
Status : Hors ligne

Re: [..] Rendre un StatusBar transparent

#5

Message par Hugues »

Salut,

merci pour vos 2 réponses.

Une petite question avec la fonction de Mikell...

Nous avons comme couleur

Code : Tout sélectionner

$color2 = 0x00f0ff
, pourquoi lorsque l'on applique à la StatusBar

Code : Tout sélectionner

_GUICtrlStatusBar_SetBkColor($hStatus, $color2)
, la couleur n'est pas la même (Jaune)? :shock: (PS je suis daltonien donc les couleurs... :oops: )
Avatar du membre
mikell
Spammer !
Spammer !
Messages : 6292
Enregistré le : dim. 29 mai 2011 17:32
Localisation : Deep Cévennes
Status : Hors ligne

Re: [..] Rendre un StatusBar transparent

#6

Message par mikell »

Fichier d'aide pour _GUICtrlStatusBar_SetBkColor dit : color passed in must be BGR Hex color or RGB COLORREF
Comme la couleur utilisée n'est pas prédéfinie par une variable (de l'include ColorConstants.au3) il faut passer la teinte 0xrrggbb sous la forme 0xbbggrr
Dans le code, pour la couleur 0x00f0ff logiquement il aurait donc fallu mettre 0xfff000 mais ça le faisait pas tout à fait à cause du dégradé
" L'échec est le fondement de la réussite. " (Lao-Tseu )
" Plus ça rate, plus on a de chances que ça marche " (les Shadoks )
Hugues
Niveau 8
Niveau 8
Messages : 597
Enregistré le : ven. 21 sept. 2012 18:12
Status : Hors ligne

Re: [..] Rendre un StatusBar transparent

#7

Message par Hugues »

Ok merci pour l'information! :mrgreen:
Avatar du membre
Anthony
Niveau 6
Niveau 6
Messages : 292
Enregistré le : lun. 17 janv. 2011 14:08
Localisation : France
Status : Hors ligne

Re: [R] Rendre un StatusBar transparent redimensionnable

#8

Message par Anthony »

Bonjour à tous,

Désolé pour le déterrage de Topic mais je suis sur l'action alors je partage, je sais que çà peut servir :P

Voili, voilou, sous windows X j'ai dû remplacer:

Code : Tout sélectionner

;~ DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 1)
;~ DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
par

Code : Tout sélectionner

; to allow the setting of Bk Color at least under Windows 10
_WinAPI_SetWindowTheme($hStatus, "", "")
Voici la démo redimensionnable :D

Code : Tout sélectionner

#include <Color.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <GuiTab.au3>
#include <WindowsConstants.au3>
#include <WinAPITheme.au3>

Global $Graphic

$color1 = 0xccaaaa
$color2 = 0x00f0ff

$hGUI = GUICreate("Gradient Demo Sizeable", 640, 480, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU))

$hStatus = _GUICtrlStatusBar_Create( $hGUI)
; to allow the setting of Bk Color at least under Windows 10
_WinAPI_SetWindowTheme($hStatus, "", "")

Local $aParts[3] = [175, 260, -1], $SetBarHeight = 20
_GUICtrlStatusBar_SetParts($hStatus, $aParts)
_GUICtrlStatusBar_SetMinHeight( $hStatus, $SetBarHeight)

_GUICtrlStatusBar_SetText($hStatus, "Color : " & $color2, 0,  $SBT_NOBORDERS)
_GUICtrlStatusBar_SetText($hStatus, "AkeReKouKou", 1,  $SBT_NOBORDERS)
_GUICtrlStatusBar_SetText($hStatus, "", 2,  $SBT_NOBORDERS)
_GUICtrlStatusBar_SetBkColor($hStatus, _WinAPI_SwitchColor( $color2))	; _GUICtrlStatusBar_SetBkColor($hStatus, 0xf2e300)

$size = WinGetClientSize( $hGUI)
_GUICtrlCreateGradient($color1, $color2, 0, 0, $size[0], $size[1]-$SetBarHeight)

GUIRegisterMsg($WM_SIZE, "_WM_SIZE")

GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
Wend

Func _GUICtrlCreateGradient($nStartColor, $nEndColor, $nX, $nY, $nWidth, $nHeight)
   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

   GUICtrlDelete( $Graphic)
   $Graphic = GuiCtrlCreateGraphic($nX, $nY, $nWidth, $nHeight, $TCS_BOTTOM)

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

Func _WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)
   $size = WinGetClientSize( $hGUI)
   _GUICtrlCreateGradient($color1, $color2, 0, 0, $size[0], $size[1]-$SetBarHeight)
   _GUICtrlStatusBar_Resize( $hStatus)
   Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE
La démo redimensionnable en plus light, merci walkson de m'avoir mis sur la bonne voie :bisou:

Code : Tout sélectionner

#Include <GUIConstantsEx.au3>
#include <GuiConstants.au3>
#include <GuiStatusBar.au3>
#include <Timers.au3>
#Include <WinAPIEx.au3>

;~ Global Const $STM_SETIMAGE = 0x0172
;~ Global Const $STM_GETIMAGE = 0x0173

Local $nStartColor	= 0x005530, $nEndColor = 0x005FFF	; Format RRGGBB
Local $iBgColor		= 0x303030							; Format RRGGBB
Local $iBarColor	= 0x005fff							; Format RRGGBB

$hGUI = GUICreate('MyGUI', 600, 300, -1, -1, $WS_MINIMIZEBOX+$WS_MAXIMIZEBOX+$WS_SIZEBOX+$WS_CAPTION + $WS_SYSMENU)   ; create a GUI for the bitmap
GUISetBkColor($iBgColor, $hGUI) ;set GUI background color

_GUICtrlCreateGradient( $hGUI, $nStartColor, $nEndColor, 0, 0, 600, 260)

Global $g_hStatus = _GUICtrlStatusBar_Create($hGUI)
Local $aParts[3] = [75, 150, -1]
_GUICtrlStatusBar_SetParts($g_hStatus, $aParts)
_GUICtrlStatusBar_SetBkColor($g_hStatus, _WinAPI_SwitchColor( $iBarColor))
_GUICtrlStatusBar_SetText($g_hStatus, "AAAA", 0)
_GUICtrlStatusBar_SetText($g_hStatus, "BBB", 1 )
_GUICtrlStatusBar_SetText($g_hStatus, "TIME", 2 )
_GUICtrlStatusBar_SetMinHeight($g_hStatus, 25)
_WinAPI_SetWindowTheme( $g_hStatus, "", "")

GUISetState()

   _Timer_SetTimer($hGUI, 1000, "_UpdateStatusBarClock")

GUIRegisterMsg($WM_SIZE, "_WM_SIZE")

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

_Timer_KillAllTimers($hGUI)
GUIDelete($hGUI)

; #FUNCTION# ====================================================================================================================
; Author ........: mikell, Anthony Baillou, walkson
; Modified.......: Anthony Baillou, walkson
; ===============================================================================================================================
Func _GUICtrlCreateGradient( $hWnd, $nStartColor, $nEndColor, $nX, $nY, $nWidth, $nHeight)
   Dim $aVertex[2][3] = [[0, 0, $nStartColor], [@DesktopWidth, @DesktopHeight, $nEndColor]]
   $hDC		= _WinAPI_CreateCompatibleDC(0)    ; create the bitmap
   $hBitmap	= _WinAPI_CreateBitmap( @DesktopWidth, @DesktopHeight, 1, 32)
   $hSv		= _WinAPI_SelectObject($hDC, $hBitmap)
   _WinAPI_GradientFill($hDC, $aVertex, 0, 1)          ; actual fill
   _WinAPI_SelectObject($hDC, $hSv)
   _WinAPI_DeleteDC($hDC)
   GUICtrlCreatePic("", 0, 0, @DesktopWidth, @DesktopHeight)
   GUICtrlSetState(-1, $GUI_DISABLE)
   GUICtrlSendMsg(-1, $STM_SETIMAGE, 0, $hBitmap)
   GUICtrlSetPos( -1, $nX, $nY, $nWidth, $nHeight)
   GUICtrlSetResizing( -1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM + $GUI_DOCKRIGHT)
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
J'ai été diagnostiqué pour trouble de la concentration, soyez indulgent
Merci à tous pour votre aide.

Mon UDF GuiStatusBar facile
Répondre