Jump to content
Sign in to follow this  
myspacee

learn to use GUICtrlCreatePic

Recommended Posts

myspacee

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.

Share this post


Link to post
Share on other sites
Zedna

#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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.