Jump to content

Double click issue


Recommended Posts

Hello,

I got a problem. I have created a programm for image view. It works fine but i got an issue.

I got double click register msg in the script. When i double click an image from the list it displays it at the input but it doesnt shows the image. When i select an image from the Browser button it shows the image. What am i doing wrong.

Here is the script.

#include <ButtonConstants.au3>
#include <TabConstants.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <File.au3>
#include "RecFileListToArray.au3"
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <GuiScrollBars.au3>
#include <ScrollBarConstants.au3>
$Form1 = GUICreate("Form1", 784, 591, 245, 90)
$menu = GUICtrlCreateMenu("&File")
$menu1 = GUICtrlCreateMenu("?")
$menu1item2 =GUICtrlCreateMenuItem("Info", $menu1)
$Group1 = GUICtrlCreateGroup("ScreenShots", 10, 30, 210, 450)
$Group2 = GUICtrlCreateGroup("Image", 230, 30, 540, 450)
$Button1 = GUICtrlCreateButton("Browser...", 685, 450, 75, 25)
$Input1 = GUICtrlCreateInput("", 240, 450, 265, 21)
$List1 = GUICtrlCreateList("", 20, 50, 190, 430)
$Image=GUICtrlCreatePic(GUICtrlRead($Input1),240,50,520,384)
GUISetState()
; Look for doubleclicks on the list
GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")

$sPath = StringReplace(@DesktopDir, "\AutoIt3.exe", "\")
$aFiles = _FileListToArray($sPath, "*.*", 1)
  For $i = 1 To $aFiles[0]
   GUICtrlSetData($List1, $aFiles[$i])
  Next

While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
 Case $Button1
   $file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)")
   GUICtrlSetData($Input1, $file)
   _setImage($Image,$file)
EndSwitch
WEnd


Func _WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    Local $nCode = BitShift($wParam, 16)        ; HiWord
    Local $nIDFrom = BitAND($wParam, 0xFFFF)    ; LoWord
    Switch $nIDFrom
        ; If from the list
        Case $List1
            Switch $nCode
                ; If a double click
                Case $LBN_DBLCLK
                    ; Read selected item
                    $sListItem = GUICtrlRead($List1)
                    ; Display selected item
                    GUICtrlSetData($Input1, $sListItem)
     _setImage($Image,$sListItem)
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Func _setImage($Control,$Image)
If GUICtrlSetImage($Control,$Image)=0 Then Return @error
Return 0
EndFunc

I feel nothing.It feels great.

Link to comment
Share on other sites

Change this line in your _setimage function.

If GUICtrlSetImage($Control, $sPath & "" & $sImage) = 0 Then Return @error ; you need the path to the filename as well as the file name itself.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

; you need the path to the filename as well as the file name itself.

It works but it cancels my Browser button... What i did is made 2 $sImage one with the old path and one with yours.

Is there an other way??

I feel nothing.It feels great.

Link to comment
Share on other sites

Then send the information to the function with the path in the double click routine, instead of having it set INSIDE the function, you send the correct information to it from the double click routine in the same format as the browse button would send it.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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