PC SOFT

WINDEV的在线文档

  • Overview
  • Example of Drag and Drop between a List Box control and a button
  • Example of Drag and Drop between a TreeView control and a TreeView Table control
文档页面当前正在翻译。对于此延迟我们深表歉意。
您可以自愿地帮助我们翻译您想要的文档段落,然后只需通过以下地址与我们联系:info@cn.windev.com
产品
WinDevWebDev-服务器代码WebDev-浏览器代码WinDev Mobile报表和查询
平台
WindowsLinuxWindows MobileWindows PhoneWindows Store appsAndroidAndroid Widget iPhone/iPad
语言
JavaPHPAjax用户代码(MCU)外部语言
数据库
HFSQLHFSQL Client/Server存储过程HF 5.5OLE DBODBC本地访问

Overview
This help page presents two examples of programmed Drag and Drop performed in a WinDev application:

Example of Drag and Drop between a List Box control and a button
The following code is used to delete the data found in a List Box control by Drag and Drop to a graphic button containing a recycle bin. Only the move (cut/paste) is allowed. The move cursor is displayed during the move (cut/paste) between the List Box control and the "Bin" button.

1. Defining the source: the List Box control

//- - Initializing the list box
LST_List..鼠标拖放源=鼠标拖放.程序

2. Defining the target: the BTN_Bin button. In the initialization code of the button, the procedures for managing Drag and Drop are also called by 鼠标拖放事件.

In this example:

  • the 鼠标拖放.滑过 event is used to change the mouse cursor ("Rollover" procedure).
  • the 鼠标拖放.释放 event is used to program the process for managing the drop. In our case, this process corresponds to the deletion of the element from the List box control ("OnDrop" procedure).
//- - Initializing the BTN_Bin button
BTN_Bin..鼠标拖放目标=鼠标拖放.程序

// Call to the OnDrop procedure when the left mouse button
// is released on the BTN_Bin button
鼠标拖放事件"OnDrop"BTN_Bin鼠标拖放.释放

// Call to the Rollover procedure when the mouse cursor
// moves between the source list and the BTN_Bin button
鼠标拖放事件"OnRollover"BTN_Bin鼠标拖放.滑过

3. Defining the procedures:

过程DndDragOver()
// Cursor indicating the move
鼠标拖放光标鼠标拖放.移动

过程OnDrop()
// Only the move is allowed (not the copy)
鼠标拖放接受鼠标拖放.移动
// Delete the element from the source control
列表删除鼠标拖放.源控件

Example of Drag and Drop between a TreeView control and a TreeView Table control
The window contains:
  • a memory TreeView control (filled by programming).
  • a memory TreeView Table control.
The following example is used to move a Treeview control element (or a branch and its children) into a treeview Table control. The two methods of programmed Drag and Drop are presented.

Method 1: Full programmed mode
  1. Defining the source control: the TreeView control:
    // -- Initialization code of TREE_MENU control
    树视图添加TREE_MENU"STARTERS"
    树视图添加TREE_MENU"STARTERS"+TAB+"Salad"
    树视图添加TREE_MENU"STARTERS"+TAB+"Cooked meat"
    树视图添加TREE_MENU"STARTERS"+TAB+"Prawn cocktail"
    树视图添加TREE_MENU"MAIN COURSES"
    树视图添加TREE_MENU"MAIN COURSES"+TAB+"Chicken stew"
    树视图添加TREE_MENU"MAIN COURSES"+TAB+"Fish and chips"
    树视图添加TREE_MENU"MAIN COURSES"+TAB+"Pasta with salmon"
    树视图添加TREE_MENU"MAIN COURSES"+TAB+"Pasta alla carbonara"
    树视图添加TREE_MENU"MAIN COURSES"+TAB+"Pork ribs"
    树视图添加TREE_MENU"DESSERTS"
    树视图添加TREE_MENU"DESSERTS"+TAB+"Caramel custard"
    树视图添加TREE_MENU"DESSERTS"+TAB+"Chocolate cream"
    树视图添加TREE_MENU"DESSERTS"+TAB+"Tiramisu"
    树视图添加TREE_MENU"DESSERTS"+TAB+"Ice cream"
    树视图添加TREE_MENU"DESSERTS"+TAB+"Apple pie"

    // Enable the programmed Drag and Drop
    TREE_MENU..鼠标拖放源=鼠标拖放.程序
  2. Defining the target: the TreeView Table control. In the initialization code of the Table control, the procedures for managing Drag and Drop are also called by 鼠标拖放事件.
    In this example:
    • the 鼠标拖放.滑过 event is used to change the mouse cursor ("pRollover" procedure).
    • the 鼠标拖放.释放 event is used to program the process for managing the drop. In our case, this process corresponds to the copy of the elements found in the Table control into the TreeView Table control ("pDrop" procedure).
      // -- Initializing the TreeView Table control
      TVT_MENU..鼠标拖放目标=鼠标拖放.程序

      鼠标拖放事件pRolloverTVT_MENU鼠标拖放.滑过
      鼠标拖放事件pDropTVT_MENU鼠标拖放.释放
  3. Defining the procedures:
    过程pRollover()

    // Cursor indicating the move
    鼠标拖放光标鼠标拖放.移动

    过程pDrop()

    // Only the move is allowed (not the copy)
    鼠标拖放接受鼠标拖放.移动

    sRoot字符串型
    sLeaf字符串型
    sElement字符串型
    sChild字符串型

    sElement树视图选择TREE_MENU
    sRoot提取字符串sElement1TAB从头部
    sLeaf提取字符串sElement1TAB从尾部

    如果sLeafsRoot,那么
    如果表格查找子元素COL_TREEsRoot)=-1,那么
    表格添加子行TVT_MENU0sRoot
    结束

    sChild树视图获取子元素TREE_MENUsRoot树视图.第一个
    只要sChild不等于""
    表格添加子行TVT_MENUsRootsChild
    sChild树视图获取子元素TREE_MENUsRoot树视图.下一个
    结束
    否则
    如果表格查找子元素COL_TREEsRoot)=-1,那么
    表格添加子行TVT_MENU0sRoot
    结束
    表格添加子行TVT_MENUsRootsLeaf
    结束

