Page 2 of 3

Re: Drag grid item to another grid

Posted: Tue Dec 12, 2017 8:43 pm
by mol
thank you Edward!

Re: Drag grid item to another grid

Posted: Wed Dec 13, 2017 2:27 am
by huiyi_ch
thank you Edward!

Re: Drag grid item to another grid

Posted: Wed Dec 13, 2017 8:38 am
by bpd2000
serge_girard wrote: ↑
Tue Dec 12, 2017 4:10 pm
Great and many thanks!

I will take a look at it asap!

Serge
+1

Re: Drag grid item to another grid

Posted: Wed Dec 13, 2017 3:22 pm
by edk
Next version.
  • Support for LISTBOX and LISTBOX Multiselect has been added.
  • Support for Grid Multiselect has been added.

    Because the Multiselect support has been added, the concept of storing the dragged variables has been changed. Each table item is one record. Each record is an array containing data:
    Grid - cell values ​​in a row.
    TextBox, EditBox - value of the control
    RichEditBox - if there is no text selection, the contents of the control, if selected, is the selection value.
    ListBox - item value.
  • The mouse pointer has been changed to drag.
  • Small fixes for using EditBox and RichEditBox.
Dragging from ListBox only with the right mouse button.

There is a problem with determining the row position when dropping data on ListBox. I can not determine this based on the parameter lParam. The GET_DRAG_LIST_DRAGITEM function does not work properly due to receiving the wrong control handle. I do not know why the received control handle differs from the saved value _HMG_SYSDATA [54].
Therefore, the function of handling the data dropout on ListBox is limited and it is not possible to simulate the data insertion operation between items as in Grid.

Re: Drag grid item to another grid

Posted: Wed Dec 13, 2017 4:44 pm
by serge_girard
Thanks Edward !

Looks very great!

Serge

Re: Drag grid item to another grid

Posted: Thu Dec 14, 2017 12:16 am
by huiyi_ch
serge_girard wrote: ↑
Wed Dec 13, 2017 4:44 pm
Thanks Edward !

Looks very great!

Serge
+1

Re: Drag grid item to another grid

Posted: Thu Dec 14, 2017 2:50 pm
by edk
Another version.
While dragging the data, a preview of what we drag. :)
Unfortunately, when dragging ListBox, the preview is not precise. :(
DragAndDrop_0.003.7z
(1.1 MiB) Downloaded 69 times
PS Improvement of small bugs:
DragAndDrop_prg.7z
(3.51 KiB) Downloaded 64 times

Re: Drag grid item to another grid

Posted: Sat Dec 16, 2017 10:10 pm
by edk
Next version.
Support for dragging GRID column headers has been added.

Due to the ON HEADCLICK event handler, dragging is possible with the right mouse button only.

Within the same Grid, dragging the header changes the order of the columns.

Dragging a column header from GRID Form_1 to Grid Form_2 or Form_3 adds a new column.
By the way, I found a bug in the operation of the AddColumnEx method.
If we add a new column between existing ones, after inserting the column, the neighbor column's caption also changes.

You can test this eg in \SAMPLES\Controls\Grid\GRID_40 changing in file demo.prg line No. 108 from

Code: Select all

@ 250,  55 BUTTON Button_1 CAPTION "AddCol" ACTION Form_1.Grid_1.AddColumnEx (Nil, "Col"+alltrim(str(++n)), 100, NIL, {'TEXTBOX','NUMERIC','$ 999,999'})
to

Code: Select all

@ 250,  55 BUTTON Button_1 CAPTION "AddCol" ACTION Form_1.Grid_1.AddColumnEx (2, "Col"+alltrim(str(++n)), 100, NIL, {'TEXTBOX','NUMERIC','$ 999,999'})
Dragging GRID columns is possible only within currently visible columns and only from GRID, in which Items are.

In addition, the problem with ScrollBar in GRID was revealed. By moving the mouse pointer to ScrollBar the handle does not change, and the program "Sees" as if it was still on GRID, moving the slider horizontally may result in a drag effect.

I'm really sorry for the imperfections of my DragAndDrop.

Certainly better results could be obtained using the C language, but this is beyond my reach.

Re: Drag grid item to another grid

Posted: Sun Dec 17, 2017 4:24 am
by bpd2000
Nice contribution, Thanks

Re: Drag grid item to another grid

Posted: Mon Dec 18, 2017 2:01 pm
by Steed
Thanks