本技巧讲述了在PB脚本中创建12种行选择指示图标:包括颜色条、凸起的文本以及标准的PB行选择指示图标,函数中包括在运行时建立、删除、修改指示图标等功能。
/*-----------------------------------------------
FUNCTION:- boolean SetRfi(datawindow adw, int ai_rfi_cd)
PURPOSE/FUNCTIONALITY:- Create ColorBand or RaisedTextBand to serve as RowFocusIndicator for a Grid/Tabular DataWindow.
- Switch Off/Destroy previously created RowFocusIndicator
ARGUMENTS:- adw : datawindow reference- ai_rfi_cd : type of RowFocusIndicator to be set.
legal values: 0 to 120=Switch Off/Destroy
RETURNS:- bool. True=Successful, False=Failed
HOW TO USE?- Create this function as a window function or as a function
in a NVO with two arguments as under:1. datawindow adw ... by value2. integer ai_rfi_cd ... by value
and with boolean return- If created as a function/event of datawindow, arument-1 (adw) isnot required. (Use "This" in lieu of "adw")- Call it after dataobject is assigned to dataWindowControl.
- Function Call Example:This.SetRfi(dw, 7)
- if created as a window function and called from the window, assuming dataWindowControl is names as dw.
------------------------------------------------------------------------
Author: Rajnikant Puranik/Nov.8,1998email:puranik@bom2.vsnl.net.in
------------------------------------------------------------------------NO BAR ON USAGE*/
string ls_h, ls_err, ls_msg, ls_mod, ls_objstring ls_bg_colour //background colorlong ll_width //width of band
ll_width = Long(adw.Object.DataWindow.HorizontalScrollMaximum)
//ai_rfi_cd = Integer Code for type of SetRowFocusIndicatorCHOOSE CASE ai_rfi_cd CASE 0 //No RowFocusIndicator adw.SetRowFocusIndicator(Off!) //Destroy Previously created RowFocusIndicator Rectangle //named "rf_rect" ls_obj = adw.Object.DataWindow.Objects if Pos(ls_obj, "rf_rect") > 0 then ls_mod = "destroy rf_rect" ls_err = adw.Modify(ls_mod) if ls_err <> "" then ls_err = "Modify Error:" + ls_err PopulateError(-1, ls_err) goto lbl_err end if end if
CASE 1 adw.SetRowFocusIndicator(Hand!)
CASE 2 adw.SetRowFocusIndicator(FocusRect!)
CASE 4 to 11 /* CREATE COLORED BAND/RECTANGLE NAMED : rf_rect
It is preferable to define colors and other constants in a global NVO. e.g.: constant long LIGHT_YELLOW = RGB(255, 255, 200)
In case the NVO is named gc ("g" fot Global and "c" fot constants). then one could substitute below: ls_bg_colour = string(RGB(255, 255, 200)) by ls_bg_colour = string(gc.LIGHT_YELLOW)*/
CHOOSE CASE ai_rfi_cd CASE 4 ls_bg_colour = string(RGB(255, 255, 255)) //WHITE
CASE 5 ls_bg_colour = string(RGB(217, 217, 217)) //LIGHTER GRAY
CASE 6 ls_bg_colour = string(RGB(192, 192, 192)) //LIGHT GRAY
CASE 7 ls_bg_colour = string(RGB(255, 255, 200)) //LIGHT YELLOW
CASE 8 ls_bg_colour = string(RGB(255, 179, 217)) //LIGHT PINK
CASE 9 ls_bg_colour = string(RGB(140, 200, 200)) //LIGHT GREEN
CASE 10 ls_bg_colour = string(RGB(255, 211, 168)) //LIGHT ORANGE
CASE 11 ls_bg_colour = string(RGB(200, 255, 255)) //LIGHT BLUE
END CHOOSE ll_width += adw.width
//Create Rectangle String ls_mod = "Create Rectangle(band=detail" + & " x='" + string(adw.X) + "'" +& " y='0'" +& " height='80~t if(1=1, RowHeight(), 80)'" +& " width='" + string(ll_width) + "'" +& " name=rf_rect " +& " visible='1~t if(currentrow() = getrow(), 1, 0)'" +& " brush.hatch='6'" + & " brush.color='" + ls_bg_colour + "'" +& " pen.style='0'" +& " pen.width='5'" +& " pen.color='" + string(gc.BLACK) + "'" +& " background.mode='2'" +& " background.color='0'" +& ")"
CASE 12 if adw.VscrollBar then ll_width += adw.width - 130 else ll_width += adw.width - 20 end if //create string for raised text rectangle named : rf_rect ls_mod = "create text(band=Detail" +& " color='0'" +& " border='6'" +& " x='" + string(adw.X + 10) + "'" +& " y='0'" +& " height='80~t if(1=1, RowHeight() - 5, 80)'" +& " width='" + string(ll_width) + "'" +& " text=''" +& " name=rf_rect" +& " visible='1~t if(currentrow() = getrow(), 1, 0)'" +& " background.mode='2'" +& " background.color='12632256'" +& " )"
CASE ELSE ls_err = "Illegal Option: " + String(ai_rfi_cd) + " !" PopulateError(-1, ls_err) goto lbl_errEND CHOOSE
CHOOSE CASE ai_rfi_cd CASE 4 to 12 ls_err = adw.Modify(ls_mod)
if ls_err <> "" then ls_err = "Modify Error:" + ls_err PopulateError(-1, ls_err) goto lbl_err end if
if adw.SetPosition("rf_rect", "detail", FALSE) <> 1 then ls_err = "SetPosition Error." PopulateError(-1, ls_err) goto lbl_err end if END CHOOSE
return true
//-------------------------------------------------------------------lbl_err:
ls_msg = error.Text + ". " +&"Error/Msg No.=" + String(error.Number) + "; " +&"Window/Menu=" + error.WindowMenu + "; " +&"Object=" + error.Object + "; " +&"ObjectEvent=" + error.Object + "; " +&"Error Line No.=" + String(error.Line) + "."
MessageBox("Message/Error", ls_msg, Exclamation!)
return false
■完