Jump to content

Get remote picture into GUI picture box


 Share

Recommended Posts

Hi everyone

I'm building a small quiz script which reads/writes results from MySQL.

I'm pretty new to using the GUI functions of AutoIt and I've used the Koda editor to design up my GUI. It all works fine and I can get data into and out of the input boxes correctly.

I've also got a picturebox on the GUI and I'd like to get a particular PNG from a URL and insert it into that picture box in the GUI.

Is that possible?

Cheers, B

Link to comment
Share on other sites

Hi everyone

I'm building a small quiz script which reads/writes results from MySQL.

I'm pretty new to using the GUI functions of AutoIt and I've used the Koda editor to design up my GUI. It all works fine and I can get data into and out of the input boxes correctly.

I've also got a picturebox on the GUI and I'd like to get a particular PNG from a URL and insert it into that picture box in the GUI.

Is that possible?

Cheers, B

#Include <GDIPlus.au3>

GUICreate('Test', 400, 400)
$Pic = GUICtrlCreatePic('', 75, 75, 250, 250)
GUISetState()

_SetImage($Pic, '1.png')
Sleep(1000)
_SetImage($Pic, '2.png')
Sleep(1000)
_SetImage($Pic, '3.png')

do
until GUIGetMsg() = -3

func _SetImage($controlID, $sFileName)
    
    local $hWnd, $hImage, $hBitmap

    $hWnd = GUICtrlGetHandle($controlID)
    if not IsPtr($hWnd) then
        return SetError(1, 0, 0)
    endif
    if not GUICtrlSetImage($controlID, '') then
        return SetError(1, 0, 0)
    endif
    _GDIPlus_Startup()
    $hImage = _GDIPlus_BitmapCreateFromFile($sFileName)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    _GDIPlus_BitmapDispose($hImage)
    _GDIPlus_Shutdown()
    if $hBitmap = 0 then
        return SetError(1, 0, 0)
    endif
    _WinAPI_SetWindowLong($hWnd, -16, BitOR(_WinAPI_GetWindowLong($hWnd, -16), 0x0E))
    _SendMessage($hWnd, 0x0172, 0, $hBitmap)
    return SetError(0, 0, 1)
endfunc; _SetImage
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...