Function Reference


_GUICtrlListView_SetBkImage

Sets the background image in the control

#include <GuiListView.au3>
_GUICtrlListView_SetBkImage ( $hWnd [, $sURL = "" [, $iStyle = 0 [, $iXOffset = 0 [, $iYOffset = 0]]]] )

Parameters

$hWnd Control ID/Handle to the control
$sURL [optional] URL of the background image. If blank, the control has no background
$iStyle [optional] Determines the background image style:
    0 - Normal
    1 - Tiled
$iXOffset [optional] Percentage of the control's client area that the image should be offset horizontally.
Only valid when 0 is used in $iStyle.
$iYOffset [optional] Percentage of the control's client area that the image should be offset vertically.
Only valid when 0 is used in $iStyle.

Return Value

Success: True.
Failure: False.

Remarks

Call CoUninitialize when the application is terminating.
At this time this function only works with _GUICtrlListView_Create() or External ListViews.

Related

_GUICtrlListView_Create, _GUICtrlListView_GetBkImage

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example_UDF_Created() ;use UDF built listview

Func Example_UDF_Created()
        Local $iStylesEx = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)

        Local $hGUI = GUICreate("(UDF Created) ListView Set Background Image (v" & @AutoItVersion & ")", 600, 550)

        Local $hListView = _GUICtrlListView_Create($hGUI, "", 2, 2, 596, 500, -1, -1, True) ; Last option Calls CoInitializeEx
        _GUICtrlListView_SetExtendedListViewStyle($hListView, $iStylesEx)

        ; Set ANSI format
;~     _GUICtrlListView_SetUnicodeFormat($hListView, False)

        ; Load images
        Local $hImage = _GUIImageList_Create()
        _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
        _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16))
        _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16))
        _GUICtrlListView_SetImageList($hListView, $hImage, 1)

        ; Add columns
        _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
        _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)
        _GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100)

        ; Add items
        _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
        _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1)
        _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2)
        _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
        _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1)
        _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)

        ; Build groups
        _GUICtrlListView_EnableGroupView($hListView)
        _GUICtrlListView_InsertGroup($hListView, -1, 1, "Group 1")
        _GUICtrlListView_InsertGroup($hListView, -1, 2, "Group 2")
        _GUICtrlListView_SetItemGroupID($hListView, 0, 1)
        _GUICtrlListView_SetItemGroupID($hListView, 1, 2)
        _GUICtrlListView_SetItemGroupID($hListView, 2, 2)

        ; Get the Image
        Local $sURL = "http://www.autoitscript.com/autoit3/files/graphics/autoit9_wall_grey_800x600.jpg"
        Local $sFilePath = @ScriptDir & "\AutoIt.jpg"
        InetGet($sURL, $sFilePath)

        ; Set the Background Image
        _GUICtrlListView_SetBkImage($hListView, $sFilePath)
        Local $aImage = _GUICtrlListView_GetBkImage($hListView)

        GUISetState(@SW_SHOW)

        MsgBox($MB_SYSTEMMODAL, "Information", "Background Image: " & $aImage[1])

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
        DllCall('ole32.dll', 'long', 'OleUninitialize') ; Must call for each CoInitializeEx call made
        GUIDelete()
        FileDelete($sFilePath)
EndFunc   ;==>Example_UDF_Created