PC SOFT

WINDEV的在线文档

  • Overview
  • Passing parameters to a window when it is opened
  • Returning a value when a window is closed
  • Running the test of a window with parameters
  • Notes
  • Parameters passed by value
  • Giving a default value to the parameter in the declaration
  • Scope of parameters
文档页面当前正在翻译。对于此延迟我们深表歉意。
您可以自愿地帮助我们翻译您想要的文档段落,然后只需通过以下地址与我们联系: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本地访问

Window with parameters

Overview
A window can:
  • Receive parameters when it is opened.
  • Return values when it is closed.
This window behaves like a procedure that may (or may not) return values.

This type of window can be useful in the following cases:

  • "calendar" windows (fix a default date when it is opened and return a selected date when it is closed),
  • search windows,
  • login windows that return the password entered, ...
This help page presents:
16版本和更高版本
WinDevLinux The windows with parameters are available for the WinDev applications in Linux.
16新版本
WinDevLinux The windows with parameters are available for the WinDev applications in Linux.
WinDevLinux The windows with parameters are available for the WinDev applications in Linux.

Passing parameters to a window when it is opened
To pass parameters to a window when it is opened:

1. Declare a procedure in the "Global declarations" process of the window. The name of this procedure and the name of the window must be identical. The parameters of this procedure correspond to the parameters that must be passed to the window.

Caution: The declaration of the procedure (PROCEDURE keyword) must correspond to the first line of the "Declaration process of global variables".

For example, the WIN_CALENDAR window is used to manage the selection of a date in a calendar. This window expects a parameter indicating the date to select.

// -- Global declarations of WIN_Calendar

过程WIN_CalendarsSelDate
//  sSelDate: date to select

This parameter can be handled from any process of the window (button, local procedures, ...).

For example, in the "Initialization" process of the WIN_Calendar window:

// -- Initialization of WIN_Calendar

// EDT_DateControl is an edit control
// It contains the value of the sSelDate parameter
EDT_DateControlsSelDate

2. Pass the parameter expected by the window when it is opened (打开, 打开子窗口, 打开同级窗口, MDI打开). For example, the BTN_Calendar button is used to open the WIN_Calendar window. Today's date is passed in parameter when this window is opened.2. Pass the parameter expected by the window when it is opened (打开, 打开移动窗口, 打开子窗口, 打开同级窗口, MDI打开). For example, the BTN_Calendar button is used to open the WIN_Calendar window. Today's date is passed in parameter when this window is opened.

// -- Click code of BTN_Calendar button

// Open the WIN_Calendar window
// Today's date is passed in parameter
打开WIN_Calendar今天())

Returning a value when a window is closed
To return a value when a window is closed:

1. Use ..返回值 in the processes that call 关闭.

For example, in the WIN_Calendar window, the BTN_OK button and the BTN_CANCEL button close the window once the value to return was initialized:

// -- Click on BTN_OK button (WIN_Calendar window)

// OK was clicked by the user,
// the date entered in the EDT_DateControl control is returned
我的窗口..返回值=EDT_DateControl
// Close the window
关闭()

// -- Click code of BTN_CANCEL (WIN_Calendar window)

// The BTN_CANCEL button was clicked by the user,
// an empty string is returned
我的窗口..返回值=""
// Close the window
关闭()

You also have the ability to use ..返回值 in the "Closing" process of the window:

// -- Closing code of WIN_Calendar window

// The date is entered in the EDT_DateControl control
如果EDT_DateControl"",那么
// No date was entered
我的窗口..返回值=""
否则
// A date is entered
我的窗口..返回值=EDT_DateControl
结束

2. Retrieve in a variable the value returned by the window when it was closed. This variable contains the result of 打开.

For example, the BTN_Calendar button is used to open the WIN_Calendar window. When opening this window (打开), today's date is passed in parameter. The value returned by the window when it is closed corresponds to the result returned by 打开. This result is retrieved in the ResultDate variable:

// -- Click code of BTN_Calendar button

// Open the WIN_Calendar window
// ResultDate is a string variable containing
// the value returned by the WIN_Calendar window
ResultDate打开WIN_Calendar今天())

// Study the result returned by the window
如果ResultDate"",那么
信息"No date was selected."
否则
信息"Selected date: "+日期转换为字符串ResultDate掩码.系统日期))
结束

