精华内容
下载资源
问答
  • 尝试将VB.NET自定义控件的背景设置透明,且不遮住下面的控件
  • VB.NET 实现自定义控件的透明背景

    千次阅读 2011-01-23 12:18:00
    VB.NET 2010 开发自定义控件时,需要设置背景透明的方法如下图:

    VB.NET 2010 开发自定义控件时,需要设置其背景透明的方法如下图:

     

    VB.NET 实现自定义控件的透明背景

    展开全文
  • 当使用manifast文件使VB6做出程序支持XP主题时,会发现由于VB内置控件的背景大多数不能设置透明,而导致选项卡上控件上放置的控件非常不协调。该资源就是为了解决这个问题自定义控件示例源码,感谢Jottum。
  • 2.还有一种透明方法是截取被窗口矩形覆盖区域,将其获取为一个bitmap然后赋值给窗口当背景!但是直接赋值也不行,里面有个小技巧。这种方法比直接设置opcity效果强太多了,几乎达到真正透明了!只剩控件!但是和第...
  • 一个美化窗体的VB程序源,可以改变窗体背景图片和纯颜色,对背景图片进行添加、删除、淡化,窗体透明设置控件开源有很多地方值得VB爱好者研究学习,每一块代码都有中文注译,思路清晰易懂,对开发换肤程序有...
  • 将目标PictureBoxBackColor设置为白色,再调用ShapeMe RGB(255, 255, 255), True, , PictureBox ,就可以让名称为PictureBox PictureBox 控件背景透明   '===================================...

    将目标PictureBox的BackColor设置为白色,再调用ShapeMe RGB(255, 255, 255), True, , PictureBox ,就可以让名称为PictureBox 的PictureBox 控件背景透明

     

    '========================================
    '声明作用:透明化PictureBox,注意设置其背景颜色为纯白
    '========================================
    Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
    Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
    Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
    Private Declare Sub ReleaseCapture Lib "user32" ()
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    Private Const RGN_DIFF = 4
    Dim CurRgn As Long, TempRgn As Long  ' Region variables
     
    '========================================
    '函数名称:ShapeMe
    '函数作用:透明化PictureBox背景
    '========================================
    Public Sub ShapeMe(Color As Long, HorizontalScan As Boolean, Optional Name1 As Form = Nothing, Optional Name2 As PictureBox = Nothing)
      
        Dim X As Integer, Y As Integer 'points on form
       Dim dblHeight As Double, dblWidth As Double 'height and width of object
       Dim lngHDC As Long 'the hDC property of the object
       Dim booMiddleOfSet As Boolean 'used during the gathering of transparent points
       Dim colPoints As Collection 'this will hold all usrPoints
       Set colPoints = New Collection
        Dim Z As Variant 'used during iteration through collection
       Dim dblTransY As Double 'these 3 variables hold each point that will be made transparent
       Dim dblTransStartX As Double
        Dim dblTransEndX As Double
        Dim Name As Object 'will hold the name of the object.  Late-bound and slower, but allows different types (in this case Form or PictureBox)
      
        'check out the name or names passed into the subroutine
       If Name1 Is Nothing Xor Name2 Is Nothing Then 'we know there is a name in one of them
           If Name1 Is Nothing Then 'set the name
               Set Name = 界面上的PictureBox控件
            Else
               Set Name = 界面上的PictureBox控件
            End If
        Else 'both or none hold valid names
           MsgBox "Must pass in the name of either a Form OR a PictureBox.  TransForm received NONE or BOTH.  Function failed.", vbOKOnly, "ShapeMe Subroutine"
            Exit Sub
        End If
      
        'initialization
       With Name
            .AutoRedraw = True 'object must have this setting
           .ScaleMode = 3 'object must have this setting
           lngHDC = .hdc 'faster to use a variable; VB help recommends using the property, but I didn't encounter any problems
           If HorizontalScan = True Then 'look for lines of transparency horizontally
               dblHeight = .ScaleHeight 'faster to use a variable
               dblWidth = .ScaleWidth 'faster to use a variable
           Else 'look vertically (note that the names "dblHeight" and "dblWidth" are non-sensical now, but this was an easy way to do this
               dblHeight = .ScaleWidth 'faster to use a variable
               dblWidth = .ScaleHeight 'faster to use a variable
           End If 'HorizontalScan = True
       End With
        booMiddleOfSet = False
      
        'gather all points that need to be made transparent
       For Y = 0 To dblHeight  ' Go through each column of pixels on form
           dblTransY = Y
            For X = 0 To dblWidth  ' Go through each line of pixels on form
               'note that using GetPixel appears to be faster than using VB's Point
               If TypeOf Name Is Form Then 'check to see if this is a form and use GetPixel function which is a little faster
                   If GetPixel(lngHDC, X, Y) = Color Then  ' If the pixel's color is the transparency color, record it
                       If booMiddleOfSet = False Then
                            dblTransStartX = X
                            dblTransEndX = X
                            booMiddleOfSet = True
                        Else
                            dblTransEndX = X
                        End If 'booMiddleOfSet = False
                   Else
                        If booMiddleOfSet Then
                            colPoints.Add Array(dblTransY, dblTransStartX, dblTransEndX)
                            booMiddleOfSet = False
                        End If 'booMiddleOfSet = True
                   End If 'GetPixel(lngHDC, X, Y) = Color
               ElseIf TypeOf Name Is PictureBox Then 'if a PictureBox then use Point; a little slower but works when GetPixel doesn't
                   If Name.Point(X, Y) = Color Then
                        If booMiddleOfSet = False Then
                            dblTransStartX = X
                            dblTransEndX = X
                            booMiddleOfSet = True
                        Else
                            dblTransEndX = X
                        End If 'booMiddleOfSet = False
                   Else
                        If booMiddleOfSet Then
                            colPoints.Add Array(dblTransY, dblTransStartX, dblTransEndX)
                            booMiddleOfSet = False
                        End If 'booMiddleOfSet = True
                   End If 'Name.Point(X, Y) = Color
               End If 'TypeOf Name Is Form
              
            Next X
        Next Y
      
        CurRgn = CreateRectRgn(0, 0, dblWidth, dblHeight)  ' Create base region which is the current whole window
      
        For Each Z In colPoints 'now make it transparent
           TempRgn = CreateRectRgn(Z(1), Z(0), Z(2) + 1, Z(0) + 1)  ' Create a temporary pixel region for this pixel
           CombineRgn CurRgn, CurRgn, TempRgn, RGN_DIFF  ' Combine temp pixel region with base region using RGN_DIFF to extract the pixel and make it transparent
           DeleteObject (TempRgn)  ' Delete the temporary region and free resources
       Next
      
        SetWindowRgn Name.hwnd, CurRgn, True  ' Finally set the windows region to the final product
       'I do not use DeleteObject on the CurRgn, going with the advice in Dan Appleman's book:
       'once set to a window using SetWindowRgn, do not delete the region.
      
        Set colPoints = Nothing
      
    End Sub

    展开全文
  • VB控件属性使用大全

    2011-12-15 12:02:34
    控件具有很多相同属性,如标识控件名称Name属性、标识控件标题Caption属性、有效属性Enable、可见属性Visible、标识控件位置和大小Top、Left、Width、Height、属性、定义背景BackColor属性、定义前景色...
  • 此实例包含FileSystemWatcher类,clListBox背景透明,类重写,设置控件可以用透明背景Transparent,从不是创建控件“richTextBox1”线程访问它,利用线程解决方案,还有无边窗体移动方法,任务栏右侧通知显示...
  • 没有使用VB的标准控件,但使用了大量API函数,并加入了详细注释,附加属性页,操作简便,尤其适合API函数初学者学习研究使用。同时适合做MDI表单和childfrom表单背景,只要你选择合适图片和过滤色就可以对...
  • 在.Net环境下绘制矩形,椭圆形,三角形等形态窗体是件很简单事情,只要设置窗体的背景透明当你在窗体上绘制图形和控件时,是不会显示窗体,这点MSGDI+确实相比其他平台实现方式更加方便和简单。...
    在.Net环境下绘制矩形,椭圆形,三角形等形态的窗体是件很简单的事情,只要设置窗体的背景透明当你在窗体上绘制图形和控件时,是不会显示窗体的,这点MS的GDI+确实相比其他平台的实现方式更加方便和简单。



    设置方式也很简单,首先设置FORM的BackColor为一个程序中不常用的颜色,然后再设置FORM的TransparenceKey为这个颜色就OK了。





    参考VB.net代码



    Private Sub Form1_Load(ByVal sender As System.Object, _

    ByVal e As System.EventArgs) Handles MyBase.Load

    '设置背景

    Me.BackColor = Color.Black

    '设置透明

    Me.TransparencyKey = Color.Black

    end sub



    C#.net



    private void Form1_Load(object sender, EventArgs e)

    {

    this.BackColor = Color.Black

    this.TransparencyKey = Color.Black

    }


    --------------------------------------------------------------------------------------
    - 版权声明:
    - 如在本页面内无特别说明,本文内容均为[李大仁博客]原创,本文版权归[李大仁博客]所有。
    - 欢迎转载,转载请务必在文章页面明显位置提供原文链接并注明出处。欢迎您在转载本文时保留本段声明。
    - 文章标题:[.Net]设置背景透明的窗体,GDI+绘制异形WINFORM
    - 独立博客:李大仁博客
    - 永久链接:http://www.lidaren.com/archives/706
    --------------------------------------------------------------------------------------
    以上内容由博客自动发布工具自动发布,最终显示内容和效果会与原文内容有所偏差,敬请谅解。
    展开全文
  • VB上,flash的透明处理方便,只需修改flash控件shockwaveFlashWMode属性:wmode = Transparent,但是在C#中,这样设置,flash控件根本没反应!上网,百度、谷歌,搜搜搜!没有得到解决方案,但是搜到了一个控件 ...

    现在发现VB真的很方便,C#虽然也不错,但是对flash的处理,和一些控件的使用还是不如VB方便!在VB上,flash的透明处理方便,只需修改flash控件shockwaveFlash的WMode属性:wmode = Transparent,但是在C#中,这样设置,flash控件根本没反应!上网,百度、谷歌,搜搜搜!没有得到解决方案,但是搜到了一个控件 f_in_box_lib.dll!虽然知道它支持flash背景透明,但是只有一个控件在手,没有相关说明,相当于授之以鱼,而无渔!没办法,直接访问f_in_box官网http://www.f-in-box.com/dotnet/(f_in_box的.net版本),看了一下帮助!找到了相关的代码:

    分两步:

    1.  WMode = Transparent (在属性列表中设置)

    2. 响应f_in_box_lib的OnPaintStage事件,并添加代码

     if (f_in_box__lib.PaintStage.PrePaint == stage)
       {
        f_in_box__lib.f_in_box__control f_in_box__control = (f_in_box__lib.f_in_box__control)sender;

        using (Bitmap b = new Bitmap(Width, Height))
        {
         using (Graphics g = Graphics.FromImage(b))
         {
          PaintEventArgs pea = new PaintEventArgs(g, new Rectangle(f_in_box__control.Location, f_in_box__control.Size));

          this.OnPaintBackground(pea);
          this.OnPaint(pea);

          g.DrawImage(
           pictureBox1.Image,
           new Rectangle(pictureBox1.Location, pictureBox1.Size),
           new Rectangle(new Point(0, 0), pictureBox1.Image.Size),
           GraphicsUnit.Pixel);

          Canvas.DrawImage(
           b,
           new Rectangle(new Point(0, 0), f_in_box__control.Size),
           new Rectangle(f_in_box__control.Location, f_in_box__control.Size),
           GraphicsUnit.Pixel);
         }
        }
       }

    这样就实现了flash的背景透明!

    f_in_box官网实现了Demo下载,并附有源代码!如果上述步骤还不能帮助你的话,就到官网下载Demo!唯一的缺点就是下载速度忒慢!有时还达不到1kb/s!

    转载于:https://www.cnblogs.com/CPFlying/archive/2010/03/14/1685731.html

    展开全文
  • 然后在用户控件的界面上添加一个label一个image,同时将label1置为顶层(bring to front 反正让label1压着image1就行了) 然后将label1backstyle设为透明,usercontrolbackstyle也设为透明,image1strech...
  • 1,barsetup10.exe Office 97 工具栏(267KB) 2,ac35vb6.zip 界面控件,支持键盘、 MouseOvers 和定制图相等功能(950KB) 3,activeskin.zip 皮肤效果控件,给您应用程序加上漂亮皮肤(2524KB) ...
  • 1,barsetup10.exe Office 97 工具栏(267KB) 2,ac35vb6.zip 界面控件,支持键盘、 MouseOvers 和定制图相等功能(950KB) 3,activeskin.zip 皮肤效果控件,给您应用程序加上漂亮皮肤(2524KB) ...
  • 利用它,你可以抓下屏幕上任何东西(293KB) 49,URSample.ZIP 一个系统权限控制控件UserRight(113KB) 50,coolbutton.ZIP 具有IE风格按钮控件,可设置边框式样,背景 的透明特性,字体大小颜色(34...
  • 利用它,你可以抓下屏幕上任何东西(293KB) 49,URSample.ZIP 一个系统权限控制控件UserRight(113KB) 50,coolbutton.ZIP 具有IE风格按钮控件,可设置边框式样,背景 的透明特性,字体大小颜色(34...
  • 利用它,你可以抓下屏幕上任何东西(293KB) 49,URSample.ZIP 一个系统权限控制控件UserRight(113KB) 50,coolbutton.ZIP 具有IE风格按钮控件,可设置边框式样,背景 的透明特性,字体大小颜色(34...
  • 利用它,你可以抓下屏幕上任何东西(293KB) 49,URSample.ZIP 一个系统权限控制控件UserRight(113KB) 50,coolbutton.ZIP 具有IE风格按钮控件,可设置边框式样,背景 的透明特性,字体大小颜色(34...
  • 4、DGVPrint组件添加了报表头与报表尾内容的设置属性和参数; 5、DGVPrint与VB2008Print组件在以工资条方式打印表格时,添加了是否自动换行续打的功能(即,如果工资条列太多在一行中打印不下时,可以指定自动换行续...
  • 1、强大DataGridView打印功能,不仅可以以多种形式(普通打印、分栏打印、跨页打印、工资条打印)打印DGV表格,基本上能完全按DGV控件本身设置的格式如字体、字号、背景颜色、前景颜色、单元格对齐方式等打印出来...
  • 1、强大DataGridView打印功能,不仅可以以多种形式(普通打印、分栏打印、跨页打印、工资条打印)打印DGV表格,基本上能完全按DGV控件本身设置的格式如字体、字号、背景颜色、前景颜色、单元格对齐方式等打印出来...
  • 可以在面页中以半透明空心文字形式打印背景水印,只需要简单设置控件的WaterMarkText等几个以WaterMark开头属性即可,程序会自动打印水印。 3、PrintDGV函数可直接使用DGVPrint组件保存打印方案文件打印输出...
  • 可以换肤窗体VB源程序,这个例子中,我们可以为应用程序窗体设置背景图'片,这是通过在窗体上平铺图片实现,而你会发现'窗体上其他控件也变为透明,这是应用了控件集合 'Microsoft Forms2.0 Object Library...
  • 范例1-45 设置透明的任务栏 ∷相关函数:GetWindowLong SetWindowLong FindWindowSetLayeredWindowAttributes 范例1-46 在任务栏上隐藏运行程序图标 1.7 风格按钮 范例1-47 立体阴影按钮 范例1-48 炫彩立体...
  • 此实例包含FileSystemWatcher类,clListBox背景透明,类重写,设置控件可以用透明背景Transparent,从不是创建控件“richTextBox1”线程访问它,利用线程解决方案,还有无边窗体移动方法,任务栏右侧通知显示...
  • 6.2.1 编辑控件的通知消息 6.2.2 编辑控件消息 6.2.3 程序举例 6.3 列表框消息 6.3.1 列表框消息分类 6.3.2 列表框消息 6.3.3 列表框消息举例 6.4 组合框消息 6.4.1 组合框消息 6.4.2 组合框消息举例 ...
  • 1、强大DataGridView打印功能,不仅可以以多种形式(普通打印、分栏打印、跨页打印、工资条打印)打印DataGridView表格,基本上能完全按DataGridView控件本身设置的格式如字体、字号、背景颜色、前景颜色、单元格...
  • 属性设置丰富多样:条码高度,宽度,比例,颜色,背景颜色,透明度,大小,校验数位,消息显示,边界格式,加载模式,注释格式,图片对象。 XBarCodePro ATL ActiveX控件兼容系统: Windows 95/98/NT/2000/ME/XP...
  • VB编程资源大全

    2007-10-17 20:47:23
    trans.zip 建立透明的窗口(2KB) 113,lookview.zip LookView OCX(101KB) 114,weiqi101.zip 围棋控件(18KB) 115,proplist.zip PROPLIST(150KB) 116,freeocx.zip FreeOCX(44KB) 117...

空空如也

空空如也

1 2 3
收藏数 56
精华内容 22
关键字:

vb控件背景透明的设置