当前位置: 源码素材网 » VB教程 » 详情页

一个基于VB的制作渐变窗口背景色的模块

  •   时间:2019-02-08
  • 概述:渐变色

制作渐变的窗口背景色模块,必须在Form_paint事件中调用,调用示范:1、call formbc(me,0,0,255) 2、call formbc(me,0,255,0)
调用说明:1、制作蓝色过渡背景色 2、制作绿色过渡背景色:

Public Function formbc(formx As Form, colorr As Integer, colorg As Integer, colorb As Integer)
On Error Resume Next
Dim hbrush As Integer
Dim oldmode As Integer
Dim retval As Integer
Dim stepsize As Integer
Dim tpx As Integer
Dim fillarea As RECT
If colorr < 0 Then colorr = 0
If colorg < 0 Then colorg = 0
If colorb < 0 Then colorb = 0
If colorr > 255 Then colorr = 255
If colorg > 255 Then colorg = 255
If colorb > 255 Then colorb = 255
oldmode = formx.ScaleMode
formx.ScaleMode = 3
stepsize = 1 + formx.ScaleHeight / 480
fillarea.Left = 0
fillarea.Right = formx.ScaleWidth
fillarea.Top = 0
fillarea.Bottom = stepsize
For tpx = 1 To 480
  hbrush = CreateSolidBrush(RGB(colorr, colorg, colorb))
  retval = FillRect(formx.hdc, fillarea, hbrush)
  retval = DeleteObject(hbrush)
  colorr = colorr - 1
  colorg = colorg - 1
  colorb = colorb - 1
  If colorr < 0 Then colorr = 0
  If colorg < 0 Then colorg = 0
  If colorb < 0 Then colorb = 0
  fillarea.Top = fillarea.Bottom
  fillarea.Bottom = fillarea.Bottom + stepsize
Next tpx
formx.ScaleMode = oldmode
End Function

这是从一个VB窗口特效程序中整理出来的,或许不准确,仅供参考。

    相关声明:

      若“一个基于VB的制作渐变窗口背景色的模块”有损您的权益,请告之我们删除内容。
      部分文章来源于网络,版权归原作者所有。