1. Drag and Drop Win32Lib Example Needed

Couldn't find info in the docs, nor an example in the examples.

Can somebody post code for using w32HDragAndDrop?

Thank you!

new topic     » topic index » view message » categorize

2. Re: Drag and Drop Win32Lib Example Needed

You don't need to look more than ListTreeView.exw in the DEMO directory of Win32Lib. If you have something editor that can search directories, use it.

jEdit, or grep, or walk_dir() with read_file() and match() in EUPHORIA.

new topic     » goto parent     » topic index » view message » categorize

3. Re: Drag and Drop Win32Lib Example Needed

Thanks for the clue, SPringle.

I realize now I need to be more specific. :)

I'm wanting to drag and drop a file from my desktop (or any explorer location) to the window or a control. I couldn't get the ListTreeView.exw program to accept a file dragged from the desktop.

Thanks!

new topic     » goto parent     » topic index » view message » categorize

4. Re: Drag and Drop Win32Lib Example Needed

euphoric said...

Thanks for the clue, SPringle.

I realize now I need to be more specific. :)

I'm wanting to drag and drop a file from my desktop (or any explorer location) to the window or a control. I couldn't get the ListTreeView.exw program to accept a file dragged from the desktop.

Thanks!

It's easily possible that you already know this, and I may be wrong in some respect also, but:

the demo doesn't USE w32HDragAndDrop to DO anything, it just serves to "ANNOUNCE" or trigger an alert that the user has "dragged and dropped" (that is, dragged and ATTEMPTED to drop) something somewhere; the event routine that's invoked then must handle COMPLETELY the action of PUTTING that thing that was dragged INTO/ONTO the place it was "dropped" onto.

"w32HDragAndDrop" doc says: Something has been dragged onto the control or window

note that that doesn't mean that the something has actually been PUT onto a control or window, simply that it was "dragged" there and the mouse button was then RELEASED, such that the event routine knows that there was an INTENT to put something somewhere; you still have to MOVE it there with code.

The demo is only SHOWING a "movement" (in the Tree and List views), not actualy DOING a move. It takes "dummy" fileNames on the ListView, "drags" them as you wish from one dummy "directory" to another on the TreeView, but there are no actual files involved, and there's no actual CODE in the demo to implement file movement.

Hope that might help some, or, I apologize if I've said something you already understand.

Dan

new topic     » goto parent     » topic index » view message » categorize

5. Re: Drag and Drop Win32Lib Example Needed

Well, this is "quick and dirty" example, sortof, but it does allow a file dragged from desktop to be presented in a mle in a Euphoria program, not sure if that's exactly what you wanted or not.

I "lifted" most of it from a Win32Lib demo, "ShowText.exw".

--  code generated by Win32Lib IDE v1.0.4 Build July-06-2008 
 
constant TheProgramType="exw"  
  
include Win32Lib.ew 
without warning 
 
-------------------------------------------------------------------------------- 
--  Window Window1 
constant Window1 = createEx( Window, "Test Drag to EditBox", 0, Default, Default, 400, 300, 0, 0 ) 
constant SB = createEx( StatusBar, "", Window1, 0, 0, 0, 0, 0, 0 ) 
constant MleText2 = createEx( MleText, "MleText2", Window1, 52, 32, 148, 148, w32or_all({ES_AUTOVSCROLL,WS_VSCROLL}), 0 ) 
--------------------------------------------------------- 
-------------------------------------------------------------------------------- 
procedure MleText2_onDragAndDrop (integer self, integer event, sequence params)--params is ( int id, seq FileName ) 
  integer fromId 
  sequence filename 
 
  integer fh 
  object dirinfo 
  sequence data 
 
  fromId = params[1] 
  filename = params[2] 
 
   -- just a test: 
   --  puts(1, "from: " & sprint(fromId) & "  filename: " & filename & "\n") 
 
  if length(filename) > 3 then -- I put this here because the event  
--seems to be invoked 3 times on a drag, 
-- and only one of them has the actual file name, 
-- so I "filtered" for it by requiring it be longer than 
-- three characters.  The "3" is for filename LENGTH, 
-- has nothing(?) to do with the fact that the event  
-- is invoked EXACTLY three times. 
-- To see what I mean, uncomment the test above this. 
 
 
  	 
      -- all that follows is from ShowText demo: 
         -- filename = getText(fName)  --already got it 
    if length(filename) = 0 then 
        setText(SB, "I require a file name first.") 
        return 
    end if 
 
    dirinfo = dir(filename) 
    if equal(dirinfo, -1) then 
        setText(SB, sprintf("File '%s' not found.", {filename})) 
        return 
    end if 
 
    if dirinfo[1][D_SIZE] > 32000 then 
        setText(SB, sprintf("File '%s' is larger than 32000 bytes.", {filename})) 
        return 
    end if 
 
    fh = open(filename, "rb") 
    if fh <= 0 then 
        setText(SB, sprintf("Unable to open file '%s'.", {filename})) 
        return 
    end if 
 
 
    data = get_bytes(fh, dirinfo[1][D_SIZE]) 
 
    setText(MleText2, data) 
 
    close(fh) 
 
    setText(SB, "File loaded.") 
 
 
  end if 
 
 
end procedure 
setHandler( MleText2, w32HDragAndDrop, routine_id("MleText2_onDragAndDrop")) 
---------------------------------- 
WinMain( Window1,Normal ) 
------------------------------------------------------ 


Hope this helps.

Dan

new topic     » goto parent     » topic index » view message » categorize

6. Re: Drag and Drop Win32Lib Example Needed

DanM said...

Well, this is "quick and dirty" example, sortof, but it does allow a file dragged from desktop to be presented in a mle in a Euphoria program, not sure if that's exactly what you wanted or not.

I "lifted" most of it from a Win32Lib demo, "ShowText.exw".

Thanks Dan. That helped. I knew what to do with the w32HDragAndDrop message, but I wasn't able to get it to

setText( txt_FileName, params[2] )

until I put in the test you used, if length( params[2] ) > 3 then...

So, THANKS AGAIN! :)

new topic     » goto parent     » topic index » view message » categorize

7. Re: Drag and Drop Win32Lib Example Needed

euphoric said...
DanM said...

Well, this is "quick and dirty" example, sortof, but it does allow a file dragged from desktop to be presented in a mle in a Euphoria program, not sure if that's exactly what you wanted or not.

I "lifted" most of it from a Win32Lib demo, "ShowText.exw".

Thanks Dan. That helped. I knew what to do with the w32HDragAndDrop message, but I wasn't able to get it to

setText( txt_FileName, params[2] )

until I put in the test you used, if length( params[2] ) > 3 then...

So, THANKS AGAIN! :)

You're welcome!

And if you uncomment the print before that test, you'll see why the event doesn't work right without the test: there are apparently THREE triggerings of the event from ONE drag'n drop, the last one returns nothing for params[2], the first one returns a single character, and the second returns the file name in params[2]. Seems to me there's something WRONG with the event being triggered 3 times for one action??

Dan

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu