求助:在透明窗体中画线会闪
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