Jump to content

having problems with $WS_EX_ACCEPTFILES


Shark007
 Share

Recommended Posts

The following code is a miniature of my app, and works as expected.

I created the mini app below for testing purposes.

My goal is to add a dropbox for files that i can work with to my working application.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

GUICreate(" My GUI input acceptfile", 320, 180, -1, -1, -1, $WS_EX_ACCEPTFILES)
GUICtrlCreateTab(4, 0, 310, 140)
GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
#Region tab
$tab = GUICtrlCreateTabItem("newtab")
$drop = GUICtrlCreateInput("", 24, 50, 180, 20)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSetBkColor(-1, 0xcccccc)
GUICtrlCreateGroup("", -99, -99, 1, 1)
#EndRegion tab

#Region tab
$tab = GUICtrlCreateTabItem("newtab1")
#EndRegion tab

#Region tab
$tab = GUICtrlCreateTabItem("newtab2")
#EndRegion tab


GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = $drop Then test()
    If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd

Func test()
    MsgBox(4096, "filename", GUICtrlRead($drop))
EndFunc   ;==>test

my application is aprox 6300 lines of code.

I have been trying to troubleshoot this problem for a week already.

The moment I change

GUICreate(" My GUI", 320, 180, -1, -1)

to

GUICreate(" My GUI", 320, 180, -1, -1, -1, $WS_EX_ACCEPTFILES)

I have an obvious problem. Not only can i not make the app accept files by adding the required code, but the moment I open the executable with only this one change posted above, the application no longer opens center screen, but 1 step up as if it had opened once before it, and moved itself up a position.

If anyone could offer suggestions to assist troubleshooting this problem, I'd be very appreciative.

Edited by Shark007
Link to comment
Share on other sites

Try:

If $msg = $GUI_EVENT_DROPPED Then test()

Also, you should close out the creation of tab items with:

GUICtrlCreateTabItem("")

So, this version works:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

GUICreate(" My GUI input acceptfile", 320, 180, -1, -1, -1, $WS_EX_ACCEPTFILES)
GUICtrlCreateTab(4, 0, 310, 140)
GUICtrlSetResizing(-1, $GUI_DOCKAUTO)

$tab = GUICtrlCreateTabItem("newtab")
$drop = GUICtrlCreateInput("", 24, 50, 180, 20)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSetBkColor(-1, 0xcccccc)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$tab = GUICtrlCreateTabItem("newtab1")
$tab = GUICtrlCreateTabItem("newtab2")
GUICtrlCreateTabItem("")
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_DROPPED Then test()
    If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd

Func test()
    MsgBox(4096, "filename", GUICtrlRead($drop))
EndFunc   ;==>test

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Thanks for the advice about closing out the creation of the tab items. I was not aware of that.

What I was looking for with this posting is some advice that would to help me troubleshoot my larger application (over 6300 lines) as to why I am having difficulty in trying to add file dropping to my app.

My app works well as far as I know. I have not had any problems with it until I decided to add

-1, $WS_EX_ACCEPTFILES to GUICreate(" My GUI", 320, 180, -1, -1)

The moment I add that one thing to my application, it does weird things. Most notably, it no longer opens center screen, but top screen and, the ability to drop files is non functional even though I add all the required commands etc.

Edited by Shark007
Link to comment
Share on other sites

See the first item in my earlier post for why drop file wasn't detected. You were watching for the wrong GUI message.

The working demo I posted doesn't do anything strange for me. Does it work correctly in your environment?

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

The script in my 1st post works, as does the modified script you posted. And I thank you for your interest in helping me find a resolution. The problem I am having is that I cannot get to drag n drop to work in another script that is 6300 lines long.

I was hoping a seasonned user would spot an obvious reason why I cannot get it to work.

When I change GUICreate("My GUI", 320, 180, -1, -1)

to GUICreate("My GUI", 320, 180, -1, -1, -1, $WS_EX_ACCEPTFILES)

I immediately begin to have problems in my 6300 line script.

The moment I make that one change to my application, it starts to do weird things. Most notably, it no longer opens center screen, but opens at the top of the screen and the ability to drop files is non functional even though I add all the required commands.

Edited by Shark007
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...