| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 392 人关注过本帖
标题:求助:在透明窗体中画线会闪
只看楼主 加入收藏
seafish011
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:1
帖 子:167
专家分:694
注 册:2011-11-8
结帖率:90%
收藏
已结贴  问题点数:20 回复次数:2 
求助:在透明窗体中画线会闪
RT,尝试过在PICTUREBOX中实现同样的功能,但是也是一样会闪。
为什么在透明窗体中画线就会闪?有没有解决办法?
先谢谢各位啦!
下面附上代码(测试如下代码,需要添加Timer控件):
程序代码:
Option Explicit

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long

Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2
Private Const LWA_COLORKEY = &H1

Dim i As Integer

Private Sub Form_Load()
    Dim rtn As Long
    Me.BackColor = vbBlue
    Me.BorderStyle = 0
    rtn = GetWindowLong(hWnd, GWL_EXSTYLE)
    rtn = rtn Or WS_EX_LAYERED
    SetWindowLong hWnd, GWL_EXSTYLE, rtn
    SetLayeredWindowAttributes hWnd, vbBlue, 100, LWA_COLORKEY
    Timer1.Interval = 800
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
    i = i + 100
    Me.Cls
    Me.DrawWidth = 2
    Me.Line (0, 0)-(800, i), vbRed
    Me.DrawWidth = 9
    Me.PSet (300, 300), vbGreen
End Sub
搜索更多相关主题的帖子: color 
2013-12-01 01:28
bczgvip
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:66
帖 子:1310
专家分:5312
注 册:2009-2-26
收藏
得分:20 
程序代码:
Private Sub Timer1_Timer()
    i = i + 100
'    Me.Cls
    Me.DrawWidth = 2
    Me.Line (0, 0)-(800, i), vbblue, bf
    Me.Line (0, 0)-(800, i), vbRed
    Me.DrawWidth = 9
    Me.PSet (300, 300), vbGreen
End Sub
2013-12-01 20:57
seafish011
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:1
帖 子:167
专家分:694
注 册:2011-11-8
收藏
得分:0 
thank you 版主
2013-12-01 21:26
快速回复:求助:在透明窗体中画线会闪
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016831 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved