Hi.
I'm trying to fabricate the universal DragAndDrop support.
My intention was not to change HMG sources and create additional events for controls, but only to use available methods.
I thought to use the existing "GetFocus" event.
The projects are not complete yet and free of errors, but I present to the wider circle for its evaluation and suggestions.
I study the behavior of events and I still have a lot to catch up
.
The current version supports GRID, TEXTBOX, EDITBOX, RICHEDITBOX controls.
Because TextBox and Editbox are not able to handle the DragAndDrop event with the left mouse button (do a text selection), I did DragAndDrop with the right mouse button.
There is also a function that returns the value with which the mouse button was made DragAndDrop. You can use it to, for example, create a context menu
.
I am sending source and demo in the attachment.
The demo supports the following DragAndDrop events:
from Form_1: Grid_1 to Form_2: Grid_1 - copies the dragged content of the cell.
from Form_1: Grid_1 to Form_3: Grid_1 with the left mouse button - copies the entire row that has been dragged.
from Form_1: Grid_1 to Form_3: Grid_1 with the right mouse button - displays a context menu with dynamic options: add / insert a dragged row; replace the current line with data from the line being dragged; move from Form_1: Grid1 dragged row.
from Form_2: Grid_1 to any Form_2 control - it copies the contents of the cell (it also copies cells within itself)
You can copy from any controls of all forms to each control type TEXTBOX, EDITBOX and RICHEDITBOX of Form_2
From Form_3: Grid_1 to Form_1: Grid_2 - moves the entire row.
Available functions:
HMG_Is_DaD () - determines whether the DragAndDrop operation was performed. We can then specify different behaviors for the GotFocus event, depending on whether it is a real event or just simulated by DragAndDrop.
HMG_DaD_Drag_Window () - the name of the window from which DragAndDrop was started
HMG_DaD_Drag_Control () - name of the control from which the data was dragged
HMG_DaD_Drop_Window () - the name of the window in which the data was dropped.
HMG_DaD_Drop_Control () - name of the control in which the data was dropped.
HMG_DaD_DragCellRow () - the Grid row from which the data was dragged (only for GRID)
HMG_DaD_DragCellCol () - the Grid column from which the data was dragged (only for GRID)
HMG_DaD_DropCellRow () - the Grid row on which data has been dropped (only for GRID). If dropped in empty space, it will equal to 0
HMG_DaD_DropCellCol () - the Grid column on which data has been dropped (only for GRID)). If dropped in empty space, it will equal to 0
HMG_DaD_Value () - value of dragged data, it is always an array, for a row Grid consisting of all cells in a row. For TEXT it's a value as one-dimensional array.
HMG_DaD_CellValue () - cell value (GRID)/ value (TEXT) of dragged data
HMG_Is_RButtonDaD() - it return the value .T. if DragAndDrop was using with the right mouse button.
HMG_Release_DaD () - releases the saved values for DragAndDrop.
To use the DragAndDrop function, add DragAndDrop.prg to your project.
In the source of the main program, you should initiate the DragAndDrop support via
command:
EnableDragAndDrop ()
Disabling DragAndDrop support via:
DisableDragAndDrop ().
Enjoy.
I apologize for my hopeless English.