Jump to content

$GUI_EVENT_DROPPED in Edit control not detected?


monter
 Share

Recommended Posts

Hello, here is my problem:

#include <Array.au3>
#include <GUIConstants.au3>
#Include <GuiList.au3>

$gui = GUICreate("Drop files in my controls", 300, 410, -1, -1, -1, $WS_EX_ACCEPTFILES)
$input = GUICtrlCreateInput("", 10, 40, 280, 100)
GUICtrlSetState(-1, $GUI_ACCEPTFILES)
$list = GUICtrlCreateList("", 10, 170, 280, 110)
GUICtrlSetState(-1, $GUI_ACCEPTFILES)
$edit = GUICtrlCreateEdit("", 10, 300, 280, 100, $WS_VSCROLL)
GUICtrlSetState(-1, $GUI_ACCEPTFILES)
GUICtrlCreateLabel("Input:      ($GUI_EVENT_DROPPED works)", 10, 23, -1, 13)
GUICtrlCreateLabel("List:      ($GUI_EVENT_DROPPED works)", 10, 153, -1, 13)
GUICtrlCreateLabel("Edit:      ($GUI_EVENT_DROPPED doesn't work)", 10, 283, -1, 13)

GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_EVENT_DROPPED
            MsgBox(0, "", "You dropped files..." & @CRLF & @GUI_DRAGFILE)
            _GUICtrlListAddItem ($list, @GUI_DRAGFILE)
        Case Else
    EndSelect
WEnd

$GUI_EVENT_DROPPED isn't detected in Edit control? Is this is right?

monter.FM [font="Tahoma;"]Full programs:[/font][font="'Microsoft Sans Serif';"] LogOnOff - keeps alive user session, after set time it performs logoff (instead of locking [acronym="Personal Computer"]PC[/acronym], useful in some corporations working with [acronym="Active Directory"]AD[/acronym]).[/font] ČharCönvěr - character set converter. [font="'Microsoft Sans Serif';"]CDTray - automated opening/closing the [acronym="Compact Disc"]CD[/acronym] tray.[/font] [font="'Microsoft Sans Serif';"]Example scripts: [/font][font="'Microsoft Sans Serif';"]RecentFolders - managing recently used folder list with combobox.[/font] [font="'Microsoft Sans Serif';"]AutoUpdater - periodic auto-checking, auto-updating and auto-relaunching newest script version.[/font] Changed host from monter.homeip.net to monter.homenet.org - replace address in my scripts to get back them to work.

Link to comment
Share on other sites

$GUI_EVENT_DROPPED isn't detected in Edit control? Is this is right?

I noticed that when droppig a file $MSG allways = -13 but it equals -8 when you drop a file in the Edit.

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
Share on other sites

plastix:

It's not that, here is the On Event Mode version:

#include <Array.au3>
#include <GUIConstants.au3>
#Include <GuiList.au3>
Opt("GUIOnEventMode", 1)

$gui = GUICreate("Drop files in my controls", 300, 410, -1, -1, -1, $WS_EX_ACCEPTFILES)
$input = GUICtrlCreateInput("", 10, 40, 280, 100)
GUICtrlSetState(-1, $GUI_ACCEPTFILES)
$list = GUICtrlCreateList("", 10, 170, 280, 110)
GUICtrlSetState(-1, $GUI_ACCEPTFILES)
$edit = GUICtrlCreateEdit("", 10, 300, 280, 100, $WS_VSCROLL)
GUICtrlSetState(-1, $GUI_ACCEPTFILES)
GUICtrlCreateLabel("Input:      ($GUI_EVENT_DROPPED works)", 10, 23, -1, 13)
GUICtrlCreateLabel("List:      ($GUI_EVENT_DROPPED works)", 10, 153, -1, 13)
GUICtrlCreateLabel("Edit:      ($GUI_EVENT_DROPPED doesn't work)", 10, 283, -1, 13)

GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
GUISetOnEvent($GUI_EVENT_DROPPED, "Dropped")

GUISetState(@SW_SHOW)

While 1
    Sleep(500)
Wend

Func Dropped()
        MsgBox(0, "", "You dropped files..." & @CRLF & @GUI_DRAGFILE)
        _GUICtrlListAddItem ($list, @GUI_DRAGFILE)
EndFunc 

Func Close()
    Exit
EndFunc

and also Edit control fails in detecting $GUI_EVENT_DROPPED.

rbhkamal:

-8 means $GUI_EVENT_PRIMARYUP, it works only at first primary up-ing (I mean after launching the script), next dropping of files is ignored...

Edited by monter

monter.FM [font="Tahoma;"]Full programs:[/font][font="'Microsoft Sans Serif';"] LogOnOff - keeps alive user session, after set time it performs logoff (instead of locking [acronym="Personal Computer"]PC[/acronym], useful in some corporations working with [acronym="Active Directory"]AD[/acronym]).[/font] ČharCönvěr - character set converter. [font="'Microsoft Sans Serif';"]CDTray - automated opening/closing the [acronym="Compact Disc"]CD[/acronym] tray.[/font] [font="'Microsoft Sans Serif';"]Example scripts: [/font][font="'Microsoft Sans Serif';"]RecentFolders - managing recently used folder list with combobox.[/font] [font="'Microsoft Sans Serif';"]AutoUpdater - periodic auto-checking, auto-updating and auto-relaunching newest script version.[/font] Changed host from monter.homeip.net to monter.homenet.org - replace address in my scripts to get back them to work.

Link to comment
Share on other sites

rbhkamal:

-8 means $GUI_EVENT_PRIMARYUP, it works only at first primary up-ing (I mean after launching the script), next dropping of files is ignored...

Maybe you should open a bug. :D

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
Share on other sites

or you could do something like:

#include <GuiConstants.au3>

Global Const $WM_COMMAND = 0x0111
Global Const $EN_CHANGE = 0x300
Global Const $DebugIt = 1

#include <Array.au3>
#include <GUIConstants.au3>
#Include <GuiList.au3>

$gui = GUICreate("Drop files in my controls", 300, 410, -1, -1, -1, $WS_EX_ACCEPTFILES)
$input = GUICtrlCreateInput("", 10, 40, 280, 100)
GUICtrlSetState(-1, $GUI_ACCEPTFILES)
$list = GUICtrlCreateList("", 10, 170, 280, 110)
GUICtrlSetState(-1, $GUI_ACCEPTFILES)
$edit = GUICtrlCreateEdit("", 10, 300, 280, 100, $WS_VSCROLL)
GUICtrlSetState(-1, $GUI_ACCEPTFILES)
GUICtrlCreateLabel("Input:    ($GUI_EVENT_DROPPED works)", 10, 23, -1, 13)
GUICtrlCreateLabel("List:     ($GUI_EVENT_DROPPED works)", 10, 153, -1, 13)
GUICtrlCreateLabel("Edit:     ($GUI_EVENT_DROPPED doesn't work)", 10, 283, -1, 13)

GUISetState()
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_EVENT_DROPPED
            MsgBox(0, "", "You dropped files..." & @CRLF & @GUI_DragFile)
            _GUICtrlListAddItem($list, @GUI_DragFile)
        Case Else
    EndSelect
WEnd

Func _Input_Changed()
;----------------------------------------------------------------------------------------------
    If $DebugIt Then ConsoleWrite(_DebugHeader("Input Changed:" & GUICtrlRead($input)))
;----------------------------------------------------------------------------------------------
EndFunc  ;==>_Input_Changed

Func _Edit_Changed()
    If StringLen(StringStripWS(StringReplace(GUICtrlRead($edit), @CRLF, @LF), 2)) Then
    ;----------------------------------------------------------------------------------------------
        If $DebugIt Then
            ConsoleWrite(_DebugHeader("Edit Changed:" & StringStripWS(StringReplace(GUICtrlRead($edit), @CRLF, @LF), 2)))
            MsgBox(0, "", "You dropped files..." & @CRLF & StringStripWS(StringReplace(GUICtrlRead($edit), @CRLF, @LF), 2))
        EndIf
    ;----------------------------------------------------------------------------------------------
        _GUICtrlListAddItem($list, StringStripWS(StringReplace(GUICtrlRead($edit), @CRLF, @LF), 2))
    EndIf
EndFunc  ;==>_Edit_Changed

Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    Local $nNotifyCode = _HiWord($wParam)
    Local $nID = _LoWord($wParam)
    Local $hCtrl = $lParam
    
    Switch $nID
        Case $input
            Switch $nNotifyCode
                Case $EN_CHANGE
                    _Input_Changed()
            EndSwitch
        Case $edit
            Switch $nNotifyCode
                Case $EN_CHANGE
                    _Edit_Changed()
            EndSwitch
    EndSwitch
; Proceed the default Autoit3 internal message commands.
; You also can complete let the line out.
; !!! But only 'Return' (without any value) will not proceed
; the default Autoit3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc  ;==>MY_WM_COMMAND

Func _DebugHeader($s_text)
    Return _
            "!===========================================================" & @LF & _
            "+===========================================================" & @LF & _
            "-->" & $s_text & @LF & _
            "+===========================================================" & @LF
EndFunc  ;==>_DebugHeader

Func _HiWord($x)
    Return BitShift($x, 16)
EndFunc  ;==>_HiWord

Func _LoWord($x)
    Return BitAND($x, 0xFFFF)
EndFunc  ;==>_LoWord

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Your script get some error this one should do what you try to implement

#include <Array.au3>
#include <GUIConstants.au3>
#Include <GuiList.au3>

$gui = GUICreate("Drop files in my controls", 300, 410, -1, -1, -1, $WS_EX_ACCEPTFILES)
$input = GUICtrlCreateInput("", 10, 40, 280, 100)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
$list = GUICtrlCreateList("", 10, 170, 280, 110)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
$edit = GUICtrlCreateEdit("", 10, 300, 280, 100, $WS_VSCROLL)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlCreateLabel("Input:      ($GUI_EVENT_DROPPED works)", 10, 23, -1, 13)
GUICtrlCreateLabel("List:      ($GUI_EVENT_DROPPED works)", 10, 153, -1, 13)
GUICtrlCreateLabel("Edit:      ($GUI_EVENT_DROPPED doesn't work)", 10, 283, -1, 13)

GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_EVENT_DROPPED
            MsgBox(0, "", "You dropped files..." & @CRLF & @GUI_DRAGFILE)
            _GUICtrlListAddItem (@GUI_DROPID, @GUI_DRAGFILE)
        Case Else
    EndSelect
WEnd
Edited by Jos
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...