Sign in to follow this  
Followers 0
Unc3nZureD

Error with GUI_DRAGFILE

8 posts in this topic

#1 ·  Posted (edited)

Hi guys, as the title says somewhy I can't use the @GUI_DRAGFILE. Here my code is:

$Form2 = GUICreate(" FTProject [UPLOAD]", 211, 122, 403, 231, -1, BitOR($WS_EX_ACCEPTFILES,$WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
GUICtrlSetState (-1, $GUI_DROPACCEPTED)
$Label1 = GUICtrlCreateLabel("Drag a file here to start uploading!", 8, 8, 199, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Progress1 = GUICtrlCreateProgress(6, 96, 198, 17)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
_FTP_Close($Open)
Exit
EndSwitch

msgbox(0,"",@GUI_DRAGFILE)
WEnd

Unknown macro.

What did I fail?

----------------

Edit:

Theoritacally I found the problem, but not sure yet. GUISetonEvent?

Edited by Unc3nZureD

Share this post


Link to post
Share on other sites



Unless there is a file dropped onto the GUI, that macro doesn't work, there's a similar issue with using @GUI_CtrlID, if no control has been actioned, you get an error when using it. It's working as intended because you're trying to access something that doesn't apply.


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

Share this post


Link to post
Share on other sites

GUIDelete($Form1)
$Form2 = GUICreate(" FTProject [UPLOAD]", 211, 122, 403, 231, -1, BitOR($WS_EX_ACCEPTFILES,$WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
GUICtrlSetState($Form2, $GUI_DROPACCEPTED)
$Label1 = GUICtrlCreateLabel("Drag a file here to start uploading!", 8, 8, 199, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Progress1 = GUICtrlCreateProgress(6, 96, 198, 17)
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_DROPPED, _UploadFile(), $Form2)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
_FTP_Close($Open)
Exit
EndSwitch
WEnd
EndFunc

Func _UploadFile()
msgbox(0,"", @GUI_DRAGFILE)

I thought it'll be working. But it instantly gets activated. Still can't get it working :S

Share this post


Link to post
Share on other sites

One thing I see is that you're mixing OnEvent mode and MessageLoop mode, that won't work.

If you could post a script that reproduces the error, that someone can run, it will make it easier to see exactly what it is you're attempting and why it's not working.


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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

#include <FTPEx.au3>
#include <String.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ProgressConstants.au3>

$Form2 = GUICreate(" FTProject [UPLOAD]", 211, 122, 403, 231, -1, BitOR($WS_EX_ACCEPTFILES,$WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
GUICtrlSetState (-1, $GUI_DROPACCEPTED)
$Label1 = GUICtrlCreateLabel("Drag a file here to start uploading!", 8, 8, 199, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Progress1 = GUICtrlCreateProgress(6, 96, 198, 17)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd

So that thing that it should do is:

If somebody drags a file into the Form, it will upload the file to a given FTP.

Edited by Unc3nZureD

Share this post


Link to post
Share on other sites

Try this demo, run it from SciTE and it will display the name of the file dropped on the label in the lower panel.

#include <FTPEx.au3>
#include <String.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ProgressConstants.au3>
$Form2 = GUICreate(" FTProject [UPLOAD]", 211, 122, 403, 231, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
$Label1 = GUICtrlCreateLabel("Drag a file here to start uploading!", 8, 8, 199, 40)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xffffff) ; set the background color so you can see where the label is.
$Progress1 = GUICtrlCreateProgress(6, 96, 198, 17)
GUISetState(@SW_SHOW)
While 1
     $nMsg = GUIGetMsg()
     Switch $nMsg
          Case $GUI_EVENT_CLOSE
               Exit
          Case $GUI_EVENT_DROPPED ; actioned when a file is dropped on the label, because that is the only control set w/$GUI_DROPACCEPTED
               ConsoleWrite(@GUI_DragFile & @CRLF)
          Case $Label1 ; click the label and it will display what file was dropped on it.
               ConsoleWrite(@GUI_DragFile & @CRLF)
     EndSwitch
WEnd

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

Share this post


Link to post
Share on other sites

So as I can see I can't make it with the GUI itself. Okay, I did a little trick :) Used your source and I gave the label bigger area so it's like they dragged to the GUI, but it's handled by the label :)

Thanks!

Share this post


Link to post
Share on other sites

You're welcome.


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

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  
Followers 0