Page 3 of 5
Re: Drag and drop file in windows 8.1 possible?
Posted: Sat Feb 01, 2014 4:31 pm
by Sparkie
Fangles,
download this exe and see what happens. Here is the source:
Code: Select all
EnableExplicit
#Window = 0
Enumeration ; Gadgets
#TargetFiles
EndEnumeration
Define Event, Count, i
Define Files$
If OpenWindow(#Window, 0, 0, 800, 600, "Drag & Drop", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
; Create the target gadgets
ListIconGadget(#TargetFiles, 5, 5, 7900, 590, "Drop Files here", 250)
; Now enable the dropping on the target gadgets
EnableGadgetDrop(#TargetFiles, #PB_Drop_Files, #PB_Drag_Copy)
Repeat
Event = WaitWindowEvent()
; Drop event on the target gadgets, receive the dropped data
;
If Event = #PB_Event_GadgetDrop
Select EventGadget()
Case #TargetFiles
Files$ = EventDropFiles()
Count = CountString(Files$, Chr(10)) + 1
For i = 1 To Count
AddGadgetItem(#TargetFiles, -1, StringField(Files$, i, Chr(10)))
Next i
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
End
Re: Drag and drop file in windows 8.1 possible?
Posted: Sat Feb 01, 2014 10:24 pm
by Fangbeast
Sparkie wrote:Fangles,
download this exe and see what happens. Here is the source:
Code: Select all
EnableExplicit
#Window = 0
Enumeration ; Gadgets
#TargetFiles
EndEnumeration
Define Event, Count, i
Define Files$
If OpenWindow(#Window, 0, 0, 800, 600, "Drag & Drop", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
; Create the target gadgets
ListIconGadget(#TargetFiles, 5, 5, 7900, 590, "Drop Files here", 250)
; Now enable the dropping on the target gadgets
EnableGadgetDrop(#TargetFiles, #PB_Drop_Files, #PB_Drag_Copy)
Repeat
Event = WaitWindowEvent()
; Drop event on the target gadgets, receive the dropped data
;
If Event = #PB_Event_GadgetDrop
Select EventGadget()
Case #TargetFiles
Files$ = EventDropFiles()
Count = CountString(Files$, Chr(10)) + 1
For i = 1 To Count
AddGadgetItem(#TargetFiles, -1, StringField(Files$, i, Chr(10)))
Next i
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
End
No drag and drop, circle with diagonal line through it.
I still blame srod's festering, used sheep!!
Re: Drag and drop file in windows 8.1 possible?
Posted: Sat Feb 01, 2014 10:39 pm
by Sparkie
Just a few ideas I've come across on the net in regards to your drag drop issue:
Have you tried disabling various items in your Win startup?
What are your UAC settings?
Create a new Win account and try drag drop from the new account.
Are you using 3rd party desktop manager type apps?
Re: Drag and drop file in windows 8.1 possible?
Posted: Sat Feb 01, 2014 10:58 pm
by srod
Try the following fangles. Drag from explorer to the main window. If it works then the file names should be shown in the debugger.
This uses OLE drop handling which, behind the scenes, should be the way the PB drag/drop lib is doing it. The other possibility is already covered by one of Rashad's posts (#WM_DROPFILES) and you had that working.
If this code works then the fault is definitely with PB's lib.
I think it more likely though that the code will fail and the fault lies elsewhere.
Code: Select all
Structure _IDropTarget
*vTable
refCount.i
blnAllowDrop.i
EndStructure
OleInitialize_(0)
#Window = 0
If OpenWindow(#Window, 0, 0, 800, 600, "Drag & Drop", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
*this._IDropTarget = AllocateMemory(SizeOf(_IDropTarget))
*this\vTable = ?VTable_IDropTarget
RegisterDragDrop_(WindowID(#Window), *this) ; declare our gadget as a potential drop target
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
End
;-Drop enable function.
;-Internal functions.
;/////////////////////////////////////////////////////////////////////////////////
;*pdwEffect guaranteed to be non-null.
Procedure DropTarget_SetEffects(grfKeyState, *pdwEffect.LONG)
If grfKeyState&#MK_CONTROL
If *pdwEffect\l & #DROPEFFECT_COPY
*pdwEffect\l = #DROPEFFECT_COPY
Else
*pdwEffect\l = #DROPEFFECT_NONE
EndIf
ElseIf *pdwEffect\l & #DROPEFFECT_MOVE
*pdwEffect\l = #DROPEFFECT_MOVE
Else
*pdwEffect\l = #DROPEFFECT_NONE
EndIf
EndProcedure
;/////////////////////////////////////////////////////////////////////////////////
;-iDropTarget methods.
;/////////////////////////////////////////////////////////////////////////////////
Procedure.i DropTarget_QueryInterface(*this._IDropTarget, iid, *ppvObject.INTEGER)
Protected result
If CompareMemory(iid, ?IID_IUnknown, SizeOf(CLSID)) Or CompareMemory(iid, ?IID_IDropTarget, SizeOf(CLSID))
*ppvObject\i = *this
*this\refCount + 1
result = #S_OK
Else
*ppvObject\i=0
result = #E_NOINTERFACE
EndIf
ProcedureReturn result
EndProcedure
;/////////////////////////////////////////////////////////////////////////////////
;/////////////////////////////////////////////////////////////////////////////////
Procedure.i DropTarget_AddRef(*this._IDropTarget)
*this\refCount + 1
ProcedureReturn 0
EndProcedure
;/////////////////////////////////////////////////////////////////////////////////
;/////////////////////////////////////////////////////////////////////////////////
Procedure.i DropTarget_Release(*this._IDropTarget)
Protected result
*this\refCount - 1
If *this\refCount > 0
result = *this\refCount
Else
FreeMemory(*this)
EndIf
ProcedureReturn result
EndProcedure
;/////////////////////////////////////////////////////////////////////////////////
;/////////////////////////////////////////////////////////////////////////////////
Procedure.i DropTarget_DragEnter(*this._IDropTarget, dataObject.IDataobject, grfKeyState, pt.q, *pdwEffect.LONG)
Protected result=#S_OK, thisFormatEtc.FORMATETC
*this\blnAllowDrop = #False
If *pdwEffect = 0
result = #E_INVALIDARG
Else
;Check to see if the data object supports our text format.
With thisFormatEtc
\cfFormat = #CF_HDROP
\dwAspect = #DVASPECT_CONTENT
\lindex = -1
\tymed = #TYMED_HGLOBAL
EndWith
If dataObject\QueryGetData(thisFormatEtc) = #S_OK
*this\blnAllowDrop = #True
DropTarget_SetEffects(grfKeyState, *pdwEffect)
Else
*pdwEffect\l = #DROPEFFECT_NONE
EndIf
EndIf
ProcedureReturn result
EndProcedure
;/////////////////////////////////////////////////////////////////////////////////
;/////////////////////////////////////////////////////////////////////////////////
Procedure.i DropTarget_DragOver(*this._IDropTarget, grfKeyState, pt.q, *pdwEffect.LONG)
Protected result = #S_OK
If *pdwEffect = 0
result = #E_INVALIDARG
Else
If *this\blnAllowDrop
DropTarget_SetEffects(grfKeyState, *pdwEffect)
Else
*pdwEffect\l = #DROPEFFECT_NONE
EndIf
EndIf
ProcedureReturn result
EndProcedure
;/////////////////////////////////////////////////////////////////////////////////
;/////////////////////////////////////////////////////////////////////////////////
Procedure.i DropTarget_DragLeave(*this._IDropTarget)
ProcedureReturn #S_OK
EndProcedure
;/////////////////////////////////////////////////////////////////////////////////
;/////////////////////////////////////////////////////////////////////////////////
;*pdwEffect\l contains the original combination of effects.
Procedure.i DropTarget_Drop(*this._IDropTarget, Dataobject.IDataobject, grfKeyState, pt.q, *pdwEffect.LONG)
Protected result = #S_OK, anchWnd, tempAnchWnd, thisFormatEtc.FORMATETC, thisStgMedium.STGMEDIUM, *ptrChar.CHARACTER
If *pdwEffect = 0
result = #E_INVALIDARG
ElseIf *this\blnAllowDrop
;Set effects.
DropTarget_SetEffects(grfKeyState, *pdwEffect)
;Do we proceed?
If *pdwEffect\l <> #DROPEFFECT_NONE
;Retrieve the data. We have previously checked for valid data.
;Windows automatically converts between #CF_TEXT and #CF_UNICODETEXT as appropriate.
With thisFormatEtc
\cfFormat = #CF_HDROP
\dwAspect = #DVASPECT_CONTENT
\lindex = -1
\tymed = #TYMED_HGLOBAL
EndWith
If Dataobject\GetData(thisFormatEtc, thisStgMedium) = #S_OK
If thisStgMedium\hGlobal ;Only prudent to be sure here!
buffer = AllocateMemory(1024)
If buffer
numFiles = DragQueryFile_(thisStgMedium\hGlobal, -1, 0, 0)
For i = 0 To numFiles-1
DragQueryFile_(thisStgMedium\hGlobal, i, buffer, 1024)
Debug PeekS(buffer)
Next
FreeMemory(buffer)
EndIf
EndIf
ReleaseStgMedium_(thisStgMedium)
Else
result = #E_FAIL
EndIf
EndIf
EndIf
ProcedureReturn result
EndProcedure
;/////////////////////////////////////////////////////////////////////////////////
DataSection
VTable_IDropTarget:
Data.i @DropTarget_QueryInterface()
Data.i @DropTarget_AddRef()
Data.i @DropTarget_Release()
Data.i @DropTarget_DragEnter()
Data.i @DropTarget_DragOver()
Data.i @DropTarget_DragLeave()
Data.i @DropTarget_Drop()
CompilerIf Defined(IID_IUnknown, #PB_Label) = 0
IID_IUnknown: ;"{00000000-0000-0000-C000-000000000046}"
Data.l $00000000
Data.w $0000,$0000
Data.b $C0,$00,$00,$00,$00,$00,$00,$46
CompilerEndIf
CompilerIf Defined(IID_IDropTarget, #PB_Label) = 0
IID_IDropTarget: ;{00000122-0000-0000-C000-000000000046}
Data.l $00000122
Data.w $0000,$0000
Data.b $C0,$00,$00,$00,$00,$00,$00,$46
CompilerEndIf
EndDataSection
Re: Drag and drop file in windows 8.1 possible?
Posted: Sun Feb 02, 2014 12:38 am
by Sparkie
Fangles, which came first on your PC, PB 5.21 or Win 8.1?
If PB 5.21 was first, try re-installing (PB 5.21).
Re: Drag and drop file in windows 8.1 possible?
Posted: Sun Feb 02, 2014 1:45 am
by Fangbeast
Have you tried disabling various items in your Win startup?
Everything except motherboard drivers, ADSL statistics and backup program.
What are your UAC settings?
"Always Notify"
Create a new Win account and try drag drop from the new account.
Righty ho, will do that today.
Are you using 3rd party desktop manager type apps?
No, never saw the need for them.
Re: Drag and drop file in windows 8.1 possible?
Posted: Sun Feb 02, 2014 1:46 am
by Fangbeast
Sparkie wrote:Fangles, which came first on your PC, PB 5.21 or Win 8.1?
If PB 5.21 was first, try re-installing (PB 5.21).
Totally clean install of an upgrade window 8 and then to 8.1. Found a way *not* to upgrade windows 7 to 8 but actually do a clean install.
Then installed PB 5.21.
Re: Drag and drop file in windows 8.1 possible?
Posted: Sun Feb 02, 2014 1:48 am
by Fangbeast
If this code works then the fault is definitely with PB's lib.
I think it more likely though that the code will fail and the fault lies elsewhere.
Yes, the code failed darn it.
Re: Drag and drop file in windows 8.1 possible?
Posted: Sun Feb 02, 2014 1:57 am
by Sparkie
Running out of ideas here Fangles....how about restarting IDE and Run as Administrator?
Re: Drag and drop file in windows 8.1 possible?
Posted: Sun Feb 02, 2014 2:34 am
by Fangbeast
Sparkie wrote:Running out of ideas here Fangles....how about restarting IDE and Run as Administrator?
Tried that too Sir Sparkie. Thanks for sticking with me thus far. Windows 8/8.1 has done some funny things to be, especially on the 64 bit version. Don't have a 32 bit version handy to test unfortunately.
Thanks to srod as well for taking the time to stop rotating sheep and help. I mean, the sheep are a full time occupation for him (apart from deliberately festering and steaming underpants of course)!
I bet that the fix will be a simple one that I haven't thought of because I am very stupid these days (Shaddap LuciferSD!!).
Maybe I have to go back to windows 7 for now as it works there and I need to finish this code, or simply adopt RASHAD's kind solution for now.
Re: Drag and drop file in windows 8.1 possible?
Posted: Sun Feb 02, 2014 2:53 am
by Sparkie
What other things are not working properly for you on Win 8.1 Fangles?
Re: Drag and drop file in windows 8.1 possible?
Posted: Sun Feb 02, 2014 3:04 am
by Kuron
Drag and drop file in windows 8.1 possible?
Yes, but you need to manually set proper permissions for your applications due to the security features in Windows 8. More info can be found here on how to properly set up your permissions for each app.
http://www.c-sharpcorner.com/UploadFile ... windows-8/
http://forum.thewindowsclub.com/windows ... lders.html
http://www.mladengradev.com/en/how-to-g ... windows-8/
Re: Drag and drop file in windows 8.1 possible?
Posted: Sun Feb 02, 2014 3:42 am
by Sparkie
Well I never had to manually set permissions but certainly worth a try. I would first try hitting the [Esc] key to see if that fix works for you Fangles.
Nice find Kuron.

Re: Drag and drop file in windows 8.1 possible?
Posted: Sun Feb 02, 2014 3:56 am
by RASHAD
It looks that Drag n Drop in windows 8.1 is a nightmare for many users (see the web)
Fangles, can you run (Programs and Features) and post a list of your installed programs ?
Someone had a problem with a program called Fence for example
Maybe one of your software causing the problem
And take it easy

Re: Drag and drop file in windows 8.1 possible?
Posted: Sun Feb 02, 2014 3:57 am
by Kuron
Sparkie wrote:Nice find Kuron.

Sadly, it is a well-known issue. I am sorry for not seeing this thread before now, or I would have posted the info sooner. I generally do NOT read this forum category and clicked on it by mistake tonight. But one of the three links will usually sort most people out.
I took the easy way out and no longer provide drag and drop functionality in any of my software.
