1. Stephan Schröpel
  2. PowerBuilder
  3. Tuesday, 17 January 2023 09:43 AM UTC

Hello

 Rolands code Example  worked very well for years for me. Thanks to Roland.

But in PB2022.1892 my user event uw_dropfiles from pbm_dropfiles does not fire any longer. The event is implemented in a w_main window. The same code in PB2021.1506 is working. Drag&Drop is enabled, but releasing mouse button makes pbm_dopfiles fire.

Is something different?

Thank you 

Stephan

Stephan Schröpel Accepted Answer Pending Moderation
  1. Friday, 17 March 2023 14:37 PM UTC
  2. PowerBuilder
  3. # 1

Hi Chris,
unfortunately it does not work.I made all the changes to Longptr
I am using your code in two windows, in none of them the pbm_dropfiles event ( = ue_dropfiles) fires. In debugging mode I set a breakpoint at the beginning of the event, but it never stops there.

Here is the code:

LOCAL EXTERNAL FUNCTIONS
FUNCTION ulong DragQueryFile(Longptr al_hDrop, ulong ai_File, REF string as_FileName, ulong ai_cb) LIBRARY "shell32.dll" alias for "DragQueryFileW"

SUBROUTINE DragAcceptFiles(Longptr l_hWnd,boolean fAccept) LIBRARY "shell32.dll" // alias for "DragAcceptFiles"

SUBROUTINE DragFinish(ulong hDrop) LIBRARY "shell32.dll" Alias for "DragFinish"

IN OPEN EVENT of the Window:
Postevent("ue_enabledrag")

IN EVENT UE_ENABLE_DRAG:
DragAcceptFiles(handle(this), true)



IN EVENT UE_DROPFILES with Event_ID pbm_dropfiles:

String ls_path
String ls_temp
ulong lul_file, lul_max_files
Long ll_pos1,ll_pos2
Constant ULong lul_hex = 4294967295
ULong lul_pathSize = 1023
ulong lul_index

ls_path = Space(lul_pathSize)
lul_max_files = DragQueryFile(handle, lul_hex, ls_path, lul_pathSize)

IF lul_max_files > 0 THEN

DO WHILE lul_index >= 0 and lul_index < lul_max_files
ls_path = Space(lul_pathSize)
lul_file = DragQueryFile(handle, lul_index, ls_path, lul_pathSize)
IF lul_file > 0 THEN
fw_import(ls_path)
lul_index++
ELSE
lul_index = -1
END IF
LOOP
END IF

DragFinish(handle)

 

Comment
  1. Chris Pollach @Appeon
  2. Friday, 17 March 2023 15:40 PM UTC
Hi Stephan;

FYI: I have just released my Drag & Drop external files example in PB 2022. http://chrispollach.blogspot.com/2023/03/external.html



Note that there are two formats to the DragQueryFile SDK declaration ...

FUNCTION Integer DragQueryFile ( LongPTR hDrop, uLong iFile, uLong lpszFile, uLong cch ) Library "SHELL32.dll" Alias For "DragQueryFileW"

FUNCTION Integer DragQueryFile ( LongPTR hDrop, uLong iFile, Ref String lpszFile, uLong cch ) Library "SHELL32.dll" Alias For "DragQueryFileW"



li_Files = go_ac.DragQueryFile ( handle, 4294967295, ls_File, 0 )

Note that the last parameter is a ZERO to allow an "indeterminate" length of data to be returned.



HTH

Regards ... Chris
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Thursday, 19 January 2023 14:51 PM UTC
  2. PowerBuilder
  3. # 2

I built a more advanced version of my example and posted it on my website:

https://www.topwizprogramming.com/freecode_dragfiles.html

Files are dragged into a ListView control where they are shown with file icons, type, size, and date.

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Wednesday, 18 January 2023 15:35 PM UTC
  2. PowerBuilder
  3. # 3

I figured it out, the external function declarations in my example have incorrect data types so don't work in 64bit.

The handle arguments need to be defined as Longptr:

Subroutine DragAcceptFiles ( Longptr hWnd, Boolean fAccept ) Library "shell32.dll"

Function ULong DragQueryFile ( Longptr hDrop, ULong iFile, Ref String lpszFile, ULong cch ) Library "shell32.dll" Alias For "DragQueryFileW"

 

Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Wednesday, 18 January 2023 12:55 PM UTC
  2. PowerBuilder
  3. # 4

Hi,

If the same code is working in pb2021, than this suggests a "bug" or at least a change of "something" to me.

Can you make a small sample application that reproduces the problem and post it here and maybe even better on https://www.appeon.com/standardsupport/newbug ?

regards.

Comment
  1. Miguel Leeuwe
  2. Wednesday, 18 January 2023 12:58 PM UTC
Also, I don't really understand what you mean when you say "... my user event uw_dropfiles from pbm_dropfiles does not fire any longer. ... but releasing mouse button makes pbm_dopfiles fire..."

So .. when does it fire and when not?

regards
  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 18 January 2023 13:00 PM UTC
You wouldn't have 2 events mapped to the same pbm_dropfiles ?
  1. Helpful
  1. Roland Smith
  2. Wednesday, 18 January 2023 18:14 PM UTC
I think he was running 64bit and my external function declaration had the wrong data type for the handles.
  1. Helpful 1
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 17 January 2023 21:37 PM UTC
  2. PowerBuilder
  3. # 5

Hi Stephan;

   FWIW: My STD Framework's drag & drop is working well for me in PB 2022 build 1892.

   I just migrated the PB 2021 version to 2022 and it unit tests 100%, as follows:

   I will do a full unit test of this code tonight and post the PB2022 updated example to the STD Framework's website. I will update you later on this evening where to download it. Maybe you can spot something different in my code vs Roland's that might help explain the issue.

Regards ... Chris

Comment
  1. Stephan Schröpel
  2. Tuesday, 24 January 2023 10:07 AM UTC
Hi Chris,



your code example is working, but using the same code, the event in my software is still not firing. Now I developed so much changes... Customers are waiting for the next release, and I'm still trying to hold them back.

Is there a way to fall back to a prevoius version? Or hoping that this problem will be fixed in future releases?



Best regards

Stephan

  1. Helpful
  1. Roland Smith
  2. Tuesday, 24 January 2023 13:27 PM UTC
Dragging files from Windows Explorer triggers the pbm_dropfiles event, not the dragdrop event. The dragdrop event is for dragging between two PB controls. Take a look at my example I posted above.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 24 January 2023 19:55 PM UTC
Hi Stephan;

If Roland & My examples work in PB 2022 build 1892 then your App should as well ... IF, you followed the same coding approach.

Unfortunately without seeing your App code implementation, it's hard to advise you further.

Regards ... Chris
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.