Recognizing a mouse Dragged file onto a blitzmax

BlitzMax Forums/BlitzMax Beginners Area/Recognizing a mouse Dragged file onto a blitzmax

Hardcoal(Posted 2015) [#1]
Hi..

Is there a way to get and recognize a mouse dragged File From a windows Folder into a blitzmax graphic window?

but without using maxgui commands..

off course i need only the URL of the file..

tnx


Hardcoal(Posted 2015) [#2]
no help :(


degac(Posted 2015) [#3]
I'm quite sure the window created via Graphics doesnt' accept OS events like the ones created via MaxGUI.


Hardcoal(Posted 2015) [#4]
Yea your right degac// but i thought if i can capture the path of a dragged file some how from the system. all i need to do is recognize when the mouse is above the graphic windows and then drop it into the window.

all i need is a way to read from system when a file is being dragged..

any clue how to read a windows event from blitzmax?

tnx


grable(Posted 2015) [#5]
Drag & Drop is quite involved, especially on windows.

But if you just want a list of dropped files, overriding the WindowProc with SetWindowLong and
checking for the WM_DROPFILES message will do.
Though you should read up on window procs and all that or you will mess things up ;)

EDIT: I forgot, you allso need to call DragAcceptFiles before doing any of this.


Hardcoal(Posted 2015) [#6]
I saw that command DragAcceptFiles()
but how do i get the hwnd address of blitzmax window
and what is Faccept means?

any chance for a little example?

tnx


Hardcoal(Posted 2015) [#7]
ok i think i found how to get hwnd by using hWnd=GetActiveWindow()


no how do i use the WM_DROPFILES ?
and what is Faccept means ?

i found this function SetWindowLongA() but it askes for an index and newlong
which i dont know what they are..


grable(Posted 2015) [#8]
GetActiveWindow() is not the right function to use, as you cant guarantee that your window is the active one when its called.

After some digging i found an old sample and fixed it up a bit, should have all you need :)



Hardcoal(Posted 2015) [#9]
Great Grable!

I'm gonna check that later.

I'm dearly in depth to your effort so far.

H.c


grable(Posted 2015) [#10]
No worries, i have plenty of samples.. Too many perhaps ;) hehe


Hardcoal(Posted 2015) [#11]
Great, it works on blitzmax windows. but when I turn on Xors3d window
It doesnt..
Im gonna try to find out why.. hope I can solve it my self.

Few mins later..

Ok.. iv switch the function to GetActiveWindow and it works.
Since im running this function immediately after creating the xors3D win
it always capture the right window.

Just one thing I dont understand yet..
How does this function DragAcceptFiles runs when its out of the loop?
and how can I read the directory Value?

I know i can simply put the DragAcceptFiles Call function inside the loop..
but is it the right way to do that?

Cheers


grable(Posted 2015) [#12]
DragAcceptFiles only signals to windows that your window can accept dropped files, so you only need to call this once.
The real meat happens in the window proc under WM_DROPFILES, using DragQueryFile to extract the strings from the message.


Hardcoal(Posted 2015) [#13]
Great. Thats what I was missing.


Hardcoal(Posted 2015) [#14]
Im apologize garble, but i expected that this DragQueryFile will return String.

But I dont know what to define in its values and how to get a string back..


20 mins later..

Ok Ive managed to come up with a solution :)


Hardcoal(Posted 2015) [#15]
Im trying hard to do this simple thing which is making the blitzmax Window Topmost on desktop.

how hard cat it be.. gees..

IVe used all this commands

SetWindowPos(ThisWinAddress, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE)
ShowWindow(ThisWinAddress, 255)
SetActiveWindow(ThisWinAddress)
SetFocus(ThisWinAddress)

still doesnt work omg.. what wrong..

only when i used
SetWindowPos(ThisWinAddress, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE)

it worked but then the window remains locked on topmost state..


grable(Posted 2015) [#16]
Thats what topmost means in windows ;)

Otherwise ShowWindow(SW_SHOW) or SetActiveWindow should always move it to top of Z-order.
SetFocus is only for keyboard focus btw.

Oh, and you really should read up on these functions and others on MSDN, they are documented quite well.


Henri(Posted 2015) [#17]
Hi,

I believe that this is MS restriction (From Vista onwards) so that people wouldn't make popups when user is writing in active window. You can make application icon flash with 'SetForegroundWindow(hwnd)'.

Here is some info found in codeproject website link

-Henri


grable(Posted 2015) [#18]
Ah yes, you are right of course. i forgot about that one, sucks to have XP era knowledge :/


Hardcoal(Posted 2015) [#19]
The thing is grable is that after I load the dragged file,
Im trying to make the blitzmax window active again.
I Do

SetWindowPos(ThisWinAddress, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE)
SetActiveWindow(ThisWinAddress)

And it works well once.

But on second drag.. it doesn't..
how come?


grable(Posted 2015) [#20]
Well... If you had done what Henri said and used SetForegroundWindow instead, you would not have that problem.


Hardcoal(Posted 2015) [#21]
Sorry Grable. How could I missed that post..?

I guess it's because I was reading it from a phone.


Ok. problem solved thanks Henry