可视控件
progressbar 进度条
string ls_messages[]
of_SetFillStyle(LEFTRIGHT) 如何添冲进度条
of_SetDisplayStyle(MSGTEXT) 显示样式,消息文本(可以是数组或字符串),百分比进度
PCTCOMPLETE 完成百分比 xx%
POSITION 显示当前位置 50 不带百分号
BAR 进度条上无文本
ls_messages[1] = "Inspecting Application Dependencies..."
ls_messages[2] = "Opening File..."
ls_messages[3] = "Parsing Data..."
ls_messages[4] = "Deleting..."
ls_messages[5] = "Inserting..."
of_SetMessageText(ls_messages) 设置显示的内容
of_SetStep(1) 设置每次增加多少
of_SetMaximum(100) 进度条最小值
of_SetMinimum(0) 最大值
of_SetTextColor(RGB(255,255,255)) 进度条上文本修饰
of_SetFillColor(RGB(0,128,0))
of_SetFontBold(true) 颜色,粗体,斜体,下线
of_SetAutoReset(false) 自动
of_SetFontSize(10) 字体大小
of_setautoreset() 进度完成时是否清空显示(回到进度条初始时显示的样子,只是一个条没有进度有些难看)
一般设置为false
uo_1.of_SetPosition(0) 当前进度位置
of_Increment() 增加进度
状态栏
of_SetStatusBar(true) 开启服务
// In the exact order tell the service what to display.
inv_statusbar.of_Register('text_id', 'text', sle_modifytext.text, 400) 注册文本对象
inv_statusbar.of_Register('bitmap_id', 'bitmap', 'cdromtpt.bmp', 100) 注册图片对象
启用内置 工具
inv_statusbar.of_Setbar(true) 进度条
inv_statusbar.of_SetBarFillColor(255) 添冲颜色
inv_statusbar.of_SetBarDisplayStyle(inv_statusbar.PCTCOMPLETE) 按百分比显示进度
控制进度条增加
do
inv_statusbar.of_BarIncrement(1)
loop
inv_statusbar.of_SetMem(true) 可用内存
inv_statusbar.of_SetTimer(true) 日期
编辑工具栏上指定的内容
inv_statusbar.of_Modify('text_id', sle_modifytext.text)
inv_statusbar.of_Modify('bitmap_id', 'Harddriv.bmp')
u_lv 列表框
数据来源于datawindow
lv_1.of_SetDatasource("d_products", SQLCA, "description", "picture_name")
字段可以冲当 lable ,图片,状态,状态图片
// 将所有可见的列加到report列表中(report是列表的一种显式方式)
lv_1.of_AddColumns()
展开显示内容
lv_1.Post of_populate()
u_lvs
this.of_setdatasource(true) 启用数据源服务
this.of_setupdateable( false) 不更新该控件
this.of_setrmbmenu(true) 启用右键菜单
this.of_setsort(true) 启用排序服务
inv_sort.of_setcolumnheader(true) 设置排序时使用列的标题名来显示,而不是英文列显示
this.inv_datasource.of_setconfirmondelete(true) 删除提示
If lv_1.inv_datasource.of_Register("description", "d_products", SQLCA) < 0 Then 注册数据来源
MessageBox("Error", "Error in of_Register", Exclamation!)
End If
lv_1.inv_datasource.of_setpicturecolumn('picture_name') 图片列图片来源
lv_1.inv_datasource.of_registerreportcolumn( ) 启用将all 可见列加入到report 视图中
lv_1.event pfc_populate( ) 显示图片
需处理的自身事件
pfc_retrieve
any an[20]
return this.of_retrieve(an,ads)
自动更新,不需要额外代码
u_tvs服务
tv_1.of_SetLevelSource ( True ) 启动服务
tv_1.of_SetBase ( True ) 启动基本服务 (find结点基本操作)
tv_1.of_SetUpdateable ( True ) 设置控件是否可以更新
/* Register the tree levels to the datastore data,
and establish level pictures */
tv_1.inv_levelsource.of_Register ( 1, "sales_regions_region", "", "d_region", SQLCA, "" ) 注册数据来源
tv_1.inv_levelsource.of_SetPictureColumn ( 1, "1" ) //要显示图片的索引
tv_1.inv_levelsource.of_SetSelectedPictureColumn ( 1, "7" ) //设置选中时的图片
图片也可以使用 of_addpicture("")
tv_1.inv_levelsource.of_Register ( 2, "states_state_name", ":parent.1.sales_regions_region", "d_regionstate", SQLCA, "" )
tv_1.inv_levelsource.of_SetPictureColumn ( 2, "2" )
tv_1.inv_levelsource.of_SetSelectedPictureColumn ( 2, "7" )
tv_1.inv_levelsource.of_Register ( 3, "customer_company_name", ":parent.2.sales_regions_region, :parent.1.states_state_id", "d_regionstatecust", SQLCA, "" )
tv_1.inv_levelsource.of_SetPictureColumn ( 3, "3" )
tv_1.inv_levelsource.of_SetSelectedPictureColumn ( 3, "7" )
tv_1.inv_levelsource.of_Register ( 4, "employee_emp_lname", ":parent.1.customer_id", "d_regionstatecustrep", SQLCA, "" )
tv_1.inv_levelsource.of_SetPictureColumn ( 4, "4" )
tv_1.inv_levelsource.of_SetSelectedPictureColumn ( 4, "7" )
tv_1.inv_levelsource.of_Register ( 5, "order_id_string", ":parent.2.customer_id, :parent.1.employee_emp_id", "d_regionstatecustrepord", SQLCA, "" )
tv_1.inv_levelsource.of_SetPictureColumn ( 5, "5" )
tv_1.inv_levelsource.of_SetSelectedPictureColumn ( 5, "7" )
tv_1.inv_levelsource.of_Register ( 6, "product_description", ":parent.1.sales_order_id", "d_regionstatecustreporditm", SQLCA, "" )
tv_1.inv_levelsource.of_SetPictureColumn ( 6, "6" )
tv_1.inv_levelsource.of_SetSelectedPictureColumn ( 6, "7" )
显示数据
tv_1.Event pfc_populate ( 0 ) //0 句柄 顶层
/* Select the first item */
tv_1.SelectItem ( tv_1.inv_base.of_FindFirstItemLevel ( 1, 0 ) )
//selectitem(句柄)
tv_1.inv_levelsource.of_SetUpdateStyle ( 1 )
实现pfc_retrieve()事件
/* Retrieve the level data */
any la_args[20]
integer li_level
If IsValid ( inv_levelsource ) Then
li_level = of_GetNextLevel ( al_parent )
//取得下一层的级别
inv_levelsource.of_GetArgs ( al_parent, li_level, la_args )
//取当前层的参数
End If
根据参数进行检索(检索当前结点的所有子结点数据)
Return of_retrieve ( al_parent, la_args, ads_data )
selectionchanging event: 对选择的结点进行处理
n_ds lds_datastore
treeviewitem ltvi_item
int li_level
long ll_row
If newhandle > 0 Then
this.GetItem ( newhandle, ltvi_item )
li_level = ltvi_item.Level
// Ask for save if data has changed
this.event ue_update( li_level)
this.inv_levelsource.of_GetDataSource ( li_level, lds_datastore )
if inv_levelsource.of_GetDataRow(newhandle, lds_datastore, ll_row) = -1 then
MessageBox("Error", "Error in of_getdatarow", exclamation!)
Return
end if
lds_datastore.ReSelectRow ( ll_row ) //从数据库中重新读取数据
上面的部分是通用的 处理后结果存入lds_datastore中ll_row行中
dw_1.Event ue_RefreshView ( lds_datastore, ll_row )
End If
//
//
// Function: of_register
//
// Access: public
//
// Arguments:
// ai_Level The TreeView level to associate the data source with.
// as_LabelColumn The column in the DataWindow object to display.
// as_RetrieveArgs Retrieval/filter arguments for the level. These should
// be separated by commas in the format:
// :keyword.n.column
// where column is the name of a column in another level's
// data source. If keyword is 'level', n is an absolute level
// number. If keyword is 'parent', n is a number relative to
// the current level (i.e. :parent.2.c1 would be column c1 in
// the DataWindow for the level 2 levels above this one).
// ads_control The DataStore control to be used for the data source.
// as_FilterCols Columns on the datastore object used for filtering the datastore.
// This type of datasource does a retrieve once and uses the
// retrieval arguments to to filter out those records which do not
// match. The column names should be separated by commas.
// ex: "colname.NA, Col2name.NO, col3name"
// means "Not (Colname=xxx) And Not (col2name=xxx) Or col3name=xxx"
// ex: "colname.A, Col2name"
// means "Colname=xxx And col2name=xxx"
// xxx is the values provided by the retrieval args
// The columns will be the left side of the filter statement and the
// retrieval arguments are the right side (i.e. filtercol='retrieval args')
//
// Returns: integer
// 1 = the data source was added successfully
// -1 = argument validation error
// -2 = the DataWindow object did not have any key columns assigned
// -3 = a previous level had already been marked as recursive (there can be no more)
//
//
// Description: Register a datastore control as a data source for a level of the TreeView.
// The data source will be linked to the TreeView level and used
// to populate.
//
//
//
// Revision History
//
// Version
// 6.0 Initial version
//
//
//
// Copyright ?1996-1997 Sybase, Inc. and its subsidiaries. All rights reserved.
// Any distribution of the PowerBuilder Foundation Classes (PFC)
// source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//
树和列表框组合使用
树和数据窗口组合使用
更新树的原理 ,主要是更新datastore 和 树控件
of_SetRMBMenu(True)右键服务 有右键的控件都有该服务
progressbar 进度条
string ls_messages[]
of_SetFillStyle(LEFTRIGHT) 如何添冲进度条
of_SetDisplayStyle(MSGTEXT) 显示样式,消息文本(可以是数组或字符串),百分比进度
PCTCOMPLETE 完成百分比 xx%
POSITION 显示当前位置 50 不带百分号
BAR 进度条上无文本
ls_messages[1] = "Inspecting Application Dependencies..."
ls_messages[2] = "Opening File..."
ls_messages[3] = "Parsing Data..."
ls_messages[4] = "Deleting..."
ls_messages[5] = "Inserting..."
of_SetMessageText(ls_messages) 设置显示的内容
of_SetStep(1) 设置每次增加多少
of_SetMaximum(100) 进度条最小值
of_SetMinimum(0) 最大值
of_SetTextColor(RGB(255,255,255)) 进度条上文本修饰
of_SetFillColor(RGB(0,128,0))
of_SetFontBold(true) 颜色,粗体,斜体,下线
of_SetAutoReset(false) 自动
of_SetFontSize(10) 字体大小
of_setautoreset() 进度完成时是否清空显示(回到进度条初始时显示的样子,只是一个条没有进度有些难看)
一般设置为false
uo_1.of_SetPosition(0) 当前进度位置
of_Increment() 增加进度
状态栏
of_SetStatusBar(true) 开启服务
// In the exact order tell the service what to display.
inv_statusbar.of_Register('text_id', 'text', sle_modifytext.text, 400) 注册文本对象
inv_statusbar.of_Register('bitmap_id', 'bitmap', 'cdromtpt.bmp', 100) 注册图片对象
启用内置 工具
inv_statusbar.of_Setbar(true) 进度条
inv_statusbar.of_SetBarFillColor(255) 添冲颜色
inv_statusbar.of_SetBarDisplayStyle(inv_statusbar.PCTCOMPLETE) 按百分比显示进度
控制进度条增加
do
inv_statusbar.of_BarIncrement(1)
loop
inv_statusbar.of_SetMem(true) 可用内存
inv_statusbar.of_SetTimer(true) 日期
编辑工具栏上指定的内容
inv_statusbar.of_Modify('text_id', sle_modifytext.text)
inv_statusbar.of_Modify('bitmap_id', 'Harddriv.bmp')
u_lv 列表框
数据来源于datawindow
lv_1.of_SetDatasource("d_products", SQLCA, "description", "picture_name")
字段可以冲当 lable ,图片,状态,状态图片
// 将所有可见的列加到report列表中(report是列表的一种显式方式)
lv_1.of_AddColumns()
展开显示内容
lv_1.Post of_populate()
u_lvs
this.of_setdatasource(true) 启用数据源服务
this.of_setupdateable( false) 不更新该控件
this.of_setrmbmenu(true) 启用右键菜单
this.of_setsort(true) 启用排序服务
inv_sort.of_setcolumnheader(true) 设置排序时使用列的标题名来显示,而不是英文列显示
this.inv_datasource.of_setconfirmondelete(true) 删除提示
If lv_1.inv_datasource.of_Register("description", "d_products", SQLCA) < 0 Then 注册数据来源
MessageBox("Error", "Error in of_Register", Exclamation!)
End If
lv_1.inv_datasource.of_setpicturecolumn('picture_name') 图片列图片来源
lv_1.inv_datasource.of_registerreportcolumn( ) 启用将all 可见列加入到report 视图中
lv_1.event pfc_populate( ) 显示图片
需处理的自身事件
pfc_retrieve
any an[20]
return this.of_retrieve(an,ads)
自动更新,不需要额外代码
u_tvs服务
tv_1.of_SetLevelSource ( True ) 启动服务
tv_1.of_SetBase ( True ) 启动基本服务 (find结点基本操作)
tv_1.of_SetUpdateable ( True ) 设置控件是否可以更新
/* Register the tree levels to the datastore data,
and establish level pictures */
tv_1.inv_levelsource.of_Register ( 1, "sales_regions_region", "", "d_region", SQLCA, "" ) 注册数据来源
tv_1.inv_levelsource.of_SetPictureColumn ( 1, "1" ) //要显示图片的索引
tv_1.inv_levelsource.of_SetSelectedPictureColumn ( 1, "7" ) //设置选中时的图片
图片也可以使用 of_addpicture("")
tv_1.inv_levelsource.of_Register ( 2, "states_state_name", ":parent.1.sales_regions_region", "d_regionstate", SQLCA, "" )
tv_1.inv_levelsource.of_SetPictureColumn ( 2, "2" )
tv_1.inv_levelsource.of_SetSelectedPictureColumn ( 2, "7" )
tv_1.inv_levelsource.of_Register ( 3, "customer_company_name", ":parent.2.sales_regions_region, :parent.1.states_state_id", "d_regionstatecust", SQLCA, "" )
tv_1.inv_levelsource.of_SetPictureColumn ( 3, "3" )
tv_1.inv_levelsource.of_SetSelectedPictureColumn ( 3, "7" )
tv_1.inv_levelsource.of_Register ( 4, "employee_emp_lname", ":parent.1.customer_id", "d_regionstatecustrep", SQLCA, "" )
tv_1.inv_levelsource.of_SetPictureColumn ( 4, "4" )
tv_1.inv_levelsource.of_SetSelectedPictureColumn ( 4, "7" )
tv_1.inv_levelsource.of_Register ( 5, "order_id_string", ":parent.2.customer_id, :parent.1.employee_emp_id", "d_regionstatecustrepord", SQLCA, "" )
tv_1.inv_levelsource.of_SetPictureColumn ( 5, "5" )
tv_1.inv_levelsource.of_SetSelectedPictureColumn ( 5, "7" )
tv_1.inv_levelsource.of_Register ( 6, "product_description", ":parent.1.sales_order_id", "d_regionstatecustreporditm", SQLCA, "" )
tv_1.inv_levelsource.of_SetPictureColumn ( 6, "6" )
tv_1.inv_levelsource.of_SetSelectedPictureColumn ( 6, "7" )
显示数据
tv_1.Event pfc_populate ( 0 ) //0 句柄 顶层
/* Select the first item */
tv_1.SelectItem ( tv_1.inv_base.of_FindFirstItemLevel ( 1, 0 ) )
//selectitem(句柄)
tv_1.inv_levelsource.of_SetUpdateStyle ( 1 )
实现pfc_retrieve()事件
/* Retrieve the level data */
any la_args[20]
integer li_level
If IsValid ( inv_levelsource ) Then
li_level = of_GetNextLevel ( al_parent )
//取得下一层的级别
inv_levelsource.of_GetArgs ( al_parent, li_level, la_args )
//取当前层的参数
End If
根据参数进行检索(检索当前结点的所有子结点数据)
Return of_retrieve ( al_parent, la_args, ads_data )
selectionchanging event: 对选择的结点进行处理
n_ds lds_datastore
treeviewitem ltvi_item
int li_level
long ll_row
If newhandle > 0 Then
this.GetItem ( newhandle, ltvi_item )
li_level = ltvi_item.Level
// Ask for save if data has changed
this.event ue_update( li_level)
this.inv_levelsource.of_GetDataSource ( li_level, lds_datastore )
if inv_levelsource.of_GetDataRow(newhandle, lds_datastore, ll_row) = -1 then
MessageBox("Error", "Error in of_getdatarow", exclamation!)
Return
end if
lds_datastore.ReSelectRow ( ll_row ) //从数据库中重新读取数据
上面的部分是通用的 处理后结果存入lds_datastore中ll_row行中
dw_1.Event ue_RefreshView ( lds_datastore, ll_row )
End If
//
//
// Function: of_register
//
// Access: public
//
// Arguments:
// ai_Level The TreeView level to associate the data source with.
// as_LabelColumn The column in the DataWindow object to display.
// as_RetrieveArgs Retrieval/filter arguments for the level. These should
// be separated by commas in the format:
// :keyword.n.column
// where column is the name of a column in another level's
// data source. If keyword is 'level', n is an absolute level
// number. If keyword is 'parent', n is a number relative to
// the current level (i.e. :parent.2.c1 would be column c1 in
// the DataWindow for the level 2 levels above this one).
// ads_control The DataStore control to be used for the data source.
// as_FilterCols Columns on the datastore object used for filtering the datastore.
// This type of datasource does a retrieve once and uses the
// retrieval arguments to to filter out those records which do not
// match. The column names should be separated by commas.
// ex: "colname.NA, Col2name.NO, col3name"
// means "Not (Colname=xxx) And Not (col2name=xxx) Or col3name=xxx"
// ex: "colname.A, Col2name"
// means "Colname=xxx And col2name=xxx"
// xxx is the values provided by the retrieval args
// The columns will be the left side of the filter statement and the
// retrieval arguments are the right side (i.e. filtercol='retrieval args')
//
// Returns: integer
// 1 = the data source was added successfully
// -1 = argument validation error
// -2 = the DataWindow object did not have any key columns assigned
// -3 = a previous level had already been marked as recursive (there can be no more)
//
//
// Description: Register a datastore control as a data source for a level of the TreeView.
// The data source will be linked to the TreeView level and used
// to populate.
//
//
//
// Revision History
//
// Version
// 6.0 Initial version
//
//
//
// Copyright ?1996-1997 Sybase, Inc. and its subsidiaries. All rights reserved.
// Any distribution of the PowerBuilder Foundation Classes (PFC)
// source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//
树和列表框组合使用
树和数据窗口组合使用
更新树的原理 ,主要是更新datastore 和 树控件
of_SetRMBMenu(True)右键服务 有右键的控件都有该服务