Toolbar : comment avoir de larges icones ?

Aide sur les Interfaces Graphique Utilisateurs (GUI).
Règles du forum
.
Répondre
IsLaMalice
Niveau 4
Niveau 4
Messages : 50
Enregistré le : lun. 03 avr. 2017 23:31
Status : Hors ligne

Toolbar : comment avoir de larges icones ?

#1

Message par IsLaMalice »

Bonjour,

Je me bats toujours avec ma toolbar... j'arrive à y mettre mes icones, des BMP, avec la commande
_GUICtrlToolbar_LoadBitmap($ToolBar1, @ScriptDir & "\icones\escargot21.bmp")

masi j'obtiens des boutons rognés en 16x16 pixels. Trop petits pour faire une jolie icone d'escargot ...

Je pensais trouvé mon bonheur dans :
_GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

mais les icones deviennent des boutons standards...

help !
Islamalice


(PS : soit dit en passant l'aide place $IDB_STD_LARGE_COLOR en 3eme position au lieu de 4e...)
#include <GuiToolbar.au3>
_GUICtrlToolbar_AddBitmap ( $hWnd, $iButtons, $hInst, $iID )

hInst : Handle to the module instance with the executable file that contains a bitmap resource.
To use bitmap handles instead of resource IDs, set this to 0. You can add system defined button bitmaps to the list by specifying -1 as the $hInst member and one of the following values as the $iID member:
$IDB_STD_LARGE_COLOR - Adds large, color standard bitmaps
$IDB_STD_SMALL_COLOR - Adds small, color standard bitmaps
$IDB_VIEW_LARGE_COLOR - Adds large, color view bitmaps
$IDB_VIEW_SMALL_COLOR - Adds small, color view bitmaps
IsLaMalice
Niveau 4
Niveau 4
Messages : 50
Enregistré le : lun. 03 avr. 2017 23:31
Status : Hors ligne

Re: Toolbar : comment avoir de larges icones ?

#2

Message par IsLaMalice »

un bout de mon code, si vous voulez tester...

Code : Tout sélectionner

#include <GuiToolbar.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Users\Rage\Documents\tests-de-scripts\form.kxf
$Form1 = GUICreate("POC", 140, 488, 358, 295)
$ToolBar1 = _GUICtrlToolbar_Create($Form1)
$ico_escargot=1000



;~ _GUICtrlToolbar_AddBitmap($ToolBar1, 5, -1, $IDB_STD_LARGE_COLOR)



_GUICtrlToolbar_LoadBitmap($ToolBar1, @ScriptDir & "\icones\escargot21.bmp")
_GUICtrlToolbar_AddButton($ToolBar1, $ico_escargot, 0)

_GUICtrlToolbar_SetButtonSize($ToolBar1, 36, 36)

GUISetState(@SW_SHOW)

	Do
	Until GUIGetMsg() = -3
	GUIDelete()
IsLaMalice
Niveau 4
Niveau 4
Messages : 50
Enregistré le : lun. 03 avr. 2017 23:31
Status : Hors ligne

Re: Toolbar : comment avoir de larges icones ?  

#3

Message par IsLaMalice »

hourra !!

_GUICtrlToolbar_SetBitmapSize ( $ToolBar1, 24, 24 )

la persévérance paie
Avatar du membre
Numeric
Niveau 5
Niveau 5
Messages : 126
Enregistré le : mer. 23 mars 2016 08:17
Status : Hors ligne

Re: Toolbar : comment avoir de larges icones ?

#4

Message par Numeric »

Salut je te propose un exemple...La fonction ci dessous peut être largement améliorée... :D , je te laisse ce soin :lol:
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <WinAPIShellEx.au3>
#include <WinAPIShPath.au3>


__MyToolbar()

Func __MyToolbar()
   Local $hGUI, $hToolbar

   $hGUI = GUICreate("Toolbar", 600, 300)
   $hToolbar = _GUICtrlToolbar_Create($hGUI)
   GUISetState(@SW_SHOW)

   Local $hBitmap = @ScriptDir & "\toolbar.bmp"
   MyToolbarLoadBMP($hToolbar, $hBitmap, 200, 100)
   MyToolbarLoadBMP($hToolbar, $hBitmap, 200, 100)
   MyToolbarLoadBMP($hToolbar, $hBitmap, 200, 100)

   Do
   Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


; #FUNCTION# ====================================================================================================================
; Name ..........: MyToolbarLoadBMP
; Description ...: Ajoute des images bmp au control toolbar
; Syntax ........: MyToolbarLoadBMP($hToolbar, $sFileName[, $iWidth = Default[, $iHeight = Default]])
; Parameters ....: $hToolbar            - a handle value.
;                  $sFileName           - a string value.
;                  $iWidth              - [optional] an integer value. Default is Default.
;                  $iHeight             - [optional] an integer value. Default is Default.
; Return values .: None
; Author ........: Numeric
; Modified ......:
; Remarks .......: Cette fonction n'est pas optimisee! juste un exemple...
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func MyToolbarLoadBMP($hToolbar, $sFileName, $iWidth = Default, $iHeight = Default)
   Local $File_Ext

   If $iWidth = Default Then $iWidth = 100 ;tu parles de larges images...
   If $iHeight = Default Then $iHeight = 100;         ""

   If Not FileExists($sFileName) Then _WinAPI_ShowError("Not found!");Le fichier n'existe pas

    $File_Ext = _WinAPI_PathFindExtension($sFileName) ;on cherche l"extention du fichier
   If $File_Ext <> ".bmp" Then
      _WinAPI_ShowError("Extension invalide!"); ici tu peux convertir le fichier en .bmp
   EndIf
   Dim $e_idRed = 1000

   _GUICtrlToolbar_SetBitmapSize($hToolbar, $iWidth, $iHeight)
   _GUICtrlToolbar_LoadBitmap($hToolbar, $sFileName)
   _GUICtrlToolbar_AddButton($hToolbar, $e_idRed, 0)
EndFunc   ;==>MyToolbarLoadBMP


 
Fichiers joints
toolbar.zip
(1.42 Kio) Téléchargé 312 fois
De 0 et 1 vers les étoiles , tout part du Binaire, Numeric
Répondre