Database 版 (精华区)

发信人: starstar (今天打老虎), 信区: Database
标  题: 在PB中使用Datawindow生成渐变色效果界面
发信站: 哈工大紫丁香 (2001年09月12日21:24:28 星期三), 站内信件

返回 主页 运行效果图: 采用在Datawindow中动态生成rectangle方法,用RGB函数计算
渐变色值。 下面是主要代码
  Gradient Create a gradient in the background of the specified datawindow
 using the specified colours. This function can be called multiple times as 
it deletes the old gradient before creating the new one, you might want to s
et redraw off before making the call.
  Integer:
1, Gradient created sucessfully -1, Gradient failed
  Public
adw_DW: Datawindow to create gradient
ai_width: Width for the gradient
as_band: DW Band to create the gradient in
ai_red: Red Value in range 0 - 255
ai_green: Green Value in range 0 - 255
ai_blue: Blue Value in range 0 - 255
lnc_Gradient.Gradient( dw_1, 255, 0 ,0 )  
   Integer
li_Red, li_Green, li_Blue, li_I, li_Y, li_Height
   Integer li_UY, li_UHeight
   Long ll_RGB
   String ls_Modify, ls_ModErr
IF ai_Red < 0 OR ai_Red > 255 THEN RETURN -1
IF ai_Green < 0 OR ai_Green > 255 THEN RETURN -1
IF ai_blue < 0 OR ai_Blue > 255 THEN RETURN -1
// Delete rectangles incase they have been painted before
FOR li_I = 1 TO cii_Segments ls_Modify += ' destroy rec_' + String( li_I )
NEXT
adw_DW.Modify( ls_Modify )
ls_Modify = ""
li_Red = ai_Red
li_Green = ai_Green
li_Blue = ai_Blue
li_Height = UnitsToPixels( Long( & adw_DW.Describe( "datawindow." + as_Band 
+ ".height" ) ), YUnitsToPixels! )
li_Height /= cii_Segments
// Create the modify string with all the lines
// in the DW so that they create the gradient.
FOR li_I = 1 TO cii_Segments
li_UY = PixelsToUnits( li_Y, YPixelsToUnits! )
li_UHeight = PixelsToUnits( li_Height, YPixelsToUnits! )
ll_RGB = RGB( li_Red, li_Green, li_Blue )
// Create the line
ls_Modify += ' create rectangle(band=' + as_Band + ' x="1" y="' + String( li
_UY ) + & '" height="' + String( li_UHeight ) + '" width="' + String( ai_Wid
th ) + & '" name=rec_' + String( li_I ) + ' brush.hatch="6" brush.color="' +
 & String( ll_RGB ) + '" pen.style="0" pen.width="5" pen.color="' + & String
( ll_RGB ) + '" background.mode="2" background.color="0" )'
// Do the counters
li_Y += li_Height li_Red -= ( 255 / cii_Segments ) IF li_Red < 0 THEN li_Red
 = 0 li_Green -= ( 255 / cii_Segments ) IF li_Green < 0 THEN li_Green = 0 li
_Blue -= ( 255 / cii_Segments ) IF li_Blue < 0 THEN li_Blue = 0 NEXT
// Apply the modify in one hit ls_ModErr = adw_DW.Modify( ls_Modify ) IF Len
( ls_ModErr ) > 0 THEN MessageBox( 'Error Adding Rectangles', ls_ModErr ) RE
TURN -1 END IF RETURN 1 

--
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: hfi.hit.edu.cn]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:5.015毫秒