Jump to content

learn to use GUICtrlCreatePic


Recommended Posts

Hello to all,

have some proble with this script, put some .jpg in script folder and run.

It list all .jpg images, allow to select one of them, and when user change selection,

GUICtrlCreatePic image on GUI. But don't refresh/load right image:

#include <WindowsConstants.au3>
#Include <Constants.au3>
#include <GUIComboBox.au3>
#include <GuiConstantsEx.au3>

;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////  
;//     set variabili
;////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
dim $sText="", $sText_old = ""
;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////  
;//     GUI
;////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
#Region ### START Koda GUI section ### Form=C:\Program Files\Koda 1.7.01\Forms\QuickFTP\FNTConvert.kxf
$hGUI = GUICreate("Sfogliabili", 510, 510, 0, 0, -1, $WS_EX_ACCEPTFILES)

$hCombo = GUICtrlCreateCombo("", 20, 280, 318, 150, BitOR($CBS_SIMPLE,$CBS_AUTOHSCROLL,$CBS_DISABLENOSCROLL,$WS_VSCROLL))

;popolate combo
_GUICtrlComboBox_BeginUpdate($hCombo)
_GUICtrlComboBox_AddDir($hCombo, "*.jpg", $DDL_DIRECTORY, False)
_GUICtrlComboBox_EndUpdate($hCombo)

;select first element
_GUICtrlComboBox_SetCurSel($hCombo, 1)
$my_selection = _GUICtrlComboBox_GetCurSel($hCombo)
_GUICtrlComboBox_GetLBText($hCombo, 1, $sText)
        
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###



        
        

While 1
    $Msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        $question = MsgBox(4, "...", "quit ?")
        if $question = 6 then Exit ;if yes -> close program

    EndSelect
        


        ;if user change selection
        $my_selection = _GUICtrlComboBox_GetCurSel($hCombo)
        _GUICtrlComboBox_GetLBText($hCombo, $my_selection, $sText)

        if $sText_old <> $sText then 
            $sText_old = $sText

            ToolTip($sText,0,0)
            GUICtrlCreatePic($sText, 340, 260, 160, 237)

        EndIf

        
    Sleep(10)
WEnd

Where is the error ?

Thank you for any info,

m.

Link to comment
Share on other sites

#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GUIComboBox.au3>
#include <GuiConstantsEx.au3>

;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
;//     set variabili
;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Dim $sText = "", $sText_old = ""
;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
;//     GUI
;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#Region ### START Koda GUI section ### Form=C:\Program Files\Koda 1.7.01\Forms\QuickFTP\FNTConvert.kxf
$hGUI = GUICreate("Sfogliabili", 510, 510, 0, 0, -1, $WS_EX_ACCEPTFILES)

$hCombo = GUICtrlCreateCombo("", 20, 280, 318, 150, BitOR($CBS_SIMPLE, $CBS_AUTOHSCROLL, $CBS_DISABLENOSCROLL, $WS_VSCROLL))
$pic = GUICtrlCreatePic("", 340, 260, 160, 237)

;popolate combo
_GUICtrlComboBox_BeginUpdate($hCombo)
_GUICtrlComboBox_AddDir($hCombo, "*.jpg", $DDL_DIRECTORY, False)
_GUICtrlComboBox_EndUpdate($hCombo)

;select first element
_GUICtrlComboBox_SetCurSel($hCombo, 0)
_GUICtrlComboBox_GetLBText($hCombo, 0, $sText)
GUICtrlSetImage($pic, $sText)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $Msg = GUIGetMsg()
    Select
        Case $Msg = $GUI_EVENT_CLOSE
            $question = MsgBox(4, "...", "quit ?")
            If $question = 6 Then Exit ;if yes -> close program

        Case $Msg = $hCombo
            ;if user change selection
            $my_selection = _GUICtrlComboBox_GetCurSel($hCombo)
            _GUICtrlComboBox_GetLBText($hCombo, $my_selection, $sText)

            If $sText_old <> $sText Then
                $sText_old = $sText

                ToolTip($sText, 0, 0)
                GUICtrlSetImage($pic, $sText)
            EndIf
    EndSelect
WEnd

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