📄 dynamic_list_control.class
字号:
/*
This class is to be used to manage dynamic lists associated with
dialog controls capable of using a dialog LIST. For a list to work,
the control must be associated with a list specified by the
"contents" directive. (ex. contents(SomeListName))
*/
*! version 1.0.0 25jan2005
version 9
class dynamic_list_control {
string dialogName // Name of the dialog box
string controlName // Name of the list control in dialog
string fullObjectReference // A string that holds the reference to the
// combined name of dialog and control
// (a combobox or listbox)
string listName // Name that class system is using for
// referencing the items in a control. This
// is the name specified by "contents"
string fullListReference // A string that holds the reference to the
// list maintained by the class system for a
// listbox or combobox
}
/****** Begin public methods *******/
program new
syntax , DIALOGname(string) CONTROLname(string)
.set, dialog(`dialogname') control(`controlname')
end
program set
syntax , DIALOGname(string) CONTROLname(string)
.dialogName = `"`dialogname'_dlg"'
.controlName = `"`controlname'"'
.fullObjectReference = "`dialogname'_dlg.`controlname'"
.listName = .`.fullObjectReference'.contents
.fullListReference = "`.dialogName'.`.listName'"
/*
If a dummy list was defined in the dialog we use it, otherwise
we create a list here, and attach it to the specified dialog
object. The name is obtained by contents(LIST_NAME), specified
by the dialog control.
*/
local type "`.`.fullListReference'.isa'"
if "`type'" == "" {
.`.dialogName'.Declare array .`.listName'
}
._clearList
end
program setList
syntax [, NEWlist(string) VALUE(string) ]
._clearList
foreach item of local newlist {
._appendToList, item(`item')
}
local defaultString
foreach val of local value {
if index("`newlist'", "`val'") { // is value in the list
local defaultString `defaultString' `val'
}
}
.`.fullObjectReference'.setvalue "`defaultString'"
end
program getLength
class exit `.`.fullListReference'.arrnels'
end
program print
display "dialogName : `.dialogName'"
display "controlName : `.controlName'"
display "listName : `.listName'"
display "fullObjectReference: `.fullObjectReference'"
display "fullListReference : `.fullListReference'"
display "length : `.getLength'"
display _newline
end
/******* End public methods *******/
/******* Begin private methods *******/
program _appendToList
syntax , item(string)
// WE MUST KEEP THE GUI CONTROL AND THE CLASS SYSTEM IN SYNC
// append the items to the groupbox
.`.fullObjectReference'.additem `item'
// append the items to the list maintained by the class system
.`.fullListReference'.Arrpush `item'
end
program _clearList
// WE MUST KEEP THE GUI CONTROL AND THE CLASS SYSTEM IN SYNC
.`.fullListReference'.Arrdropall
.`.fullObjectReference'.clearlist
end
/******* End private methods *******/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -