满意答案
nan6718
2014.07.08
采纳率:53% 等级:12
已帮助:8369人
我原来写的一个缩屏的程序,后来没用,当时只是为了测试透明窗体的.代码给你参考下。功能差一个禁用任务管理器的功能
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 GRB_Alpha As Integer
Dim rtn As Long
Private Sub Command1_Click()
GRB_Alpha = GRB_Alpha - 5
If GRB_Alpha < 5 Then
GRB_Alpha = 5
End If
Label1.Caption = "Alphaֵ" & GRB_Alpha
rtn = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED
SetWindowLong hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes hwnd, 0, GRB_Alpha, LWA_ALPHA
End Sub
Private Sub Command2_Click()
GRB_Alpha = GRB_Alpha + 5
If GRB_Alpha > 255 Then
GRB_Alpha = 255
End If
Label1.Caption = "Alphaֵ" & GRB_Alpha
rtn = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED
SetWindowLong hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes hwnd, 0, GRB_Alpha, LWA_ALPHA
End Sub
Private Sub Form_DblClick()
frmLogin.Show
End Sub
Private Sub Form_Load()
Form1.Width = Screen.Width
Form1.Height = Screen.Height
GRB_Alpha = 200
Label1.Caption = "Alphaֵ" & GRB_Alpha
Form1.BackColor = &H80C0FF
Label1.BackColor = &H80C0FF
rtn = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED
SetWindowLong hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes hwnd, 0, GRB_Alpha, LWA_ALPHA
End Sub
Private Sub Form_Unload(Cancel As Integer)
Unload Me
End Sub
登陆窗口的代码
Option Explicit
Public LoginSucceeded As Boolean
Private Sub cmdCancel_Click()
'设置全局变量为 false
'不提示失败的登录
LoginSucceeded = False
Me.Hide
End Sub
Private Sub cmdOK_Click()
'检查正确的密码
If txtPassWord1.Text = "" Or txtPassword.Text = "" Then
Label1.Caption = "密码不能为空"
End
End If
If txtPassWord1.Text = txtPassword.Text Then
'将代码放在这里传递
'成功到 calling 函数
'设置全局变量时最容易的
Str_PassWord = txtPassWord1.Text
LoginSucceeded = True
Unload Me
Form1.Show
Else
Label1.Caption = "无效的密码,请重试!"
txtPassWord1.SetFocus
End If
End Sub
00分享举报