Jump to content

Custom Picture in LIstView


SoulA
 Share

Recommended Posts

Hoping someone can point me in the right direction. Trying to add my own custom bitmap image into a listview.

My test code...

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <Constants.au3>
#Include <WinAPI.au3>

_Main()

Func _Main()
    Local $hImage, $hListView
    
    $school = _WinAPI_LoadImage(0, "school.bmp", $IMAGE_BITMAP, 0, 0, BitOr($LR_LOADFROMFILE, $LR_DEFAULTSIZE))
    
    ; Create GUI
    GUICreate("Custom Picture", 400, 300)
    $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUICtrlSetStyle($hListView, $LVS_ICON)
    GUISetState()

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, $school)
    _GUICtrlListView_SetImageList($hListView, $hImage, 0)

    ; Add items
    _GUICtrlListView_AddItem($hListView, "Item 1", 0)

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_MainoÝ÷ Øêð«Zn­¶¬jëh×6#include <GuiConstantsEx.au3>
#include <WinAPI.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

_Main()

Func _Main()

    GUICreate("ImageList AddBitmap", 400, 300)
    $listview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($listview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
    GUISetState()
    
    ; Load images
    $hImage = _GUIImageList_Create(16, 32)
    _GUIImageList_AddBitmap($hImage, "School.bmp")
    _GUICtrlListView_SetImageList($listview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($listview, "Items", 120)

    ; Add items
    _GUICtrlListView_AddItem($listview, "Item 1", 0)

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main

This is the .bmp

School.bmp

Edited by SoulA
Link to comment
Share on other sites

Urm, renaming a file to bmp does not make it a bmp file..

The image you posted is a jpg renamed to bmp, try converting the image to a bmp properly then use the 2nd code you posted..

Also you might want to use the full path to the image your trying to load.

Edit: here's the image as a bmp (not just renamed)

Cheers

Edited by smashly
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...