Jump to content

list of items and pictures


gcue
 Share

Recommended Posts

im trying to read from a list of items in an INI and generate the pictures associated to it in the INI

so far it doesnt load the images =/

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

Global $ini = "settings.ini"

Local $hImage, $hListView

GUICreate("Custom Picture", 400, 300, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
        $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
        GUICtrlSetStyle($hListView, $LVS_ICON)
        GUISetState()

$products = IniReadSection($ini, "PRODUCTS")

If IsArray($products) Then
    For $n = 1 To $products[0][0]
        $product_list = _WinAPI_LoadImage(0, $products[$n][1], $IMAGE_BITMAP, 175, 175, BitOR($LR_LOADFROMFILE, $LR_DEFAULTSIZE))

; Load images
        $hImage = _GUIImageList_Create()
        _GUIImageList_Add($hImage, $products[$n][1])
        _GUICtrlListView_SetImageList($hListView, $hImage, 0)

; Add items
        _GUICtrlListView_AddItem($hListView, $products[$n][0], 0)
    Next
EndIf
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()

INI

[PRODUCTS]
bah=pam.jpg
junk=pam.bmp
Edited by gcue
Link to comment
Share on other sites

  • Moderators

Your missing hisntance. You may want to try the GDIPlus library functions instead (Load from file one I believe). Then set the bitmap/picture to the GUI. I believe martin and nahuel put a function together yesterday or the day before to do this called SetBitmap, you can do a search for it.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

LOL i tried using this line

$product_list = _GDIPlus_BitmapCreateFromFile($products[$n][1])

in place of this line

$product_list = _WinAPI_LoadImage(0, $products[$n][1], $IMAGE_BITMAP, 175, 175, BitOR($LR_LOADFROMFILE, $LR_DEFAULTSIZE))

i get a gui crash hehehe.
Link to comment
Share on other sites

heheh same thing.. get hour glass then crash..

i tried to make the pic alot smaller 10x50 and still get the crash =/

jpg format

filesize 844 bytes

An example to use GDI+, to show you that isn't error with _GDIPlus_ImageLoadFromFile()

#include <GDIPlus.au3>
$FILE = FileOpenDialog("SELECT",@ScriptDir,"Pictures (*.bmp;*.png;*.jpg)",1)
_GDIPlus_Startup()
$hIMG = _GDIPlus_ImageLoadFromFile($FILE)
$X = _GDIPlus_ImageGetWidth($hIMG)
$Y = _GDIPlus_ImageGetHeight($hIMG)
$GUI = GUICreate("TEST",$X,$Y)
GUISetState(@SW_SHOW,$GUI)
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($GUI)
_GDIPlus_GraphicsDrawImage($hGraphic,$hIMG,0,0)

While 1
    If GUIGetMsg() = -3 Then ExitLoop
    Sleep(20)
WEnd
_GDIPlus_Shutdown()

When the words fail... music speaks.

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...