请教屏幕背景渐变以及数据库的问题

unix123 2000-04-14 09:31:00
我有两个问题向诸位VB高手请教:
1。我利用重画屏幕线条的方法实现了屏幕背景渐变,但是现在存在一个问题,
我能很明显地看到屏幕刷新的过程,这是不希望外界用户看到的,因此不
知道是否有解决的方法(有没有类似先写入内存再form1.show),源代码
如下:
Function getred(colorval As Long) As Integer
getred = colorval Mod 256
End Function
Function getgreen(colorval As Long) As Integer
getgreen = ((colorval And &HFF00FF00) / 256&)
End Function
Function getblue(colorval As Long) As Integer
getblue = ((colorval And &HFF0000) / (256& * 256&))
End Function

Private Sub Form_Resize()
Dim ipixel, pwidth As Integer
Dim redinc, greeninc, blueinc As Single
Dim color1 As Long, color2 As Long

color1 = RGB(64, 64, 64)
color2 = RGB(0, 0, 255)
startred = getred(color1)
endred = getred(color2)
startgreen = getgreen(color1)
endgreen = getgreen(color2)
startblue = getblue(color1)
endblue = getblue(color2)
pwidth = Form1.ScaleWidth
redinc = (endred - startred) / pwidth
greeninc = (endgreen - startgreen) / pwidth
blueinc = (endblue - startblue) / pwidth

For ipixel = 0 To pwidth - 1
newcolor = RGB(startred + redinc * ipixel, startgreen + greeninc
* ipixel, startblue + blueinc * ipixel)
Form1.Line (ipixel * 2, 0)-(ipixel * 2, Form1.Height - 1),
newcolor
Next

2。我使用data和data grid控件来显示foxpro的数据库table1.dbf,现在我需要显示
table1的子集,即利用条件限制部分记录,我应该怎样做?我试过
data1.recordsource="select * from table1 where field1>0"
data1.recordsource="field1>0"
都不行,错误为"找不到对象"
请高手指点,谢谢!!

...全文
88 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Un1 2000-04-14
  • 打赏
  • 举报
回复
Option Explicit
Dim lStep As Long

Dim startred As Long
Dim endred As Long
Dim startgreen As Long
Dim endgreen As Long
Dim startblue As Long
Dim endblue As Long

Function getred(colorval As Long) As Long
getred = colorval And &HFF
End Function
Function getgreen(colorval As Long) As Long
getgreen = ((colorval And &HFF00FF00) / 256&)
End Function
Function getblue(colorval As Long) As Long
getblue = ((colorval And &HFF0000) / (256& * 256&))
End Function

Private Sub Form_Load()

Dim color1 As Long, color2 As Long

color1 = RGB(64, 64, 64)
color2 = RGB(0, 0, 255)
startred = getred(color1)
endred = getred(color2)
startgreen = getgreen(color1)
endgreen = getgreen(color2)
startblue = getblue(color1)
endblue = getblue(color2)


lStep = Screen.TwipsPerPixelX
End Sub

Private Sub Form_Paint()
Dim pwidth As Integer
pwidth = ScaleWidth

Dim lr As Single
lr = startred
Dim lg As Single
lg = startgreen

Dim lb As Single
lb = startblue


Dim redinc As Single
redinc = (endred - lr) * lStep / pwidth
Dim greeninc As Single
greeninc = (endgreen - lg) * lStep / pwidth
Dim blueinc As Single
blueinc = (endblue - lb) * lStep / pwidth

Dim lh As Long
lh = ScaleHeight

Dim ipixel As Integer

Do Until ipixel > pwidth
Line (ipixel, 0)-(ipixel, lh), RGB(lr, lg, lb)
lr = lr + redinc
lg = lg + greeninc
lb = lb + blueinc
ipixel = ipixel + lStep
Loop

End Sub

Private Sub Form_Resize()
Refresh
End Sub

2: Data1.recordset.filter="field1 >0"

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