社区
VB
帖子详情
VB6的Form的AutoRedraw功能,VB.net有啥对应的函数吗
zyq654321
2017-03-07 09:41:48
一个VB6移植到VS2012的课题,原来是用Form的AutoRedraw的,VB.net不知道用啥替换好
...全文
183
1
打赏
收藏
VB6的Form的AutoRedraw功能,VB.net有啥对应的函数吗
一个VB6移植到VS2012的课题,原来是用Form的AutoRedraw的,VB.net不知道用啥替换好
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
1 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
Tiger_Zhao
2017-03-07
打赏
举报
回复
[Quote=引用 MSDN:]
图形(针对 Visual Basic 6.0 用户)
AutoRedraw 属性不再被支持,并且不是必需的,因为 Paint 和 Draw 事件可以自动保持图形。[/Quote]
不用替换。你可以认为现在全部是AutoRedraw的了。
比较简单的VB透明窗体实现方法.rar
这是一个相对简单的VB制作透明 窗体的方法,看上去这个窗体无边框、无标题栏,也没有最小最大化及关闭按钮,完全显示了一个图片的效果,其实本代码是一个透明窗体的实现实例,特此为大家分享代码如下: Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, _ ByVal nWidth As Long, ByVal nHeight As Long) As Long 'API
函数
声明 Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, _ ByVal hObject As Long) As Long'API
函数
声明 Private Sub
Form
_Load() Dim B'声明变量 Me.
Auto
Re
draw
= True B = CreateCompatibleBitmap(Me.hdc, 0, 0) SelectObject Me.hdc, B'设置窗体透明 End Sub Private Sub Image1_Click() End '退出 End Sub Private Sub Timer1_Timer() '计时器事件 Dim B '声明变量 Me.
Auto
Re
draw
= True B = CreateCompatibleBitmap(Me.hdc, 0, 0) SelectObject Me.hdc, B'保持窗体透明 End Sub
vb 小程序(别人的)
Option Explicit '
函数
声明 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 bRe
draw
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 Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Const RGN_OR = 2 Dim I As Integer, j, myint, linex As Integer Dim Fullr, myColor, crn As Long Dim Region, PicWidth, PicHeight As Long Dim mystart, mybool As Boolean Private Sub
Form
_Load() Dim hDC As Long Me.Width = Picture1.Width '设置窗体宽度等于图形宽度 Me.Height = Picture1.Height '设置窗体宽度等于图形宽度 Picture1.ScaleMode = vbPixels '设置Picture1度量单位为像素 Picture1.
Auto
Re
draw
= True '设置Picture1自动重绘有效 Picture1.
Auto
Size = True '设置Picture1自动调整大小 Picture1.BorderStyle = vbBSNone '设置Picture1的边框样式 Me.BorderStyle = vbBSNone '设置窗体的边框样式 hDC = Picture1.hDC mystart = True mybool = False I = 0 j = 0 PicWidth = Picture1.ScaleWidth PicHeight = Picture1.ScaleHeight linex = 0 myColor = GetPixel(hDC, 0, 0) '获取picture1指定像素的rgb值 For j = 0 To PicHeight - 1 For I = 0 To PicWidth - 1 If GetPixel(hDC, I, j) = myColor Or I = PicWidth Then '透明像素 If mybool Then mybool = False crn = CreateRectRgn(linex, j, I, j - 1) '创建矩形区域 If mystart Then Fullr = crn mystart = False Else CombineRgn Fullr, Fullr, crn, RGN_OR '合并区域 DeleteObject CreateRectRgn(linex, j, I, j - 1) '删除透明区域 End If End If Else '非透明像素 If Not mybool Then mybool = True linex = I End If End If Next Next Region = Fullr SetWindowRgn Me.hWnd, Region, True '设置窗体区域 myint = 0 End Sub Private Sub Timer1_Timer() '形成动画 Dim hDC As Long myint = myint + 1 If myint = 1 Then Set Picture1.Picture = LoadPicture(App.Path & "\sz3.bmp") If myint = 2 Then Set Picture1.Picture = LoadPicture(App.Path & "\sz4.bmp") If myint = 3 Then Set Picture1.Picture = LoadPicture(App.Path & "\sz5.bmp") If myint = 4 Then Set Picture1.Picture = LoadPicture(App.Path & "\sz6.bmp") If myint = 5 Then myint = 0 hDC = Picture1.hDC mystart = True mybool = False I = 0 j = 0 Me.Width = Picture1.Width Me.Height = Picture1.Height PicWidth = Picture1.ScaleWidth PicHeight = Picture1.ScaleHeight linex = 0 myColor = GetPixel(hDC, 0, 0) '获取picture1指定像素的rgb值 For j = 0 To PicHeight - 1 For I = 0 To PicWidth - 1 If GetPixel(hDC, I, j) = myColor Or I = PicWidth Then '透明像素 If mybool Then mybool = False crn = CreateRectRgn(linex, j, I, j - 1) '创建矩形区域 If mystart Then Fullr = crn mystart = False Else CombineRgn Fullr, Fullr, crn, RGN_OR '合并区域 DeleteObject CreateRectRgn(linex, j, I, j - 1) '删除透明区域 End If End If Else '非透明像素 If Not mybool Then mybool = True linex = I End If End If Next Next Region = Fullr SetWindowRgn Me.hWnd, Region, True '设置窗体区域 End Sub Private Sub Picture1_Click() End End Sub
VB6
.0和
VB.Net
的
函数
等对照表
VB6
.0和
VB.Net
的对照表
VB6
.0
VB.NET
AddItem Object名.AddItem Object名.Items.Add ListBox1.Items.Add ComboBox1.Items.Add Abs
函数
System.Math.Abs 方法 API
函数
关系 Microsoft Win32和Microsoft .NET Fra...
VB6
.0和
VB.Net
的
函数
对照表
VB6
.0和
VB.Net
的
函数
对照表
VB6
.0
VB.NET
AddItem Object名.AddItemObject名.Items.Add ListBox1.Items.Add ComboBox1.Items.AddAbs
函数
System.Math.Abs 方法
【
VB.NET
】如何在窗体上画画?
哈里最近在使用
vb.net
中,遇到很多问题。其中有一个是.net窗体上的绘制问题。 在
vb6
中,可以很简单的在窗体上画画,通过设置窗体的
auto
re
draw
属性还可以保持绘制的图形不会因为窗体超出屏幕边界等情况消失。 那.net里面如何画画能让窗体不消失,并且能用timer时钟控件做出动画一般的效果呢? 例如下面这样: Public Class
Form
1 Private x As Single = 100, y As Single = 50, x2 As Single = 300 Priva
VB
16,547
社区成员
110,525
社区内容
发帖
与我相关
我的任务
VB
VB技术相关讨论,主要为经典vb,即VB6.0
复制链接
扫一扫
分享
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章