Je me suis permis d'ajouter le mode CatchImage() à ton exemple pour ceux qui se demanderaient comment faire, avec des data et en include.
Code : Tout sélectionner
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : SetToolBarIconSize
; File : SetToolBarIconSize.pb
; File Version : 1.0.0
; Programmation : OK
; Programmed by : Guimauve
; Date : 04-06-2006
; Last Update : 04-06-2006
; Coded for PureBasic V4.00
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#TB_SETIMAGELIST = 1072
#TB_GETIMAGELIST = 1073
Macro SetToolBarIconSize(ToolBar, IconSize)
SendMessage_(ToolBarID(ToolBar), #TB_SETBITMAPSIZE, 0, (IconSize << 16) + IconSize)
ImageList_SetIconSize_(SendMessage_(ToolBarID(ToolBar), #TB_GETIMAGELIST, 0, 0) , IconSize , IconSize)
SendMessage_(ToolBarID(ToolBar), #TB_AUTOSIZE, 0, 0)
EndMacro
Enumeration
#Fenetre
#Menu
#BarreOutil
#TBtn_Alpha
#TBtn_Beta
#TBtn_Delta1
#TBtn_Delta2
EndEnumeration
;CHARGER DES ICONES
Global Image0,Image1
Image0 = CatchImage(0, ?Image0)
Image1 = CatchImage(1, ?Image1)
If OpenWindow(#Fenetre, 0, 0, 400, 300, "SetToolBarIconSize", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If CreateMenu(#Menu, WindowID(#Fenetre))
MenuTitle("File")
MenuItem(1, "Open" +Chr(9)+"Ctrl+O")
MenuItem(2, "Save" +Chr(9)+"Ctrl+S")
MenuItem(3, "Save as"+Chr(9)+"F12")
MenuItem(4, "Quit" +Chr(9)+"Alt+F4")
EndIf
IconSize = 48
If CreateToolBar(#BarreOutil, WindowID(#Fenetre))
SetToolBarIconSize(#BarreOutil, IconSize)
If CreateImage(#TBtn_Alpha,IconSize,IconSize)
StartDrawing(ImageOutput(#TBtn_Alpha));>
Box(0,0,IconSize,IconSize,RGB(255,255,255))
Box(4,4,IconSize-8, IconSize-8,RGB(255,0,0))
StopDrawing();<
EndIf
If CreateImage(#TBtn_Beta,IconSize,IconSize)
StartDrawing(ImageOutput(#TBtn_Beta));>
Box(0,0,IconSize,IconSize,RGB(0,255,0))
Box(4,4,IconSize-8,IconSize-8,RGB(125,255,125))
StopDrawing();<
EndIf
ToolBarImageButton(#TBtn_Alpha , ImageID(#TBtn_Alpha))
ToolBarSeparator()
ToolBarImageButton(#TBtn_Beta , ImageID(#TBtn_Beta))
ToolBarSeparator()
ToolBarImageButton(#TBtn_Delta1 , Image1) ; l'icône en 32x32 est mise à la taille mais ça pixellise
ToolBarImageButton(#TBtn_Delta2 , Image0)
EndIf
Repeat
EventID = WindowEvent()
Select EventID
Case #PB_Event_Menu
Select EventMenu()
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
EndSelect
EndSelect
Until EventID = #PB_Event_CloseWindow
EndIf
End
DataSection
Image0 : IncludeBinary "C:\ICONES\Run01.ico"; 48x48
Image1 : ; 32x32.ico
Data.l $00010000, $20200001, $00010000, $0CA80018, $00160000, $00280000
Data.l $00200000, $00400000, $00010000, $00000018, $08800000, $00000000
Data.l $00000000, $00000000, $00000000, $F4F80000, $F3F4F8F3, $F8F3F4F8
Data.l $F4F8F3F4, $F2F4F8F3, $F7F1F3F7, $EEF5EFF1, $E5EAF3EC, $ECDDE3F0
Data.l $D4E8D3DC, $C2CFE6C9, $E0BBCAE3, $BEDDB4C4, $A4B8DAAB, $D89FB4D8
Data.l $B2D79DB3, $9CB2D79C, $DA9EB3D8, $BEDDA4B8, $B6C6E1AC, $E8BFCDE4
Data.l $DAEBC7D3, $DAE1EED0, $F4E2E7F2, $F4F8EAED, $F3F4F8F3, $F8F3F4F8
Data.l $F4F8F3F4, $F1F3F7F2, $F6F0F2F7, $ECF4EDEF, $E0E5F1E8, $E7D4DDEC
Data.l $C9E3C7D2, $8C918DBA, $D9A8BBDC, $B0D6A1B6, $92AAD399, $6B8398BA
Data.l $A4D15E67, $8BA5D18A, $D48DA7D2, $B1D792AB, $A4B8DA9B, $E1ADBFDE
Data.l $CFE6B7C6, $CFD9EBC2, $F3DBE2EF, $F4F8E4E9, $F3F4F8F3, $F8F3F4F8
Data.l $F3F8F2F4, $F0F2F7F2, $F4EDF0F6, $E7F2E9ED, $D7DFEEE2, $E3CAD5E9
Data.l $AEC4BAC9, $2C23009F, $D37B8AA2, $A4D090A9, $84A0CE8A, $2B2F3538
Data.l $9BCC292B, $7E9BCC7E, $CE809DCD, $A5D184A0, $92ABD48B, $DB9BB1D7
Data.l $C4E0A7BA, $C3D0E6B4, $F0D1DAEB, $F4F8DDE3, $F3F4F8F3, $F8F2F4F8
Data.l $F2F7F2F4, $EFF1F6F1, $B7EAEDF5, $E1EED3CF, $CDD7EADA, $DEBECCE4
Data.l $8897AEC0, $1914017C, $B61B1A12, $9BCC768E, $4251697D, $02070602
Data.l $8DBF0706, $7695C970, $CB7796CA, $9CCC7A98, $839CC47F, $D68DA7D2
Data.l $BADB98AF, $B6C6E1A7, $ECC6D2E7, $F4F8D3DC, $F3F4F8F3, $F8F2F4F8
Data.l $F2F7F2F3, $EDEFF6F0, $5CE6EAF3, $7C3DAC9D, $AFB6BD8A, $D9B1C2DF
Data.l $646CA1B6, $1813015C, $2A110F01, $739A2127, $0707045C, $04050604
Data.l $5F810404, $7192C74A, $987393C8, $2D2A5C73, $6D84A72A, $D1829ECE
Data.l $B0D68CA6, $A9BCDC99, $E8B8C7E2, $F4F8C7D3, $F3F4F8F3, $F7F2F4F8
Data.l $F1F7F1F3, $EBEEF5EF, $96E2E7F2, $5500B8B3, $5544006A, $CA707162
Data.l $443791A6, $251E0144, $041E1902, $14061A16, $11100716, $070D0D07
Data.l $3C51090A, $6988BC2E, $022E3B50, $14110504, $7695C911, $CE7A98CB
Data.l $A7D2839F, $9CB2D78E, $E4ACBEDD, $F4F8BDCB, $F3F4F8F3, $F7F2F4F8
Data.l $F0F6F1F2, $E9ECF4EE, $C2DFE5F1, $5800C4C6, $5F4C006E, $12534300
Data.l $3F115145, $4034024A, $063A2F04, $2909362D, $27240B2F, $0C1E1D0C
Data.l $1B1B1617, $13171916, $04050607, $32430204, $7292C828, $CB7695C9
Data.l $A0CF7C99, $92AAD385, $E0A2B6DA, $F4F8B4C4, $F2F4F8F3, $F7F2F3F8
Data.l $EFF6F0F2, $E6EAF3ED, $E9DBE2EF, $6A10CCD6, $735C0080, $016D5700
Data.l $53016A55, $65520367, $09625005, $470C5B4D, $49401053, $143B3713
Data.l $21132D2C, $1417101F, $090B0E0C, $56750608, $6F90C742, $CA7293C8
Data.l $9CCC7796, $8BA5D17F, $DE9BB1D7, $F4F8ADBF, $F2F3F8F3, $CAF1F3F7
Data.l $DBBAECE5, $D8D3B8E3, $AFCAC8B3, $832CBBBC, $8C700097, $018C7000
Data.l $73018F72, $9075048F, $0B8D7307, $6A108770, $7062167E, $1C5E551A
Data.l $381C4C47, $28291939, $0F181B14, $56760E11, $556E9942, $98576F98
Data.l $7A9A5C73, $7E95B865, $DC95ADD5, $F4F8A8BB, $F2F3F8F3, $CAF1F2F7
Data.l $A711EBE5, $B99400CC, $00AF8C00, $8600A887, $AA8800A7, $01AE8B00
Data.l $9301B490, $B79304B7, $0CB49307, $8A14AE90, $94801BA3, $26807321
Data.l $54276B64, $3F412455, $182B2E1F, $1111191D, $06090C0D, $04050607
Data.l $2C2B0809, $7D98C328, $DA90A9D3, $F4F8A2B6, $F2F3F8F3, $F6F0F2F7
Data.l $D29AEDF0, $C69E00DF, $00C09A00, $9B00BF99, $C7A000C2, $01CEA500
Data.l $AC01D2A9, $D5AC04D6, $0DD2AB07, $A115CBA7, $B0991FC0, $2F9B8C28
Data.l $6C32867D, $57583170, $243E432C, $1D1C272D, $0B111417, $23070A0D
Data.l $8DBE161B, $7F9CCD70, $D88CA7D2, $F4F89FB4, $F2F3F8F3, $F6F1F2F7
Data.l $EBF4EEF0, $DBC56BE8, $00D4AA00, $B000D7AC, $E2B500DD, $01E8BA00
Data.l $B201EABC, $EB8203EC, $0EE5BA07, $B017DCB6, $C1A821D2, $37AE9C2D
Data.l $7F3E988F, $6B6D3F81, $3351583B, $2C293941, $131B1F22, $A6131B23
Data.l $94C85B78, $7D9BCC73, $D88CA5D2, $F4F89DB3, $F2F3F8F3, $F6F1F2F7
Data.l $ECF4EEF0, $E0E3E3E9, $00E6BF1F, $C400EEBE, $FAC800F5, $01FCC900
Data.l $C701FBC9, $F16402F8, $0EEA7C05, $BA17E7BE, $CDB123DC, $3EB7A531
Data.l $8C49A29A, $757B4D8B, $445E684B, $3B394652, $1B282D2F, $C5425C7F
Data.l $93C86B8E, $7D9ACC72, $D98BA6D1, $F4F89DB3, $F2F4F8F3, $9DF3F2EA
Data.l $D54FF6E5, $F9C700F6, $00FCC900, $D400FFCF, $FFD600FF, $01FFD500
Data.l $CE01FED1, $FBBF04FD, $06DB0E00, $BC18D24B, $D0B525E0, $45BCAB35
Data.l $9252A59F, $79835A8F, $5665735C, $4B4B5061, $25353E3A, $2F16242F
Data.l $455B1621, $576A8634, $D887A0C6, $F4F89EB4, $F6EEBCF3, $00FEDD11
Data.l $D400FFD7, $FFD500FF, $00FFD900, $E100FFDE, $FFE100FF, $01FFDD00
Data.l $D101FED8, $FBCD04FD, $00E56604, $490AB500, $D0B629B4, $4CBBAC3A
Data.l $945CA4A0, $7787678C, $67647A6C, $575E536A, $2C425040, $2F1E303F
Data.l $1A211321, $171B1610, $D95D6972, $F4F89EB4, $F2F4F8F3, $5EF3F3EA
Data.l $E000F9E8, $FFE100FF, $00FFE600, $EE00FFEB, $FFEA00FF, $01FFE500
Data.l $D502FDDC, $FACE05FD, $01F3BE09, $0000B30E, $812F0B88, $54B1A13D
Data.l $93669FA0, $71877486, $78617C79, $606F5370, $334E6143, $3E243B50
Data.l $3E55182C, $6F8CB72B, $DA8CA7D2, $F4F8A1B7, $F2F4F8F3, $F7F2F3F8
Data.l $EFC9F0F2, $F9EC3FF0, $00FFF100, $F700FFF6, $FFF300FF, $01FFEB00
Data.l $D703FDE1, $F9D106FC, $0AF3CA0C, $0000CB64, $5B000082, $5752210D
Data.l $91709295, $6B867E7F, $855C7D86, $667E5073, $37577044, $9F304D6C
Data.l $92C74C70, $7C9CCD6C, $DC90ABD4, $F4F8A5BB, $F2F4F8F3, $F7F2F3F8
Data.l $F0F6F0F2, $F2F19BEE, $00FFFB00, $FF00FFFF, $FFFB00FF, $01FFF300
Data.l $DD03FDE7, $F8D407FC, $17F1CB0D, $0D03E4BA, $5B00008A, $0D360000
Data.l $75622E15, $64848767, $8F567C8F, $6A874C74, $395C7A44, $9B2C4C68
Data.l $93C8496E, $80A0CE6D, $DE95AFD6, $F4F8ACC0, $F2F4F8F3, $EAF2F4F8
Data.l $F85EF3F4, $FFFD00F9, $00FFFF00, $FF00FFFF, $FFFF00FF, $01FFFB00
Data.l $E403FDF0, $F8DA07FC, $19F0D00E, $6014E5C7, $640000B1, $003D0000
Data.l $0A081F00, $516B7418, $95537B95, $6C8D4A75, $3A5F7F43, $582F506D
Data.l $5C782741, $85A4D143, $E19CB4D8, $F4F8B4C5, $F3F4F8F3, $30F5F6CB
Data.l $FF00FDFD, $FFFF00FF, $00FFFF00, $FF00FFFF, $FFFF00FF, $01FFFF00
Data.l $EE03FDF9, $F8E207FC, $18F1D80D, $B726E5CC, $7D0D04D2, $004E0000
Data.l $00002C00, $110A0A14, $963C5668, $6D8E4A75, $3C618044, $5934536D
Data.l $3D442C45, $4E5B5B2C, $E4A0B4D1, $F4F8BBCB, $F4F5E9F3, $7DF8F98C
Data.l $FA6EF9F9, $FCFC40FA, $20FBFC3F, $FF00FDFD, $FFFF00FF, $01FFFF00
Data.l $F802FDFE, $FCB405FD, $11F3AB09, $981CE4A1, $A23C13D0, $00690000
Data.l $00004000, $0E000021, $5E080000, $6D8D3449, $436A8B45, $74436482
Data.l $768A445E, $7180845E, $E798A3A4, $F4F8C3D2, $F3F4F8F3, $F8F3F4F8
Data.l $F4F8F3F4, $F1F3F7F2, $5EEFF1F6, $FF00F8FA, $FFFF00FF, $01FFFF00
Data.l $FD02FEFE, $FF4001FD, $00FF0000, $0000EE00, $B60000D7, $008C0000
Data.l $00005D00, $18000034, $000B0000, $37450A00, $4C739730, $CF6993C9
Data.l $AED57CA0, $A6BDDD91, $EABACBE4, $F4F8CCD8, $F3F4F8F3, $F8F3F4F8
Data.l $F4F8F3F4, $F2F3F8F2, $00F3F4DA, $FF00FFFF, $FFFF00FF, $01FFFF00
Data.l $FE01FEFE, $FDAF03FD, $00FF0000, $0000FF00, $DD0000F7, $00B50000
Data.l $00008100, $2800004F, $00120000, $00000D00, $39272C15, $D36F94C0
Data.l $B8DA88A9, $B3C7E29E, $EDC7D4E9, $F4F8D5DF, $F3F4F8F3, $F8F3F4F8
Data.l $F4F8F3F4, $F2F4F8F3, $00FAFB5F, $FF00FFFF, $FFFF00FF, $00FFFF00
Data.l $FE01FFFF, $FDFD02FE, $00FF2201, $0000FF00, $FF0000FF, $00DF0000
Data.l $140DA800, $4A221D73, $2030201F, $1D1F241F, $381C1C27, $D75F5057
Data.l $C1DF94B2, $BECFE6AA, $F0CFDBEC, $F4F8DDE4, $F3F4F8F3, $F8F3F4F8
Data.l $F4F8F3F4, $F4F5DBF3, $00FFFF00, $FB5FFFFF, $F3F4BAFB, $00FBFC3F
Data.l $FE01FFFF, $FDFE01FE, $00FE9003, $0000FF00, $FF0000FF, $00FF0000
Data.l $0B06CD00, $7878538F, $A46F8A8F, $7B7E6C8D, $5C6F6162, $CA616E54
Data.l $C9E39CB3, $C9D6E9B5, $F2D7E1EE, $F4F8E2E8, $F3F4F8F3, $F8F3F4F8
Data.l $F4F8F3F4, $FAFA6DF3, $DBF9F97D, $F3F7F4F5, $F0F2F7F1, $00FBFC40
Data.l $FF00FFFF, $FDFE01FF, $00FCEA13, $0000FF11, $FF0000FF, $00FF0000
Data.l $0000EB00, $751C0EAB, $D583918E, $AED68CAD, $92ADC98F, $9A90A09C
Data.l $D1E79FAA, $D1DCECC1, $F3DDE5F1, $F4F8E6EB, $F3F4F8F3, $F8F3F4F8
Data.l $F4F8F3F4, $F3F4F8F3, $F8F3F4F8, $F4F8F3F4, $F2F3F8F2, $00FCFC40
Data.l $FF00FFFF, $F2F49BFF, $01F3F07B, $0000FE59, $FF0000FF, $00FF0000
Data.l $0000FF00, $890000C5, $DE764037, $C1DFA7C0, $AFC4E1A9, $E7B7CAE3
Data.l $D9EBC1D2, $D8E2EFCD, $F5E2E9F2, $F4F8E9EE, $F3F4F8F3, $F8F3F4F8
Data.l $F4F8F3F4, $F3F4F8F3, $F8F3F4F8, $F4F8F3F4, $F2F4F8F3, $00FCFC41
Data.l $F89DFFFF, $EEF1F6F7, $11EEF1E8, $0000FDCF, $FF0000FF, $00FF0000
Data.l $0000FF00, $A10000DA, $85740000, $D1E79678, $C5D4E8C1, $EDCAD8EA
Data.l $E2EFD1DD, $E1E8F2D9, $F6E7EDF4, $F4F8ECF0, $F3F4F8F3, $F8F3F4F8
Data.l $F4F8F3F4, $F3F4F8F3, $F8F3F4F8, $F4F8F3F4, $F3F4F8F3, $9DFCFC41
Data.l $F3F8F7F8, $F1F3F7F2, $7DF0F2F7, $3A01F7EE, $FF0000FF, $00FF0000
Data.l $0000FF00, $B60000E9, $008C0000, $A9B47300, $D6E0EEBA, $F1D9E3EF
Data.l $E8F3DEE5, $E7EDF4E2, $F7ECEFF6, $F4F8EFF1, $F3F4F8F3, $F8F3F4F8
Data.l $F4F8F3F4, $F3F4F8F3, $F8F3F4F8, $F4F8F3F4, $F3F4F8F3, $F8F5F6CA
Data.l $F4F8F3F4, $F2F4F8F2, $EAF2F4F8, $A10DF3F4, $FF0000FE, $00FF0000
Data.l $0000FF00, $C50000F5, $009D0000, $10118400, $D7CDD684, $F4E3EAF3
Data.l $EDF5E5EB, $ECEFF6E9, $F7EEF1F6, $F4F8F0F2, $F3F4F8F3, $F8F3F4F8
Data.l $F4F8F3F4, $F3F4F8F3, $F8F3F4F8, $F4F8F3F4, $F3F4F8F3, $F8F3F4F8
Data.l $F4F8F3F4, $F3F4F8F3, $F8F3F4F8, $F2ACF2F4, $F0F3F7F6, $F6EEF2F7
Data.l $EEF6EDF0, $E9EDF5EB, $F4E6ECF4, $EBF4E6EC, $E6EBF4E5, $F5E7ECF4
Data.l $EFF5E9ED, $EDF0F6EB, $F7EFF2F7, $F4F8F1F3, $F3F4F8F3, $F8F3F4F8
Data.l $F4F8F3F4, $F3F4F8F3, $F8F3F4F8, $F4F8F3F4, $F3F4F8F3, $F8F3F4F8
Data.l $F4F8F3F4, $F3F4F8F3, $F8F3F4F8, $F4F8F3F4, $F3F4F8F3, $F8F3F4F8
Data.l $F4F8F2F4, $F2F4F8F2, $F8F3F4F8, $F4F8F3F4, $F3F4F8F3, $F8F3F4F8
Data.l $F4F8F3F4, $F3F4F8F3, $F8F3F4F8, $0000F3F4, $00000000, $00000000
Data.l $00000000, $00000000, $00000000, $00000000, $00000000, $00000000
Data.l $00000000, $00000000, $00000000, $00000000, $00000000, $00000000
Data.l $00000000, $00000000, $00000000, $00000000, $00000000, $00000000
Data.l $00000000, $00000000, $00000000, $00000000, $00000000, $00000000
Data.b 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
EndDataSection
; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<
Encore merci, ça va me servir.