Hello everyone.
A user proposed to me to use "Drag&Drop" to assign a file (document, image, pdf, etc) to certain records, because it was more intuitive than pressing an F* key and recovering the file, even using win_GetOpenFileName().
My app is console mode and I found that when I dragged and dropped a file, its full name was entered as keystrokes. Well, something positive if I dragged right in the GET, but I didn't know that it could generate the same behavior outside the GET, affecting the menus or jumping to other gets if there are several. I have searched how to enable/disable that option from Harbor, but I have not found any solution.
I have tried to solve this situation, using a procedure that accepts the data, but I can only get it to work if the file starts with ", that is, it has spaces and Windows puts it between " ". Here is the code if you want to try it...
/**/
//Testing how to manage drag&drop (accept/reject). File dropped must have spaces in full path to work. (e.g. "My dropped file.ext")
Private nOption, xBuffer:=PadR('Original Data to Get',MaxCol()+1)
SetMode(25,80)
Clear Screen
nOption := Alert('Testing Windows "Drag & Drop" File_Name with Spaces', {'ALLOW','DISABLE_CLEAR','DISABLE_BUFFER'})
do case
case nOption == 1
// nothing
case nOption == 2
Set Key 34 to ClearBuffer // 34 is asc('"')
case nOption == 3
Set Key 34 to DragDropOut // 34 is asc('"')
endcase
@ 0,0 SAY 'Testing Windows "Drag & Drop" File_Name with Spaces'
@ 1,0 GET xBuffer
Read
PROCEDURE ClearBuffer // To prevent drag&drop inserts chars
Local cScr, aGets, xBuffer:=Space(MaxCol()+1)
Save Screen to cScr
aGets := SaveGets()
@ MaxRow()-1,0 SAY 'Processing "Drag & Drop" NOT allowed. Press ESCAPE to continue ... '
Set Key 34 to
Clear Typeahead
MilliSec(1000)
hb_KeyClear()
Set Key 34 to ClearBuffer
RestGets(aGets)
Restore Screen from cScr
RETURN
PROCEDURE DragDropOut // To prevent drag&drop inserts chars
Local cScr, aGets, xBuffer:=Space(MaxCol()+1)
Save Screen to cScr
aGets := SaveGets()
@ MaxRow()-1,0 SAY 'Processing "Drag & Drop" NOT allowed. Press ESCAPE to continue ... '
@ MaxRow()-0,0 GET xBuffer
Set Key 34 to
Lee()
Set Key 34 to DragDropOut
RestGets(aGets)
Restore Screen from cScr
RETURN
/**/
The question is... (sorry for the long explanation)
Is there an easier way to control when to accept and when to reject a file dropped on a window in console mode?
Thank you !!!