
Comme indiqué dans le titre, je voudrais savoir s'il est possible de changer la police et la couleur des ListViewGroup ?
Voici le code concerné :
► Afficher le texte_SetListViewGroup_Font_Color
Code : Tout sélectionner
;
; Problème de changement de police d'un ListViewGroup sur une ListView
;
#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
; ============================================================================= ;
; Listage rapide des gros dossiers ;
; ============================================================================= ;
; Auteur .......................... : TopXm ;
; Date dernière update ............ : 06 mai 2012 ;
; Késako .......................... : Liste les dossiers volumineux ;
; Nom de l'outil .................. : BigFolder ;
; ============================================================================= ;
#include <array.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <Constants.au3>
#include <WinAPIEx.au3>
#include <ButtonConstants.au3>
#include <Icons.au3>
; Constantes Declaratives
Global Const $Title = 'BigFolder Version 1.0'
Global Const $DirFonts = @TempDir & '\BigFolder\Fonts\'
Global Const $DirInc = @TempDir & '\BigFolder\Include\'
Global Const $IcoPath = $DirInc & 'Back.ico'
Global Const $Plasma = 'Plasma Drip (BRK)'
Global Const $Calisto = 'Calisto MT'
Global Const $BackColor = 0x494E49
Global Const $ForeColor = 0xA29CC9 ;0xE6ECE0
Global Const $HardDrive = 'Fixed'
Global Const $DVD = 'CDROM'
Global Const $UNKNOWN = 'Unknown'
Global Const $NETWORK = 'Network'
Global Const $RAMDISK = 'RAMDisk'
Global Const $USB = 'Removable'
Global Const $aTypes[6] = ['Fixed', 'CDROM', 'UnKnown', 'Network', 'RAMDisk', 'Removable']
Global Const $iTypes[6] = [' Disques durs ', ' Lecteurs CD/DVD ', ' Lecteurs inconnus ', _
' Disques réseau ', ' Disques virtuels ', ' Disques amovibles ']
Global Const $BD_ROM = -201
Global Const $INDEX_SHIFT = 9999
Global Const $NM_CUSTOMDRAW_1 = $NM_FIRST - 121
Global Const $SHGFI_ICONLOCATION = 0x00001000
Global Const $SHGFI_TYPENAME = 0x00000400
; Others Declaratives
Global $aDrives[1][8]
Global $I
Global $nGroup, $aGroup
Global $iCX = 64, $iCY = 64
_FilesInstall()
_GuiPrepare()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
_ExiteMoi()
EndSwitch
WEnd
; --------------------------------------------------------------
; Création GUI ;
; --------------------------------------------------------------
Func _GuiPrepare()
Global $hGUI = GUICreate("BigFolder v. 1.0", 580, 530, 192, 124)
GUISetFont(14, 400, 0, "Degrading Morals")
GUISetBkColor($BackColor, $hGUI)
GUISetIcon($DirInc & '\BigFolder.ico')
Global $BtBack = GUICtrlCreateIcon('', 0, 5, 5, 32, 32)
_SetCombineBkIcon($BtBack, -1, $IcoPath, 0, 32, 32, $IcoPath, 0, 32, 32, 0, 0)
Global $hTitle = GUICtrlCreateLabel("Big Folders", 50, 5, 479, 60, BitOR($SS_CENTER, $SS_NOTIFY))
GUICtrlSetFont(-1, 36, 400, 0, $Plasma)
GUICtrlSetBkColor(-1, $BackColor)
GUICtrlSetColor(-1, $ForeColor)
Global $hLstV = GUICtrlCreateListView("", 0, 66, 579, 400, _
BitOR($LVS_ICON, $LVS_SHOWSELALWAYS, $LVS_NOCOLUMNHEADER), $WS_EX_TRANSPARENT)
GUICtrlSetFont($hLstV, 16, 800, 0, $Calisto, 5)
_GUICtrlListView_SetExtendedListViewStyle($hLstV, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT, $LVS_EX_LABELTIP))
_GUICtrlListView_SetBkColor($hLstV, $BackColor)
_GUICtrlListView_SetTextBkColor($hLstV, $BackColor)
_GUICtrlListView_SetTextColor($hLstV, $ForeColor)
_GUICtrlListView_SetView($hLstV, 1)
Global $hImage = _GUIImageList_Create(128, 128, 5, 3)
_GUICtrlListView_SetImageList($hLstV, $hImage, 0)
_GetDrivesInformations()
If @error Then _ExiteMoi()
GUISetState(@SW_SHOW)
EndFunc ;==>_GuiPrepare
; --------------------------------------------------------------
; Recherches des disques + Affichage dans la LSTV ;
; --------------------------------------------------------------
Func _GetDrivesInformations()
Local $aDrv = DriveGetDrive('ALL')
If @error Then
MsgBox(16, $Title, 'Aucun lecteur sur ce PC !' & @CRLF & @CRLF & 'Cliquer OK pour fermer')
Return SetError(@error)
EndIf
Dim $aDrives[$aDrv[0] + 1][8]
$aDrives[0][0] = $aDrv[0]
_GUIImageList_Destroy($hImage)
$hImage = _GUIImageList_Create($iCX, $iCY, 5, 3)
_GUICtrlListView_SetImageList($hLstV, $hImage, 0)
Local $SHFILEINFO, $SHFILEINFO1, $hIcon
For $I = 1 To $aDrv[0]
$aDrives[$I][0] = StringUpper($aDrv[$I])
$aDrives[$I][1] = DriveGetType($aDrv[$I])
$aDrives[$I][2] = DriveGetLabel($aDrv[$I])
$aDrives[$I][3] = DriveStatus($aDrv[$I])
$SHFILEINFO = DllStructCreate($tagSHFILEINFO)
_WinAPI_ShellGetFileInfo($aDrives[$I][0], $SHGFI_ICONLOCATION, 0, $SHFILEINFO)
$aDrives[$I][4] = DllStructGetData($SHFILEINFO, 2)
$hIcon = _WinAPI_ShellExtractIcon(DllStructGetData($SHFILEINFO, 4), DllStructGetData($SHFILEINFO, 2), $iCX, $iCX)
_GUIImageList_ReplaceIcon($hImage, -1, $hIcon)
_WinAPI_DestroyIcon($hIcon)
_GUICtrlListView_AddItem($hLstV, $aDrives[$I][0], $I - 1)
$SHFILEINFO1 = DllStructCreate($tagSHFILEINFO)
_WinAPI_ShellGetFileInfo($aDrives[$I][0], $SHGFI_TYPENAME, 0, $SHFILEINFO1)
$aDrives[$I][5] = DllStructGetData($SHFILEINFO1, 5)
_GetDriveMoreInfos($I)
Next
_SetGroups()
EndFunc ;==>_GetDrivesInformations
; --------------------------------------------------------------
; Création des Groupes dans la LSTV ;
; --------------------------------------------------------------
Func _SetGroups()
$aGroup = ''
$nGroup = 0
Local $iInd
_GUICtrlListView_EnableGroupView($hLstV)
For $I = 1 To $aDrives[0][0]
If $aGroup <> $aDrives[$I][5] Then
$aGroup = $aDrives[$I][5]
$nGroup += 1
$iInd = _ArraySearch($aTypes, $aDrives[$I][1])
_GUICtrlListView_InsertGroup($hLstV, $I, $nGroup, $iTypes[$iInd])
EndIf
_GUICtrlListView_SetItemGroupID($hLstV, $I - 1, $nGroup)
Next
EndFunc ;==>_SetGroups
; --------------------------------------------------------------
; Récupération du type de Média et du nom du lecteur ;
; --------------------------------------------------------------
Func _GetDriveMoreInfos($I)
Local $oWMI = ObjGet('winmgmts:\\' & @ComputerName & '\root\CIMV2')
Local $oCol = '', $oItem = ''
Switch $aDrives[$I][1]
Case $DVD
$oCol = $oWMI.ExecQuery('SELECT * FROM Win32_CDROMDrive Where Drive = "' & _
$aDrives[$I][0] & '"', 'WQL', 0x10 + 0x20)
If IsObj($oCol) Then
For $oItem In $oCol
$aDrives[$I][6] = $oItem.Name
$aDrives[$I][7] = $oItem.MediaType
Next
EndIf
EndSwitch
EndFunc ;==>_GetDriveMoreInfos
; --------------------------------------------------------------
; Copie des fonts et des images ;
; --------------------------------------------------------------
Func _FilesInstall()
DirCreate($DirFonts)
DirCreate($DirInc)
FileInstall('C:\Users\TopXm\Desktop\Dev\BigFolder\Fonts\plasdrip.ttf', $DirFonts & 'plasdrip.ttf', 1)
FileInstall('C:\Users\TopXm\Desktop\Dev\BigFolder\Fonts\calist.ttf', $DirFonts & 'Calist.ttf', 1)
FileInstall('C:\Users\TopXm\Desktop\Dev\BigFolder\Fonts\degradingmorals.ttf', $DirFonts & 'degradingmorals.ttf', 1)
FileInstall('C:\Users\TopXm\Desktop\Dev\BigFolder\include\BigFolder.ico', $DirInc & 'bigfolder.ico', 1)
FileInstall('C:\Users\TopXm\Desktop\Dev\BigFolder\include\Back.ico', $DirInc & 'Back.ico', 1)
_InstallFonts($DirFonts & 'Calist.ttf')
_InstallFonts($DirFonts & 'DegradingMorals.ttf')
_InstallFonts($DirFonts & 'PlasDrip.ttf')
ConsoleWrite('Error=' & @error & @CRLF)
If @error Then Return SetError(@error)
EndFunc ;==>_FilesInstall
; --------------------------------------------------------------
; Installation des fonts dans Windows ;
; --------------------------------------------------------------
Func _InstallFonts($sSourceFile)
Local Const $HWND_BROADCAST = 0xFFFF
Local Const $WM_FONTCHANGE = 0x1D
Local $FontDescript = ""
Local $FontPath = @WindowsDir & "\fonts"
Local $FontName = StringRegExpReplace($sSourceFile, "^.*\\", "")
If FileExists($FontPath & '\' & $FontName) Then Return 1
If Not FileCopy($sSourceFile, $FontPath & "\" & $FontName, 1) Then Return SetError(1, 0, 0)
Local $hGdi32_DllOpen = DllOpen("gdi32.dll")
Local $aRet = DllCall($hGdi32_DllOpen, "Int", "AddFontResource", "str", $FontPath & "\" & $FontName)
If IsArray($aRet) And $aRet[0] > 0 Then
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", _
$FontDescript, "REG_SZ", $FontPath & "\" & $FontName)
EndIf
DllClose($hGdi32_DllOpen)
DllCall("user32.dll", "Int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_FONTCHANGE, "int", 0, "int", 0)
Return 1
EndFunc ;==>_InstallFonts
; --------------------------------------------------------------
; Fin du Taf on sort ... ;
; --------------------------------------------------------------
Func _ExiteMoi()
DirRemove($DirFonts, 1)
DirRemove($DirInc, 1)
Exit
EndFunc ;==>_ExiteMoi
- BigFolder.zip
- (605.28 Kio) Téléchargé 177 fois
► Afficher le texteCapture GUI
