Jump to content
Sign in to follow this  
sjorrel

Problem Displaying Images

Recommended Posts

I'm creating a GUI that will contain a list of files (jpegs) on one side and a control on the other to show them as they are clicked on.

I'm creating the picture control with:

$photo = GuiCtrlCreatePic("c:\pathtopicture\picture.jpg", 260, 60, 420, 350)

and trying to update it with

GUICtrlSetImage( $photo, "c:\pathtopicture\newpicture.jpg")

But there two problems.

1. The pictures displayed are too big for the control, so only the top left corner is displayed. Strangely, if I move the GUI window off the visible screen area, and then move it back, the picture is resized to display in full.

2. I can't get the pic control to update.

How can I fix these problems?

Thanks!

Share this post


Link to post
Share on other sites

I'm creating a GUI that will contain a list of files (jpegs) on one side and a control on the other to show them as they are clicked on.

I'm creating the picture control with:

$photo = GuiCtrlCreatePic("c:\pathtopicture\picture.jpg", 260, 60, 420, 350)

and trying to update it with

GUICtrlSetImage( $photo, "c:\pathtopicture\newpicture.jpg")

But there two problems.

1. The pictures displayed are too big for the control, so only the top left corner is displayed. Strangely, if I move the GUI window off the visible screen area, and then move it back, the picture is resized to display in full.

2. I can't get the pic control to update.

How can I fix these problems?

Thanks!

<{POST_SNAPBACK}>

if you would post your script, i could help you...

Share this post


Link to post
Share on other sites

#include <GuiConstants.au3>
dim $pathToPhotos = ""
If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GuiCreate("Album Creater", 704, 600,(@DesktopWidth-704)/2, (@DesktopHeight-560)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$photoList = GuiCtrlCreateList("List1", 20, 30, 210, 279)
$Files = GuiCtrlCreateGroup("", 10, 10, 230, 580)
$Pictures = GuiCtrlCreateGroup("", 250, 10, 440, 450)

$chooseFolder = GuiCtrlCreateButton("Choose Folder", 20, 320, 210, 30)

$ftpHostnameLabel = GuiCtrlCreateLabel("Hostname", 20, 360, 210, 20)
$ftpHostnameInput = GuiCtrlCreateInput("Input4", 20, 380, 210, 20)
$ftpUsernameLabel = GuiCtrlCreateLabel("Username", 20, 410, 210, 20)
$ftpUsernameInput = GuiCtrlCreateInput("Input5", 20, 430, 210, 20)
$ftpPasswordLabel = GuiCtrlCreateLabel("Password", 20, 460, 210, 20)
$ftpPasswordInput = GuiCtrlCreateInput("Input6", 20, 480, 210, 20)
$ftpFolderLabel   = GuiCtrlCreateLabel("Folder", 20, 510, 210, 20)
$ftpFolderInput   = GuiCtrlCreateInput("Input6", 20, 530, 210, 20)

$photo = GuiCtrlCreatePic("D:\Desktop\Stuff\My Pics\Denise's Hen Night\DSCN0037.JPG", 260, 60, 420, 350)

$albumNameInput = GuiCtrlCreateInput("Input12", 260, 30, 420, 20)
$photoCaptionInput = GuiCtrlCreateInput("Input13", 260, 420, 420, 20)
$outputFtp = GuiCtrlCreateButton("FTP", 360, 490, 60, 30)
$outputFile = GuiCtrlCreateButton("File", 490, 490, 60, 30)

GuiSetState()

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    case $msg = $chooseFolder
        $pathToPhotos = FileSelectFolder ( "Choose folder containing pictures", "" )
        GUICtrlSetImage( $photo, "D:\Desktop\Stuff\My Pics\Denise's Hen Night\DSCN0056.JPG")
        processPhotos()
    Case Else
    ;;;
    EndSelect
WEnd
Exit

func processPhotos()
    $numberPics = 0
    $searchPics = FileFindFirstFile ( $pathToPhotos & "\*.jpg" )

    If $searchPics = -1 Then
        Return
    EndIf

    while 1
        FileFindNextFile ( $searchPics )
        If @error Then ExitLoop
        $numberPics = $numberPics + 1
    wend
    
    fileclose($searchPics)
EndFunc

The "GUICtrlSetImage" bit when "$msg = $chooseFolder" is just to try and force it without coding more.

EDIT: I've relised now that I can get the image to change. However, it is still not resizing automatically properly. When the image changes, it shows only a part of it, until the GUI is obscured by another window.

Edited by sjorrel

Share this post


Link to post
Share on other sites

Try...

Case $msg = $chooseFolder
   $pathToPhotos = FileSelectFolder ( "Choose folder containing pictures", "" )
   GUICtrlSetImage( $photo, "D:\Desktop\Stuff\My Pics\Denise's Hen _
   Night\DSCN0056.JPG")
   GUICtrlSetState($photo, $GUI_SHOW); <<<< New line, refresh's control
   processPhotos()
Edited by Burrup

qq

Share this post


Link to post
Share on other sites

Try...

Case $msg = $chooseFolder
   $pathToPhotos = FileSelectFolder ( "Choose folder containing pictures", "" )
   GUICtrlSetImage( $photo, "D:\Desktop\Stuff\My Pics\Denise's Hen _
   Night\DSCN0056.JPG")
   GUICtrlSetState($photo, $GUI_SHOW); <<<< New line, refresh's control
   processPhotos()

<{POST_SNAPBACK}>

Did the trick! thankyou very much.

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...