Jump to content

GUI with Image but where is image?


Recommended Posts

hi friends, i created the following GUI to learn about GUI but on another computer it is not showing image in my GUI. on my pc it is showing the image but on other pc not.

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=F:\Step1.kxf
$Form2 = GUICreate("My First GUI", 408, 207, 212, 214)
$Pic1 = GUICtrlCreatePic("F:\DreamyWorld.jpg", 0, 0, 404, 204)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

do i need to install autoit on other computers if i want to show my image in GUI on other computer?

Link to comment
Share on other sites

hi friends, i created the following GUI to learn about GUI but on another computer it is not showing image in my GUI. on my pc it is showing the image but on other pc not.

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=F:\Step1.kxf
$Form2 = GUICreate("My First GUI", 408, 207, 212, 214)
$Pic1 = GUICtrlCreatePic("F:\DreamyWorld.jpg", 0, 0, 404, 204)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

do i need to install autoit on other computers if i want to show my image in GUI on other computer?

You have picture in F:\DreamyWorld.jpg?

When the words fail... music speaks.

Link to comment
Share on other sites

try this....

#include <GUIConstants.au3>

Dim $Pic = "F:\DreamyWorld.jpg"

#Region ### START Koda GUI section ### Form=F:\Step1.kxf
$Form2 = GUICreate("My First GUI", 408, 207, 212, 214)
If Not FileExists($Pic) Then MsgBox(0x0, "ERROR", "The picture file could not be found   ", 5)
$Pic1 = GUICtrlCreatePic($Pic, 0, 0, 404, 204)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

8)

NEWHeader1.png

Link to comment
Share on other sites

OK... So we fixed one problem, now there is a new problem...

I can help.. one second

8)

#include <GUIConstantsEx.au3>

$Logo_jpg = @TempDir & "\Logo-au3.jpg"
FileInstall("F:\DreamyWorld.jpg", $Logo_jpg)

#Region ### START Koda GUI section ### Form=F:\Step1.kxf
$Form2 = GUICreate("My First GUI", 408, 207, 212, 214)
$Pic1 = GUICtrlCreatePic($Logo_jpg, 0, 0, 404, 204)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

8)

NEWHeader1.png

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>

$Logo_jpg = @TempDir & "\Logo-au3.jpg"
FileInstall("F:\DreamyWorld.jpg", $Logo_jpg)

#Region ### START Koda GUI section ### Form=F:\Step1.kxf
$Form2 = GUICreate("My First GUI", 408, 207, 212, 214)
$Pic1 = GUICtrlCreatePic($Logo_jpg, 0, 0, 404, 204)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

8)

it's working but why should i FileInstall() the image?

is it necessary everytime using images in GUI?

Link to comment
Share on other sites

Yes, it is a part of the program and has to be "included" because your friend nor anyone else has that same picture in the same exact location as you do.

can i include the images in exe and always use them without installing on user's computer?

Edited by FredrikIdestam
Link to comment
Share on other sites

The way I should you IS how you "include" them. That is the best way AFAIK. Remember that the pic can be erased on autoit exit too.

... I can say that there might be a way to change the pic to data and then "include" it as a file. you will have to look for that UDF in the Example Scripts area.

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

thanks. can u give me a example of using your UDF with my code which i have posted in this thread. i tried your UDF but it was complex for me.

#AutoIt3Wrapper_useupx=n
#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, DreamyWorld.jpg, rcdata, JPG_1, 0
#AutoIt3Wrapper_run_after=upx.exe --best --compress-resources=0 "%out%"

#include <GUIConstants.au3>
#include "resources.au3"

$Form2 = GUICreate("My First GUI", 408, 207, 212, 214)
$Pic1 = GUICtrlCreatePic("", 0, 0, 404, 204)
_ResourceSetImageToCtrl($pic1, "JPG_1")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
Link to comment
Share on other sites

#AutoIt3Wrapper_useupx=n
#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, DreamyWorld.jpg, rcdata, JPG_1, 0
#AutoIt3Wrapper_run_after=upx.exe --best --compress-resources=0 "%out%"

#include <GUIConstants.au3>
#include "resources.au3"

$Form2 = GUICreate("My First GUI", 408, 207, 212, 214)
$Pic1 = GUICtrlCreatePic("", 0, 0, 404, 204)
_ResourceSetImageToCtrl($pic1, "JPG_1")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
do i need to place my images in the same directory where the au3 is?

any extra tools needed for this or it will work fine after compiling as normal au3 files?

thanks for the information and help.

Link to comment
Share on other sites

do i need to place my images in the same directory where the au3 is?

Yes. but only at COMPILE time. At runtime you need only output EXE file.

do i need to place my images in the same directory where the au3 is?

any extra tools needed for this or it will work fine after compiling as normal au3 files?

thanks for the information and help.

All is described in my UDF post - just read it!

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