﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
4041	_GUICtrlStatusBar_SetIcon	Nine	Jpm	"Destroying the icon at the end of the function prevents the icon from being shown.

{{{
#include <GUIConstants.au3>
#include <GuiStatusBar.au3>

Example()

Func Example()
  Local $aPartRightSide[3] = [100, 100, -1]

  Local $hGUI = GUICreate(""Test"", 400, 300)
  Local $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
  _GUICtrlStatusBar_SetText($hStatusBar, ""Part 1"")
  _GUICtrlStatusBar_SetText($hStatusBar, ""Part 2"", 1)

  _GUICtrlStatusBar_SetIcon($hStatusBar, 0, 23, ""shell32.dll"") ; not working
  _GUICtrlStatusBar_SetIconEx($hStatusBar, 1, 23, ""shell32.dll"") ; working
  GUISetState(@SW_SHOW)

  Do
  Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Func _GUICtrlStatusBar_SetIconEx($hWnd, $iPart, $hIcon = -1, $sIconFile = """")
  If $hIcon = -1 Then Return _SendMessage($hWnd, $SB_SETICON, $iPart, $hIcon, 0, ""wparam"", ""handle"") <> 0 ; Remove Icon
  If StringLen($sIconFile) <= 0 Then Return _SendMessage($hWnd, $SB_SETICON, $iPart, $hIcon) <> 0 ; set icon from icon handle

  ; set icon from file
  Local $tIcon = DllStructCreate(""handle"")
  Local $vResult = DllCall(""shell32.dll"", ""uint"", ""ExtractIconExW"", ""wstr"", $sIconFile, ""int"", $hIcon, ""ptr"", 0, ""struct*"", $tIcon, ""uint"", 1)
  If @error Then Return SetError(@error, @extended, False)
  $vResult = $vResult[0]
  If $vResult > 0 Then $vResult = _SendMessage($hWnd, $SB_SETICON, $iPart, DllStructGetData($tIcon, 1), 0, ""wparam"", ""handle"")
  ;DllCall(""user32.dll"", ""bool"", ""DestroyIcon"", ""handle"", DllStructGetData($tIcon, 1)) ; this needs to be removed

  Return $vResult
EndFunc   ;==>_GUICtrlStatusBar_SetIconEx

}}}
"	Bug	closed	3.3.17.0	AutoIt	3.3.16.1	None	Fixed		
