Except leaderless status
We have a forum builder admin, it isn't
Moderator: Rathinagiri
Code: Select all
Error BASE/1132 Błąd zakresu tablicy: Nieprawidłowa liczba argumentów - Error array range - Incorrect number of parameters
Called from OBSLBLEDU(758)
Called from (b)MAIN(239)
Called from TREEITEMGETHANDLE(442)
Called from TREEITEMGETPATHVALUE(598)
Called from _TREE_GETPROPERTY(10062)
Called from GETPROPERTY(8361)
Called from line: MsgDebug(this.Value, MainForm.Tree.GetPathValue(this.Value))
I can't reproduce it. Get path by DblClick on node/itemmol wrote: ↑Tue Jan 15, 2019 3:03 pm There is a problem with <ParentWindowName>.<TreeControlName>.GetPathValue ( nValue ) --> anPathValue | NIL get property.
When I call it, runtime error is generated:Code: Select all
Error BASE/1132 Błąd zakresu tablicy: Nieprawidłowa liczba argumentów - Error array range - Incorrect number of parameters Called from OBSLBLEDU(758) Called from (b)MAIN(239) Called from TREEITEMGETHANDLE(442) Called from TREEITEMGETPATHVALUE(598) Called from _TREE_GETPROPERTY(10062) Called from GETPROPERTY(8361) Called from line: MsgDebug(this.Value, MainForm.Tree.GetPathValue(this.Value))
Code: Select all
#include "hmg.ch"
Function main()
EnableDragAndDrop()
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 700 ;
HEIGHT 500 ;
TITLE 'TreeView Simple Sample Drag And Drop' ;
MAIN
@ 30,10 LABEL Label_2 VALUE "Tree #1." AUTOSIZE
DEFINE TREE Tree_1 ;
AT 50,10 ;
WIDTH 200 HEIGHT 400 ;
VALUE 227 ;
ON GOTFOCUS Drag_Tree1() ;
ON CHANGE Form_1.Title:='Tree #1, Item # '+hb_valtostr(Form_1.tree_1.Value)+" , ItemName " +Form_1.tree_1.Item(Form_1.Tree_1.Value) ;
ON DBLCLICK MsgDebug (Form_1.Tree_1.Value, Form_1.Tree_1.GetPathValue (Form_1.Tree_1.Value)) ;
ITEMIDS
NODE 'Item 1' ID 1
TREEITEM 'Item 1.1' ID 11
TREEITEM 'Item 1.2' ID 12
TREEITEM 'Item 1.3' ID 13
END NODE
NODE 'Item 2' ID 2
TREEITEM 'Item 2.1' ID 21
NODE 'Item 2.2' ID 22
TREEITEM 'Item 2.2.1' ID 221
TREEITEM 'Item 2.2.2' ID 222
TREEITEM 'Item 2.2.3' ID 223
TREEITEM 'Item 2.2.4' ID 224
TREEITEM 'Item 2.2.5' ID 225
TREEITEM 'Item 2.2.6' ID 226
TREEITEM 'Item 2.2.7' ID 227
TREEITEM 'Item 2.2.8' ID 228
END NODE
TREEITEM 'Item 2.3' ID 23
END NODE
NODE 'Item 3' ID 3
NODE 'Item 3.1' ID 31
TREEITEM 'Item 3.1.1' ID 311
NODE 'Item 3.1.2' ID 312
TREEITEM 'Item 3.1.2.1' ID 3121
TREEITEM 'Item 3.1.2.2' ID 3122
END NODE
TREEITEM 'Item 3.1.3' ID 313
END NODE
TREEITEM 'Item 3.2' ID 32
NODE 'Item 3.3' ID 33
TREEITEM 'Item 3.3.1' ID 331
TREEITEM 'Item 3.3.2' ID 332
END NODE
END NODE
END TREE
END WINDOW
MsgInfo( "Do tree items use IDs? " + hb_valToStr( _IsTreeItemIDs ( 'Tree_1', 'Form_1' ) ))
ACTIVATE WINDOW Form_1
Return
***********************************
Function Drag_Tree1()
Local cDragFName := HMG_DaD_Drag_Window()
Local cDragCName := HMG_DaD_Drag_Control()
Local cDropFName := HMG_DaD_Drop_Window()
Local cDropCName := HMG_DaD_Drop_Control()
Local nDragTreeValue := HMG_DaD_DragTreeValue()
Local nDropTreeValue := HMG_DaD_DropTreeValue()
Local lIsDraggedWithRightButton := HMG_Is_RButtonDaD()
Local lIsDraggedWithShiftButton := HMG_Is_ShiftDaD()
IF HMG_Is_DaD()
HMG_Release_DaD()
DO CASE
CASE cDragFName == cDropFName .AND. cDragFName == 'Form_1' .AND. cDragCName == cDropCName .AND. cDragCName == 'Tree_1' .AND. nDragTreeValue <> nDropTreeValue
Tree_UpDate ( cDragFName, cDragCName, nDragTreeValue, cDropCName, cDropFName, nDropTreeValue, .F. /* no copying at IDs -> you have to send some new iID some way ?!? */, !lIsDraggedWithShiftButton )
ENDCASE
ENDIF
RETURN
*************************************************************************
FUNCTION Tree_UpDate ( cDragFName, cDragCName, nDragTreeValue, cDropCName, cDropFName, nDropTreeValue, lCopy, lAdd )
Local aDragItems := _GetTreeItemStru( cDragFName, cDragCName, nDragTreeValue )
//Notice: Version for tree IDs ONLY
IF nDropTreeValue == 0 .AND. !MsgYesNo("Do you want to add an item as Root?", "Dropped in an empty area.", .T.)
RETURN Nil
ENDIF
IF !EMPTY ( aDragItems )
DoMethod (cDragFName, cDragCName, "DisableUpdate")
DoMethod (cDropFName, cDropCName, "DisableUpdate")
//remove first to prevent duplicate id from appearing
DoMethod (cDragFName, cDragCName, "DeleteItem", nDragTreeValue)
IF lAdd //add item
AEVAL ( aDragItems, { |x| IF ( x[3] == 0, ;
DoMethod (cDropFName, cDropCName, "AddItem", x[2] , nDropTreeValue /* add on the drop position */, x[1] /* original id */ ) , ;
DoMethod (cDropFName, cDropCName, "AddItem", x[2] , x[3] /* add to the parent position */ , x[1] /* original id */ ) ) } )
ELSE //insert
_InsertItem ( cDropCName, cDropFName, aDragItems[1][2] , nDropTreeValue , aDragItems[1][1] /* original id */)
hb_ADel( aDragItems, 1, .T. )
AEVAL ( aDragItems, { |x| DoMethod (cDropFName, cDropCName, "AddItem", x[2] , x[3] /* add to the parent position */ , x[1] /* original id */ ) } )
ENDIF
DoMethod (cDropFName, cDropCName, "SetDefaultAllNodeFlag")
DoMethod (cDragFName, cDragCName, "EnableUpdate")
DoMethod (cDropFName, cDropCName, "EnableUpdate")
ENDIF
RETURN
*************************************************
FUNCTION _GetTreeItemStru( cFormName, cTreeName, nTreeValue )
Local ix := 0
Local aTreeStru := {}, aChild
Local nParent := 0, nItem := 1
IF nTreeValue = 0 //New root
nTreeValue := 1
ENDIF
IF IsControlDefined ( &cTreeName, &cFormName )
ix := GetControlIndex (cTreeName , cFormName )
AADD (aTreeStru, { nTreeValue, GetProperty (cFormName, cTreeName, "Item", nTreeValue), nParent } )
Do While nItem <= LEN ( aTreeStru )
nParent := aTreeStru [nItem] [1]
aChild := GetProperty ( cFormName, cTreeName, "ChildValue", nParent )
nItem ++
IF hb_isArray ( aChild )
AEVAL (aChild, { |x| AADD( aTreeStru, { x, GetProperty (cFormName, cTreeName, "Item", x), nParent } ) } )
ENDIF
EndDo
ENDIF
IF _IsTreeItemIDs ( cTreeName, cFormName ) .AND. ix > 0
ASORT ( aTreeStru, , , { |x, y| ascan ( _HMG_SYSDATA [ 25 ] [ix] , x[1] ) < ascan ( _HMG_SYSDATA [ 25 ] [ix] , y[1] ) } )
ELSE
ASORT ( aTreeStru, , , { |x, y| x[1] < y[1] } )
ENDIF
//*** Structure of aTreeStru***************
//* { { nItem, cItemText, nParentItem } , ... }
//*****************************************
Return aTreeStru
edk wrote: ↑Sat Dec 16, 2017 10:10 pm 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 fromtoCode: 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'})
Dragging GRID columns is possible only within currently visible columns and only from GRID, in which Items are.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'})
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.