段代码能画一个矩形,并自动填充渐变色,但只能填充黑色,谁能帮改一改用CommonDialog.Color来选择颜色。
Private Sub RectangleHorzShading() '渐变颜色
icn = 255 - cn
If icn < 0 Then icn = 0
If icn > 100 Then icn = 100picCanvas.Line (xs, ys)-(xp, yp), RGB(icn, icn, icn), B
If yp <> ys Then
zsn = 255 - rubcn
If zsn < 0 Then zsn = 0
If zsn > 255 Then zsn = 255
zdy = Abs((yp - (ys + 1)))
If zdy = 0 Then zdy = 0.02
zculsteps = (cn - rubcn) / zdy
For IY = ys + 1 To yp - 1 Step Sgn(yp - ys)
jsn = Int(zsn)
picCanvas.Line (xs + 1, IY)-(xp, IY), RGB(jsn, jsn, jsn)
zsn = zsn + zculsteps
If zsn > 255 Then zsn = 255: zculsteps = -zculsteps
If zsn < 1 Then zsn = 1: zculsteps = Abs(zculsteps)
Next IY
End If
End Sub
难道不会用颜色对话框:CommonDialog1.ShowColor