Method 2: Simplified programed mode

  1. Defining the source control: the TreeView control.
    树视图添加TREE_MENU1"STARTERS"
    树视图添加TREE_MENU1"STARTERS"+TAB+"Salad"
    树视图添加TREE_MENU1"STARTERS"+TAB+"Cooked meat"
    树视图添加TREE_MENU1"STARTERS"+TAB+"Prawn cocktail"
    树视图添加TREE_MENU1"MAIN COURSES"
    树视图添加TREE_MENU1"MAIN COURSES"+TAB+"Chicken stew"
    树视图添加TREE_MENU1"MAIN COURSES"+TAB+"Fish and chips"
    树视图添加TREE_MENU1"MAIN COURSES"+TAB+"Pasta with salmon"
    树视图添加TREE_MENU1"MAIN COURSES"+TAB+"Pasta alla carbonara"
    树视图添加TREE_MENU1"MAIN COURSES"+TAB+"Pork ribs"
    树视图添加TREE_MENU1"DESSERTS"
    树视图添加TREE_MENU1"DESSERTS"+TAB+"Caramel custard"
    树视图添加TREE_MENU1"DESSERTS"+TAB+"Chocolate cream"
    树视图添加TREE_MENU1"DESSERTS"+TAB+"Tiramisu"
    树视图添加TREE_MENU1"DESSERTS"+TAB+"Ice cream"
    树视图添加TREE_MENU1"DESSERTS"+TAB+"Apple pie"
    // Enable the programmed Drag and Drop
    TREE_MENU1..鼠标拖放源=鼠标拖放.程序
  2. Defining the target: TreeView table
    // -- Initializing the TreeView Table control
    TVT_MENU1..鼠标拖放目标=鼠标拖放.程序
  3. Adding processes specific to Drag and Drop into the code of the target control (code of TreeView Table control).
    • Display the processes of the TreeView Table control ("Code" from the popup menu of the control).
    • Click the different icons representing the Drag and Drop processes that must be added:
    • In our example, the processes to add are:
      • Rollover in target Drag/Drop (dndDragOver).
      • Drop in target Drag/Drop (dndDrop).
  4. Enter the code corresponding to the actions to perform:
    • Process for Drop in target Drag/Drop (dndDrop)
      // Only the move is allowed (not the copy)
      鼠标拖放接受鼠标拖放.移动

      sRoot字符串型
      sLeaf字符串型
      sElement字符串型
      sChild字符串型

      sElement树视图选择TREE_MENU1
      sRoot提取字符串sElement1TAB从头部
      sLeaf提取字符串sElement1TAB从尾部

      如果sLeafsRoot,那么
      如果表格查找子元素COL_TREE1sRoot)=-1,那么
      表格添加子行TVT_MENU10sRoot
      结束

      sChild树视图获取子元素TREE_MENU1sRoot树视图.第一个
      只要sChild不等于""
      表格添加子行TVT_MENU1sRootsChild
      sChild树视图获取子元素TREE_MENU1sRoot树视图.下一个
      结束
      否则
      如果表格查找子元素COL_TREE1sRoot)=-1,那么
      表格添加子行TVT_MENU10sRoot
      结束
      表格添加子行TVT_MENU1sRootsLeaf


      结束
    • Process for Rollover in target Drag/Drop (dndDragOver)
      // Cursor indicating the move
      鼠标拖放光标鼠标拖放.移动