VB 任务栏透明
代码:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
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
Const WS_EX_LAYERED = &H80000
Const GWL_EXSTYLE = (-20)
Const LWA_ALPHA = &H2
Private Sub Form_Load()
dim bHwnd as Long
bHwnd = FindWindow("Shell_TrayWnd", vbNullString)
SetWindowLong bHwnd, GWL_EXSTYLE, GetWindowLong(bHwnd, GWL_EXSTYLE) Or WS_EX_LAYERED
SetLayeredWindowAttributes bHwnd, 0, 128, LWA_ALPHA
'上面的128改成不透明度(0和255之间)
End Sub
取消透明的方法是
Private Sub Command1_Click()
Dim newhwnd
Dim bHwnd As Long
bHwnd = FindWindow("Shell_TrayWnd", vbNullString)
SetWindowLong bHwnd, GWL_EXSTYLE, GetWindowLong _
(bHwnd,GWL_EXSTYLE & WS_EX_LAYERED)
END SUB
相关文档:
学生时代专业是机械,但是参加工作后,机缘巧合从事了与软件相关的工作,就是对大型工程软件软件做一些二次开发,收获过快乐,收获过辛酸,在一次又一次的得与失中,想找一个地方,找一些人可以慢慢与之分享,与之交流,并期得到帮助或提供帮助!也许你是无意见路过,甚或漂过,但你的注目是我前进的动力,有幸驻足也会让我 ......
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Const EWX_LOGOFF = 0
Private Const EWX_SHUTDOWN = 1
Private Const EWX_REBOOT = 2
Private Const EWX_FORCE = 4
Private closeTime As String
Sub AdjustTokenPrivilegesForNT()
......
主窗体代码:
'打开网页
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
'复制文件
Private Declare Fu ......
Option Explicit
Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Public Declare Function RegCreateKey Lib "advapi32.dll" Alias ......
就这么一个函数就解决了那位仁兄3天多的工作
唉~!真被一个函数玩死了
这里顺便帖出来吧
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Microsoft.VisualBasic.Shell( ......