The process of the BTN_CALENDAR button is stopped until the WIN_Calendar window is closed.

18版本和更高版本
Windows Store apps Special case: Value returned by a child window in a WinDev Mobile application
In the mobile applications, the windows are opened by 打开子窗口 (instead of 打开).

You can find out the value returned by a child window in the "Closing a child window" process of the window that opened the child window (the one that called 打开子窗口).

In the mobile applications, the windows are opened by 打开移动窗口 (or 打开子窗口) instead of 打开.

You can find out the value returned by a child window in the "Closing a child window" process of the window that opened the child window (the one that called 打开移动窗口 or 打开子窗口).

For example:
  • In the closing code of the child window, 关闭 is used to return a parameter:
    Close(""MyParameter
  • In the "Closing of a child window" process of the calling window, the name of the child window as well as the returned value can be retrieved by using the MyChildWindow keyword:
    // Close a child window
    NameChildWindowMyChildWindow..Name
    ValueChildWindowMyChildWindow..ReturnedValue
18新版本
Windows Store apps Special case: Value returned by a child window in a WinDev Mobile application
In the mobile applications, the windows are opened by 打开子窗口 (instead of 打开).

You can find out the value returned by a child window in the "Closing a child window" process of the window that opened the child window (the one that called 打开子窗口).

In the mobile applications, the windows are opened by 打开移动窗口 (or 打开子窗口) instead of 打开.

You can find out the value returned by a child window in the "Closing a child window" process of the window that opened the child window (the one that called 打开移动窗口 or 打开子窗口).

For example:
  • In the closing code of the child window, 关闭 is used to return a parameter:
    Close(""MyParameter
  • In the "Closing of a child window" process of the calling window, the name of the child window as well as the returned value can be retrieved by using the MyChildWindow keyword:
    // Close a child window
    NameChildWindowMyChildWindow..Name
    ValueChildWindowMyChildWindow..ReturnedValue
Windows Store apps Special case: Value returned by a child window in a WinDev Mobile application
In the mobile applications, the windows are opened by 打开子窗口 (instead of 打开).

You can find out the value returned by a child window in the "Closing a child window" process of the window that opened the child window (the one that called 打开子窗口).

In the mobile applications, the windows are opened by 打开移动窗口 (or 打开子窗口) instead of 打开.

You can find out the value returned by a child window in the "Closing a child window" process of the window that opened the child window (the one that called 打开移动窗口 or 打开子窗口).

For example:
  • In the closing code of the child window, 关闭 is used to return a parameter:
    Close(""MyParameter
  • In the "Closing of a child window" process of the calling window, the name of the child window as well as the returned value can be retrieved by using the MyChildWindow keyword:
    // Close a child window
    NameChildWindowMyChildWindow..Name
    ValueChildWindowMyChildWindow..ReturnedValue

Running the test of a window with parameters
To run the test of a window with parameters:
  1. Open the window with parameters in the window editor ("File .. Open").Open the window with parameters in the window editor: on the "首页" pane, in the "常规" group, click "打开".
  2. Click "Go" in the icon bar of WinDev (or press the [F9] key). The following window is displayed:Clickamong the quick access buttons (or press the [F9] key). The following window is displayed:
  3. Specify the value of the parameters that will be used to run the test of the window. To use the default value of the parameters, type the "*" character.
  4. Validate. The window is displayed according to the specified values.

Notes

Parameters passed by value

If the parameters passed to a window are modified in this window, these modifications will be taken into account in this window only. The value of these parameters is not modified in the calling process.

For example:

  1. The MyDate variable is declared in the code of the BTN_Calendar button. This variable contains today's date (for example: MyDate = Today()).
  2. This variable is passed in parameter to the WIN_Calendar window. The sSelDate parameter contains the value of the MyDate variable.
  3. The value of the sSelDate parameter is modified in the WIN_Calendar window (for example: sSelDate = "20020701").
  4. The value of the MyDate variable is not modified.

Giving a default value to the parameter in the declaration

A default value can be given to the parameters when declaring the parameters.

For example, to give a default value in the previous example, enter the following code in the "Global declarations" process of the WIN_Calendar window:

// -- Global declarations of WIN_Calendar

过程WIN_CalendarsSelDate"20030101"
//  sSelDate: date to select

Scope of parameters

The parameters passed to a window are global to all the processes of this window (initialization, code of a button, code of a local procedure, ...).
另见