>>-aMessageExtensions~ConnectTreeNotify(--id--,--"--+-BEGINDRAG---+--"--> +-BEGINRDRAG--+ +-BEGINEDIT---+ +-ENDEDIT-----+ +-DEFAULTEDIT-+ +-EXPANDING---+ +-EXPANDED----+ +-DELETE------+ +-KEYDOWN-----+ +-SELCHANGING-+ +-SELCHANGED--+ >--+---------------+--)---------------------------------------->< +-,--msgToRaise-+
The ConnectTreeNotify method connects a particular WM_NOTIFY message for a tree view control with a method. The WM_NOTIFY message informs the dialog that an event has occurred in the tree view.
The arguments are:
The ID of the tree view control of which a notification is to be connected to a method.
The event to be connected with a method:
A drag-and-drop operaton was initiated. See DefTreeDragHandler for information on how to implement a drag-and-drop handler.
A drag-and-drop operaton involving the right mouse button was initiated. See DefTreeDragHandler for information on how to implement a drag-and-drop handler.
Editing a label has been started.
Label editing has ended.
This event connects the notification that label editing has been started and ended with a predefined event-handling method. This method extracts the newly entered text from the notification and modifies the item of which the label was edited. If this event is not connected you must provide your own event-handling method and connect it with the BEGINEDIT and ENDEDIT events. Otherwise, the edited text is lost and the item remains unchanged.
When you specify this event, omit the msgToRaise argument.
An item is about to expand or collapse. This notification is sent before the item has expanded or collapsed.
An item has expanded or collapsed. This notification is sent after the item expanded or collapsed.
An item has been deleted.
A key was pressed inside the tree view. This notification is not sent while a label is being edited.
Another item is about to be selected. This notification is sent before the selection has changed.
Another item was selected. This notification is sent after the selection was changed.
The message that is to be sent whenever the specified notification is received from the tree view control. Provide a method with a matching name. If you omit this argument, the event is preceded by On.
The return codes are:
No error detected.
The resource ID could not be resolved or the event argument is incorrect.
The message was not connected correctly.
The following example connects the selection-changed event for the tree view FileTree with method NewTreeSelection and displays the text of the new selection:
::class MyDlgClass subclass UserDialog inherit MessageExtensions ::method Init self~init:super(...) self~ConnectTreeNotify("FileTree", "SELCHANGED", "NewTreeSelection") ::method NewTreeSelection tc = self~GetTreeControl("FileTree") info. = tc~ItemInfo(tc~Selected) say "New selection is:" info.!text
Note:
Connections are usually placed in the Init or InitDialog method. If both methods are defined, use init as the place for this connection - but not before init:super has been called.
The event-handling method connected to ENDEDIT receives two arguments: the item handle of which the label has been edited and the newly entered text. Example:
::method OnEndEdit use arg item, newTextThe event-handling method connected to KEYDOWN receives two arguments: the control ID of the tree view control and the virtual key code pressed. Use the method KeyName of the VirtualKeyCodes class to get the name of the key. Note that your class must inherit from the VirtualKeyCodes class to use the KeyName method. Example:
::method OnKeyDown use arg id, vkey say "Key" self~KeyName(vkey) "was pressed."The event-handling method connected to EXPANDED or EXPANDING receives three arguments: the control ID of the tree view control, the tree item expanded or collapsed, and a string that indicates whether the item was expanded or collapsed. Example:
::method OnExpanding use arg id, item, what say "Item with handle" item "is going to be" whatThe event-handling method connected to BEGINDRAG or BEGINRDRAG receives three arguments: the control ID of the tree view control, the tree item to be dragged, and the point where the mouse cursor was pressed (x and y positions, separated by a blank). Example:
::method OnBeginDrag use arg id, item, where say "Item with handle" item "is in drag-and-drop mode" parse var where x y say "The drag operation started at point ("x","y")"