WINDOW_ACCEPTFILES

Started by _PJ_, September 23, 2024, 08:08:21

Previous topic - Next topic

_PJ_

I am sure I remember this used to work in the past - maybe it was with Vanilla BMax?
But it seems now, EVENT_WINDOWACCEPT events do not seem to fire.

setting WINDOW_ACCEPTFILES flag on window creation DOES change the mouse cursor from "invalid" to "drag & drop target", so there definitely seems to be something working in the creation part, but not the events

Toi ensure it wasn't jsut something I was doing/changed in my own project, I tried the example from the BMax axGUI documentation and still no event details for drag&drop

Import MaxGui.Drivers

AppTitle = "CreateWindow() Example"

Global flags:Int

' Comment/uncomment any of the following lines to experiment with the different styles.

flags:| WINDOW_TITLEBAR
flags:| WINDOW_RESIZABLE
flags:| WINDOW_MENU
flags:| WINDOW_STATUS
flags:| WINDOW_CLIENTCOORDS
'FLAGS:| WINDOW_HIDDEN
flags:| WINDOW_ACCEPTFILES
'FLAGS:| WINDOW_TOOL
'FLAGS:| WINDOW_CENTER

Local window:TGadget = CreateWindow( AppTitle, 100, 100, 320, 240, Null, flags )

If (flags & WINDOW_STATUS) Then
SetStatusText( window, "Left aligned~tCenter aligned~tRight aligned" )
EndIf

Repeat
WaitEvent()
Print CurrentEvent.ToString()
Select EventID()
Case EVENT_APPTERMINATE, EVENT_WINDOWCLOSE
End
End Select
Forever




Midimaster

This works on my BlitzMax NG:

SuperStrict

Import MaxGui.Drivers
Local window:TGadget = CreateWindow("My Window",40,40,320,240,Null,WINDOW_TITLEBAR|WINDOW_ACCEPTFILES)

While True
   WaitEvent

   Select EventID()
      Case EVENT_WINDOWCLOSE
         End   
      Case EVENT_WINDOWACCEPT
         Local file:String = String(EventExtra())
         Print file
   End Select
Wend
...On the way to Norway to watch Polar Lights

_PJ_

#2
Thanks Midimaster - I am now one step closer!

It seems to work when I run a compiled (even debug) exe

But when running from within BMax IDE ( using the Compile and Run ) - which I do a lot for testing - it doesn't work...
Will do some more tests with a built executable of my main project!

