如何在兼容 VBA 的 Sax Basic Engine 中为 OptionGroup 定义事件处理程序?
How do I define an event handler for an OptionGroup in VBA-compatible Sax Basic Engine?
我在 VBA 兼容的 Sax Basic Engine 的对话框中定义了以下 OptionGroup(嵌入用于在本地化应用程序 Passolo 中编写脚本):
Sub Main
.
.
Begin Dialog UserDialog 690,404,"Export and Import Text Files" ' %GRID:10,7,1,1
.
.
OptionGroup .ExportImport
OptionButton 30,77,190,14,"Export for translation",.optExport
OptionButton 20,221,190,14,"Import translations",.optImport
我想分配一个事件处理程序来捕获选择中的更改,以便我可以 enable/disable 对话框中的一些其他控件,具体取决于当前选择。
如何为选项组定义事件处理程序?它应该定义在 OptionGroup 级别还是 OptionButton 级别(即每个单选按钮的一个事件处理程序)?
在 Sax Basic/WinWrap Basic 中,据我所知,最接近事件处理程序的是 (dialogfunc) 原型。您的实施应处理 case 2
中 OptionGroup
值的更改:顶部单选按钮的 SuppValue 为 0。
下面示例中的 dialogfunc 将在您 select 单选按钮时将文本输出到 Passolo Messages window:
Sub Main
Begin Dialog UserDialog 690,404, "Export and Import Text Files",.ExpImpDlgFunct
OptionGroup .ExportImport
OptionButton 30,77,190,14,"Export for translation",.optExport
OptionButton 30,221,190,14,"Import translations",.optImport
OKButton 30,280,60,20
End Dialog
Dim dlg As UserDialog
Dialog dlg
End Sub
Private Function ExpImpDlgFunct(DlgItem$, Action%, SuppValue&) As Boolean
Select Case Action%
Case 1 ' Dialog box initialization
Case 2 ' Value changing or button pressed
If DlgItem = "ExportImport" Then
Select Case SuppValue
Case 0:
PSL.Output("Export")
Case 1:
PSL.Output("Import")
End Select
End If
Rem DlgFunc = True ' Prevent button press from closing the dialog box
Case 3 ' TextBox or ComboBox text changed
Case 4 ' Focus changed
Case 5 ' Idle
Rem DlgFunc = True ' Continue getting idle actions
Case 6 ' Function key
End Select
End Function
我在 VBA 兼容的 Sax Basic Engine 的对话框中定义了以下 OptionGroup(嵌入用于在本地化应用程序 Passolo 中编写脚本):
Sub Main
.
.
Begin Dialog UserDialog 690,404,"Export and Import Text Files" ' %GRID:10,7,1,1
.
.
OptionGroup .ExportImport
OptionButton 30,77,190,14,"Export for translation",.optExport
OptionButton 20,221,190,14,"Import translations",.optImport
我想分配一个事件处理程序来捕获选择中的更改,以便我可以 enable/disable 对话框中的一些其他控件,具体取决于当前选择。
如何为选项组定义事件处理程序?它应该定义在 OptionGroup 级别还是 OptionButton 级别(即每个单选按钮的一个事件处理程序)?
在 Sax Basic/WinWrap Basic 中,据我所知,最接近事件处理程序的是 (dialogfunc) 原型。您的实施应处理 case 2
中 OptionGroup
值的更改:顶部单选按钮的 SuppValue 为 0。
下面示例中的 dialogfunc 将在您 select 单选按钮时将文本输出到 Passolo Messages window:
Sub Main
Begin Dialog UserDialog 690,404, "Export and Import Text Files",.ExpImpDlgFunct
OptionGroup .ExportImport
OptionButton 30,77,190,14,"Export for translation",.optExport
OptionButton 30,221,190,14,"Import translations",.optImport
OKButton 30,280,60,20
End Dialog
Dim dlg As UserDialog
Dialog dlg
End Sub
Private Function ExpImpDlgFunct(DlgItem$, Action%, SuppValue&) As Boolean
Select Case Action%
Case 1 ' Dialog box initialization
Case 2 ' Value changing or button pressed
If DlgItem = "ExportImport" Then
Select Case SuppValue
Case 0:
PSL.Output("Export")
Case 1:
PSL.Output("Import")
End Select
End If
Rem DlgFunc = True ' Prevent button press from closing the dialog box
Case 3 ' TextBox or ComboBox text changed
Case 4 ' Focus changed
Case 5 ' Idle
Rem DlgFunc = True ' Continue getting idle actions
Case 6 ' Function key
End Select
End Function