国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

DataWindow Style幫你格式化數據窗口樣式

2024-07-21 02:13:29
字體:
來源:轉載
供稿:網友

datawindow style幫你格式化數據窗口樣式

作者:壞人張,發表時間:2004-9-19

      在使用datawindow時,通常我們都是手工在數據窗口畫板中來調整數據窗口對象的樣式(列寬、列高、標題、顏色等等)。但是在大型的應用中,往往會有眾多的數據窗口,而反復的手工去調整這些數據窗口會給我們的開發工作帶來極大的不便,即使耐心的一個一個地修改了數據窗口對象的樣式,也難免不能做到精確的統一,這樣即不符合功能復用的精神,也給系統的使用效果帶來一定的影響。

      為了很好的解決這一問題,特提出了此解決方案,此方案是專門針對grid類型的數據窗口的,在此基類中,通過代碼遍歷數據窗口的所有可視列,來改變列以及列標題的樣式,以及改變擁有下拉子數據窗口的列中的數據窗口的樣式,從而達到格式化數據窗口樣式的目的。

      你可以在以下的圖示中觀察到這一功能的最終效果:



 

圖1.datawindow style效果示例

      實現機制:

      1.首先要有一個數據窗口的基類,作為以后封裝各類數據窗口相關的特征代碼的容器。

      2.所有要格式化的dwobject的屬性均需設置為變量的形式,并為他們賦值。

      3.通過describe("datawindow.column.count") 函數來得到數據窗口的列數,并遍歷列,使用modify(" ")函數來實現改變dwobject其相關的屬性(例如:執行modify( "id_t .font.face='宋體'" )來改變id_t的字體 )。

      4.重復3的過程,但不同的是,這次遍歷的是子數據窗口的列,也就是datawindowchild對象,注意:別忘記了先判斷數據窗口是否擁有datawindowchild,有的話記住先得到他們。

      5.也是最后一步,你是否需要保存數據窗口的樣式呢?( 比如:保持同樣的列寬,下次再打開此窗口時可以保持與上次調整的列寬一樣。) 這里只是做了一個提醒,至于如何具體實現,本例中不做說明了,或許以后有專門講解系統配置方面的專題中再加以說明吧。

      主要代碼實現:

      1.變量的聲明:

         private:
         integer                   ii_style =  1            //默認樣式

         constant  integer    style_default = 1

         //style_default
         constant  string      colheader_fontcolor_default = "16777215"
         constant  string      colheader_bgcolor_default = "10040064"
         constant  string      col_bgcolor_default= "536870912~tif(mod(getrow(),2)=0,rgb(239,236,229),rgb(255,255,255))"

      2.主要函數:

      1)   integer of_getchild(ref datawindowchild adwc[])

            integer                  i, j, li_col_cnt
            integer                  li_ret
            string                    ls_col
            datawindowchild   ldwc_child[]

            li_col_cnt = integer( this.describe( "datawindow.column.count" ) )

            if li_col_cnt < 1 then return -1

            for i = 1 to li_col_cnt
                 ls_col = this.of_getcolumndisplayname( i )
                 li_ret = this.getchild( ls_col, ldwc_child[i] )
                 if li_ret = 1 then
                    j++
                    this.getchild( ls_col, adwc[j] )
                 end if
            next

            return j

      2)   string of_getcolumndisplayname(integer ai_colnumber)

            string ls_colname

            ls_colname = this.describe ("#" + string (ai_colnumber) + ".name")
            if ls_colname = " " or ls_colname = "!" then
               return "!"
            end if

            return of_getcolumndisplayname (ls_colname)

      3)   string of_getcolumndisplayname(string as_colname)

            string ls_coldisplayname

            ls_coldisplayname = this.describe (as_colname + ".name")

            return ls_coldisplayname

      4)   string of_getheadername(string as_column)

            string ls_defaultheadersuffix = "_t"
            string   ls_colhead

            ls_colhead = as_column + ls_defaultheadersuffix

            return ls_colhead

      5)   string of_getheadertext(string as_column)

            string ls_defaultheadersuffix = "_t"
            string   ls_colhead

            ls_colhead = this.describe ( as_column + ls_defaultheadersuffix + ".text" )
            if ls_colhead = "!" then
              //no valid column header, use column name.
              ls_colhead = as_column
            end if

            return ls_colhead

      6)   integer of_setstyle(integer ai_style)

            integer          i, j
            integer          li_column_cnt                  //列數
            string           ls_column_name               //列名
            string           ls_column_width               //列寬
            string           ls_child_column_name      //子數據窗口列名
            string           ls_column_headername     //列標題
            string           ls_colheader_fontcolor      //列標題字體顏色
            string           ls_colheader_bgcolor        //列標題背景顏色
            string           ls_col_bgcolor                  //列背景顏色
            datawindowchild  ldwc_child[]             //子數據窗口

            choose case ai_style
             case 1
              ls_colheader_fontcolor = colheader_fontcolor_default
              ls_colheader_bgcolor = colheader_bgcolor_default
              ls_col_bgcolor = col_bgcolor_default
             case else
              ls_colheader_fontcolor = colheader_fontcolor_default
              ls_colheader_bgcolor = colheader_bgcolor_default
              ls_col_bgcolor = col_bgcolor_default  
            end choose

            //禁止列移動
            this.modify("datawindow.grid.columnmove=no")
            //禁止鼠標全選擇
            this.modify("datawindow.selected.mouse=no")
            //調整列以及列標題
            li_column_cnt = integer( this.describe("datawindow.column.count") )

            for i = 1 to li_column_cnt
              //調整列樣式
              ls_column_name = this.of_getcolumndisplayname( i )

              this.modify( ls_column_name + ".font.face='宋體'" )
              this.modify( ls_column_name + ".font.height='-9'" )
              this.modify( ls_column_name + ".y='4'" )
              this.modify( ls_column_name + ".height='56'")
              this.modify( ls_column_name + ".background.mode='0'" )
              this.modify( ls_column_name + ".background.color='" + ls_col_bgcolor + "'" )
              //調整列標題樣式
              ls_column_headername = this.of_getheadername( ls_column_name )

              this.modify( ls_column_headername + ".color='" + ls_colheader_fontcolor + "'" )
              this.modify( ls_column_headername + ".font.face='arial'" )
              this.modify( ls_column_headername + ".font.height='-9'" )
              this.modify( ls_column_headername + ".y='0'" )
              this.modify( ls_column_headername + ".height='68'")
              this.modify( ls_column_headername + ".background.mode='0'" )
              this.modify( ls_column_headername + ".background.color='" + ls_colheader_bgcolor + "'")
            next

            //帶區樣式
            this.modify("datawindow.header.height='68'")
            this.modify("datawindow.detail.height='68'")
            this.modify("datawindow.footer.height='40'")

            //this.modify("datawindow.footer.color= '" + ls_colheader_bgcolor + "'")

            //調整datawindowchild樣式
            this.of_getchild( ldwc_child[] )

            for i = 1 to upperbound( ldwc_child )
              if isvalid( ldwc_child[i] ) then
                 ldwc_child[i].settransobject( sqlca )
                 //禁止列移動
                 ldwc_child[i].modify("datawindow.grid.columnmove=no")
                 //禁止鼠標全選擇
                 ldwc_child[i].modify("datawindow.selected.mouse=no")
                 //調整表頭高度為0
                 ldwc_child[i].modify("datawindow.header.height='0'")
                 //調整數據區高度
                 ldwc_child[i].modify("datawindow.detail.height='68'")
                 //datawindowchild的列數
                 li_column_cnt = integer( ldwc_child[1].describe("datawindow.column.count") )
                 //調整datawindowchild的列樣式
                 for j = 1 to li_column_cnt
                       //調整列樣式
                       ls_child_column_name = ldwc_child[i].describe ("#" + string (j) + ".name")
    
                       if ls_child_column_name = " " or ls_child_column_name = "!" then
                       ls_child_column_name = ''
              else
                 ls_child_column_name = ldwc_child[i].describe ( ls_child_column_name + ".name" )
              end if
    
              ldwc_child[i].modify( ls_child_column_name + ".font.face='宋體'" )
              ldwc_child[i].modify( ls_child_column_name + ".font.height='-9'" )
              ldwc_child[i].modify( ls_child_column_name + ".y='4'" )
              ldwc_child[i].modify( ls_child_column_name + ".height='56'")
              ldwc_child[i].modify( ls_child_column_name + ".background.mode='0'" )
             ldwc_child[i].modify( ls_child_column_name + ".background.color='" + ls_col_bgcolor + "'" )
            next
          end if
         next

         return 1

      至此,已經為你詳細介紹了如何實現利用代碼來統一數據窗口樣式的方法,你只需要加入到你的基類中即可,如果有任何疑問或者更好的方法,歡迎與我聯系!

 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 四会市| 沙坪坝区| 丰都县| 米泉市| 阿拉善盟| 吕梁市| 英山县| 诏安县| 镇赉县| 彭水| 长岛县| 阜平县| 兴安盟| 永兴县| 温泉县| 收藏| 波密县| 平利县| 石渠县| 张家川| 赤城县| 罗甸县| 乐陵市| 龙海市| 晋宁县| 太仆寺旗| 庄浪县| 玉屏| 博野县| 普陀区| 鄢陵县| 资中县| 宕昌县| 柳州市| 郑州市| 金山区| 犍为县| 道真| 东阳市| 新密市| 溆浦县|