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

Arnd Schmidt Accepted Answer Pending Moderation
  1. Friday, 5 May 2023 16:16 PM UTC
  2. PowerBuilder
  3. # 1

Hi Stephan,

make sure that you really call DragAcceptFiles(). I am not sure if that is a typo in your code or in your post.

IN OPEN EVENT of the Window:
//Postevent("ue_enabledrag") Wrong Eventname?!
Postevent("ue_enable_drag")

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

hth

Arnd

Comment
  1. Stephan Schröpel
  2. Monday, 8 May 2023 08:31 AM UTC
HI Arnd

it's a typo mismatch in the post. I used Drag&Drop Code in different windows and it worked fine until migrating to 2022. By dragging a file, you can see the drag-icon at mouse-pointer. But event pbm_dropfiles does not fire any longer. I tried same code in a new and not inherited window. But same reaction. creating a new workspace and testing ist, or opening Chis file example all works fine.



There must something inhibit /or capture earlier?) pbm_dropfiles from fireing in my application.



Best regards

Stephan

  1. Helpful
There are no comments made yet.
Stephan Schröpel Accepted Answer Pending Moderation
  1. Friday, 17 March 2023 14:37 PM UTC
  2. PowerBuilder
  3. # 2

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. # 3

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. # 4

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
  1. Jim Buell
  2. Wednesday, 24 April 2024 13:24 PM UTC
This solved my problem when upgrading from 2021 to 2022R3. Thanks Roland.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Wednesday, 18 January 2023 12:55 PM UTC
  2. PowerBuilder
  3. # 5

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. # 6

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. 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
  1. Stephan Schröpel
  2. Friday, 5 May 2023 12:39 PM UTC
Hi Chris

In your FileDrop Application code I found

IF IsUserAnAdmin() THEN DragrDrop does not work

I made the same test in my application and it says: I am an Admin.



Could this be the cause, my Drag&Drop does not work any longer?

Why am I an Admin in my application, but not in your FileDrop application?





Have a nice weekend

Best regards

Stephan



  1. Helpful
  1. Chris Pollach @Appeon
  2. Friday, 5 May 2023 14:41 PM UTC
Hi Stephan;

I put that check into the framework when I updated to PB 2019 and higher when testing on W10 22H1 as external file drops stopped working when I was running my PB App in Admin Mode. Now that we are on PB 2022 wit W1- & W11 version 22H2, I have not retested that aspect to see if that O/S behaviour (restriction) has been lifted by MS.

PS: PB2022 is also now compiled with VC++ 2019 vs VC++ 2010 in PB 2019/2021 - so that might make a difference now as well.

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.