Jump to content

Howto get quality Large Icons in Toolbar using imagelist


rogdog
 Share

Recommended Posts

I would like to use 32x32pixel 32bit icons in a toolbar but can't get them to display correctly in Autoit (3.2.10.0)

The icons look very poor as is they are 16x16pixel 8bit icons.

The following code shows an example icon using the toolbar and imagelist. It also show the same icon using the command GUICtrlCreateIcon.

I would like the toolbar icon to look like the GUICtrlCreateIcon icon

Anyone got any ideas how I can fix this please

CODE

#include <GuiConstantsEx.au3>

#include <GuiImageList.au3>

#Include <GuiToolBar.au3>

Local $id1, $GUI, $hImage

Local Enum $idNew = 1000, $idOpen, $idSave, $idHelp

$GUI = GUICreate("(External) ImageList AddIcon", 400, 300)

GUISetState()

; Load images

$hImage = _GUIImageList_Create (32,32, 5, 3)

_GUIImageList_AddIcon ($hImage, @SystemDir & "\shell32.dll", 20)

; Create toolbar

$hToolbar = _GUICtrlToolBar_Create($GUI)

_GUICtrlToolbar_SetImageList($hToolbar, $hImage)

_GUICtrlToolbar_AddButton ($hToolbar, $id1, 0)

; add Gui icon

$icon = GUICtrlCreateIcon (@SystemDir & "\shell32.dll",21, 3,50)

; Loop until user exits

Do

Until GUIGetMsg() = $GUI_EVENT_CLOSE

GUIDelete()

Edited by rogdog
My Scripts[topic="73325"]_ReverseDNS()[/topic]Favourite scripts by other members[topic="81687"]SNMP udf[/topic][topic="70759"]Using SNMP - MIB protocol[/topic][topic="39050"]_SplitMon:Section off your monitor!, split your monitor into sections for easy management[/topic][topic="73425"]ZIP.au3 UDF in pure AutoIt[/topic][topic="10534"]WMI ScriptOMatic tool for AutoIt[/topic][topic="51103"]Resources UDF embed/use any data/files into/from AutoIt compiled EXE files[/topic]
Link to comment
Share on other sites

Replace _GUIImageList_AddIcon function in GuiImageList.au3 with the following

Func _GUIImageList_AddIcon($hWnd, $sFile, $iIndex = 0, $fLarge = False)
    Local $tIcon, $iResult, $hIcon

    $tIcon = DllStructCreate("int Handle")
    If $fLarge Then
        $iResult = _WinAPI_ExtractIconEx($sFile, $iIndex, DllStructGetPtr($tIcon), 0, 1)
    Else
        $iResult = _WinAPI_ExtractIconEx($sFile, $iIndex, 0, DllStructGetPtr($tIcon), 1)
    EndIf
    _WinAPI_Check("_GUIImageList_AddIcon", ($iResult <= 0), -1)

    $hIcon = DllStructGetData($tIcon, "Handle")
    $iResult = _GUIImageList_ReplaceIcon($hWnd, -1, $hIcon)
    _WinAPI_Check("_GUIImageList_AddIcon", ($iResult = -1), -2)
    _WinAPI_DestroyIcon($hIcon)
    Return $iResult
EndFunc   ;==>_GUIImageList_AddIconoÝ÷ ÚØ^Ébf¡ØÆ­í¢Ø^)Þi×baz'(ú+{¦¦WºÚ"µÍÚ[ÛYH   ÑÝZPÛÛÝ[Ñ^]LÉÝÂÚ[ÛYH ÑÝZR[XYÙSÝ]LÉÝÂÒ[ÛYH   ÑÝZUÛÛ]LÉÝÂØØ[ ÌÍÚYK    ÌÍÑÕRK  ÌÍÚ[XYÙBØØ[[[H    ÌÍÚY]ÈHL    ÌÍÚYÜ[  ÌÍÚYØ]K ÌÍÚY[ÌÍÑÕRHHÕRPÜX]J    ][ÝÊ^[
H[XYÙSÝYXÛÛ][ÝË
Ì
BÈÜX]HÛÛÌÍÚÛÛHÑÕRPÝÛÛÐÜX]J  ÌÍÑÕRJBÕRTÙ]Ý]J
BÈØY[XYÙÂÌÍÚ[XYÙHHÑÕRR[XYÙSÝÐÜX]H
ÌÌ
KÊBÑÕRR[XYÙSÝÐYXÛÛ
    ÌÍÚ[XYÙKÞÝ[[È ][ÝÉÌLÜÚ[Ì    ][ÝËYJBÑÕRPÝÛÛÔÙ][XYÙSÝ
    ÌÍÚÛÛ  ÌÍÚ[XYÙJBÑÕRPÝÛÛÐY]Û
    ÌÍÚÛÛ  ÌÍÚYK
BÈYÝZHXÛÛÌÍÚXÛÛHÕRPÝÜX]RXÛÛ
ÞÝ[[È ][ÝÉÌLÜÚ[Ì    ][ÝËKË
L
BÈÛÜ[[Ù^]ÂÂ[[ÕRQÙ]ÙÊ
HH  ÌÍÑÕRWÑUSÐÓÔÑBÕRQ[]J

I'll probably add that modification to the next beta.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Cool, thanks for quick replys and excelent fix Gary .

I have tested it out and it works great

My Scripts[topic="73325"]_ReverseDNS()[/topic]Favourite scripts by other members[topic="81687"]SNMP udf[/topic][topic="70759"]Using SNMP - MIB protocol[/topic][topic="39050"]_SplitMon:Section off your monitor!, split your monitor into sections for easy management[/topic][topic="73425"]ZIP.au3 UDF in pure AutoIt[/topic][topic="10534"]WMI ScriptOMatic tool for AutoIt[/topic][topic="51103"]Resources UDF embed/use any data/files into/from AutoIt compiled EXE files[/topic]
Link to comment
Share on other sites

Thank You Gary!

I've wondered about that since using PaulIA's Auto3Lib Toolbar

and Tonedeaf's and your old GuiToolbar UDF

found a few references in google to the problem with imagelist improperly using 32 bit icons

but the code solution was beyond me.

Adding and using 32 bit alphablended images and icons to the imagelist control

Displaying Alpha (32bit) Icons with ImageLists

Thanks again

I see fascists...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...