___ Update -
Nope :(


      Case EVENT_WINDOWACCEPT still doesn't seem to fire --- I'm gonna try and look into it more closely

_PJ_

This is basically the core of my program - every other event seems to be triggered correctly.
Function EventHandler()
WaitEvent

Select (EventID())
Case EVENT_APPSUSPEND
AppSuspendEvent

Case EVENT_APPRESUME
AppResumeEvent

Case EVENT_WINDOWACTIVATE
WindowActivateEvent

Case EVENT_WINDOWMOVE
WindowMoveEvent

Case EVENT_WINDOWACCEPT
Debug("UI","EventHandler","EventID","EVENT_WINDOWACCEPT","Called")
WindowAcceptEvent

Case EVENT_WINDOWCLOSE
Debug("UI","EventHandler","EventID","EVENT_WINDOWCLOSE","Called")
WindowCloseEvent

Case EVENT_MENUACTION
'Debug("UI","EventHandler","EventID","EVENT_MENUACTION","Called")
MenuEvent

Case EVENT_GADGETACTION
GadgetActionEvent

Case EVENT_GADGETSELECT
Debug("UI","EventHandler","EventID","EVENT_GADGETSELECT","Called")
GadgetSelectEvent

Case EVENT_GADGETLOSTFOCUS
'Debug("UI","EventHandler","EventID","EVENT_GADGETLOSTFOCUS","Called")
GadgetLostFocusEvent

Case EVENT_MOUSEDOWN
MouseDownEvent

Case EVENT_MOUSEUP
MouseUpEvent

Case EVENT_MOUSEENTER
MouseEnterEvent

Case EVENT_MOUSELEAVE
MouseLeaveEvent

Case EVENT_MOUSEMOVE
MouseMoveEvent

Case EVENT_MOUSEWHEEL
MouseWheelEvent

Case EVENT_KEYUP, EVENT_KEYDOWN, EVENT_KEYCHAR
'Debug("UI","EventHandler","EventID",EventID.ToString(),"Called")
GenericKeyEvent

Case EVENT_GADGETPAINT
GadgetPaintEvent

Default
Debug("UI","EventHandler","TEvent",CurrentEvent.ToString()+" (Unhandled)","Called")
End Select

PerformMainWindowUpdate

End Function

Midimaster

#4
Do you have the same problems with exactly my code example? I tested it directly in the MaxIDE with F5 and had no problems. Even there was no need to click into the EXE first (...that it becomes the active window).

I press F5, then go to an Explorer window and drag one file into the EXE window.

Perhaps it it a version problem of your BlitzMax NG? 

I use:
  • 64bit
  • MaxIde 1.56
  • BCC 0.136
  • BMK 3.51
  • GCC 8.1.0
...On the way to Norway to watch Polar Lights

_PJ_

#5
Really appreciate your responses, MidiMaster.

To clarify --- When I run your test code [[ with a tiny change to NOTIFY the result otherwise it would not be available in non-console app/debug mode]]
SuperStrict

Import MaxGui.Drivers
Local window:TGadget = CreateWindow("My Window",40,40,320,240,Null,WINDOW_TITLEBAR|WINDOW_ACCEPTFILES)

While True
   WaitEvent

   Select EventID()
      Case EVENT_WINDOWCLOSE
         End   
      Case EVENT_WINDOWACCEPT
         Local file:String = String(EventExtra())
         Notify(file)
   End Select
Wend
ONLY works when running from an executable,NOT when using F5 or the "Build & Run" option in BMax IDE
This seems to be true of every test --- it's very strange ---

I did a few more tests with small examples, ( checking to see if panels, windowmenu or statusbar etc. were making a difference), and every test shows that the event triggers just fine [when run from executable] - so it's absolutely something to do with my code, because it NEVER works in my project - I just can't figure out what is stopping it!

I am wondering if Windows smartscreen or something might be doing some kind of "protective measures"....

As for MaxNG version, I tend to only update when I run into an issue and that issue is specifically addressed in the repo

When I click the "about" menu for BMax IDE it shows the following:::

MAXIDE 1.56 [ng] (x86) --- {{THis seems weird, should it be AMD64 or is it just referring to windows platform generally?}}
bcc[ng]release 0.144
bmk 3.5 mt-win32-64 / gcc 120200 (cpux16)

FASM version: Unavailable
GCC Version: 12.2.0
G++ Version: 12.2.0
UPX Version: n/a




William

#6
your sure you had not downloaded the x86/64 or just x86 version of the blitzmax windows release? try to be sure and download the x64 release if you can and try it. i can try on my machine. windows 11 latest updates. may be a waste of time on your end but i may try your sample code and try it.
im still interested in game app development even if its oldschool. i have ideas i want to try myself in this project if i can ever accomplish it.

William

#7
hi PJ, i'm on windows. seems to open a window and i can drag and drop with the snippet code above and it notifies me. with build & run win32-x64 version 0.136. i'd download release 0.144 but i'm on a budget metered connection.
im still interested in game app development even if its oldschool. i have ideas i want to try myself in this project if i can ever accomplish it.

_PJ_

Thanks for the info, William.

The plot thickens....

I had someone test the latest executable release build of the app ( Windows 10 64bit) and they were unable to drag/drop - so it definitely seems to be something with my installation of BMax-NG

If it wasn't for Midimaster making me look at the "About" details for MaxIDE, I wouldn't have noticed that it was "x86" - I checked the BMax{src{maxide{ folder and strangely enougfh there was a duplicate (but later-dated) maxide folder within. I ccopied the contents of THAT folder into the first one and compiled the maxide.bmx for 64-bit and now at least, the BMax IDE shows "x64"

Using this new IDE, I built all modules (with x64 architecture selected) - and the build seemed successful

However, the issue still remains regarding WINDOW_ACCEPTFILES

It is so strange...

 

Midimaster

Do you perhaps do something like PollEvent() anywhere in your code? Or a second WaitEvent()? Perhaps the event gets swallowed by any of your functions.
...On the way to Norway to watch Polar Lights

_PJ_

In Post #3  I showed the "main loop" part of my code, there is a single WaitEvent() call

I also wondered if maybe some other event (i.e. windowe activation / MouseEnter etc. ) might be happening instead and I even tried moving the priority of the WINDOW_ACCEPT in the select statement.

I will need to see if I can capture more events more frequently (i.e. using poll event ? ) and see how that goes...

Even so, that would't explain why the behaviour is different on the "test examples" - i.e. running from within MaxIDE doesn't work  (( though admittedly, this is a minor inconvenience it's just curious as to why the unexpected behaviour))

______________


I have downloaded the latest BlitzMax for windows from github, copied over all the files to my existing install, and am now running ReBuild All Modules...

_PJ_




Reinstalling NG and rebuilding all the modules didn't make any difference.

Is it possible that Windows smartscreen or Defender "Exploit Protection" could be affecting something during the compile process?
This is so weird!


Dan

Windows may prevent processes from different user level to drag and drop ...

Yesterday, while testing something out, i changed a setting on my old version of paint shop pro 
and suddenly, drag and drop started working ...

(apparently the compatibility settings prevents the drag and drop as well)
65536 GOTO Back2Basic

_PJ_

Interesting. Thanks for the input, Dan

BMax IDE is run as Administrator, and because my program accessess the regitry, the compilerd exe needs to be run with elevated privilaege too, or it will crash...
but it does seem like the "authorisation/permissions" are on the right path to finding the root of this issue.

--- I'm going to keep looking and investigating what I can... thanks for the help, though- it makes such a difference to know what works or not for others!


_PJ_

I disabled SmartScreen and set the compiled executable to be excluded by Windows Defender, but still no dice.
I have specifically run as administrator and even opened a new explorer instance with elevated privilege just to be sure -
I am wondering if it might just be something in the "Exploit Protection" options, but the descriptions for these are too technical for me to really know and I haven't changed anything from default since installing windows, so shouldnt be an issue for me if its not for most other users...