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 LWA_ALPHA = &H2 Private Const GWL_EXSTYLE = (-20) 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 SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long '我们将要调用的那个消息,在MSDN中搜索WM_SYSCOMMAND就可以找到具体说明 Const WM_SYSCOMMAND = &H112 '这个参数指明了我们让系统启动屏幕保护 Const SC_SCREENSAVE = &HF140& Private Sub Command1_Click() SendMessage Me.hwnd, WM_SYSCOMMAND, SC_SCREENSAVE, 0 Me.Timer1.Enabled = False End Sub
Private Sub Form_Load() Dim rtn As Long rtn = GetWindowLong(Me.hwnd, GWL_EXSTYLE) '取的窗口原先的样式 rtn = rtn Or WS_EX_LAYERED ' 使窗体添加上新的样式WS_EX_LAYERED SetWindowLong Me.hwnd, GWL_EXSTYLE, rtn ' 把新的样式赋给窗体 SetLayeredWindowAttributes Me.hwnd, 0, 200, LWA_ALPHA End Sub
在vb里,这些程序如果在窗体里出现就会和Msgbox冲突,我试了好多次都没有用,版主帮忙解决一下!!! |