上色

Code Block

2013年4月9日 星期二

[VB.Net] 清除無效的系統圖示

Dim hWndShell, hWndTray, hWndPager, hWndToolBar As Integer '系統用hwnd

'抹除通知區域圖示
hWndShell = FindWindow("Shell_TrayWnd", "") '取得系統圖示區hwnd

'取得通知區域hwnd
If Environment.OSVersion.Version.Major = 5 AndAlso Environment.OSVersion.Version.Minor = 0 Then
    hWndTray = FindWindowEx(hWndShell, 0, "TrayNotifyWnd", "")
    hWndToolBar = FindWindowEx(hWndTray, 0, "ToolbarWindow32", "")
Else
    hWndTray = FindWindowEx(hWndShell, 0, "TrayNotifyWnd", "")
    hWndPager = FindWindowEx(hWndTray, 0, "SysPager", "")
    hWndToolBar = FindWindowEx(hWndPager, 0, "ToolbarWindow32", "使用者升級的通知區域")
End If

'取得邊界
GetWindowInfo(hWndToolBar) '以自訂函數GetWindowInfo取得視窗資訊
Dim ibx, iby As Integer
iby = CInt(ClientY / 2) * 65536
'以WM_MOUSEMOVE消去無效圖示(將通知區域全部掃過一次)
For ibx = 1 To ClientX Step 1
    PostMessage(hWndToolBar, WM_MOUSEMOVE, 0, iby + ibx)
Next

**********以下為API宣告**********
'發送訊息到執行緒佇列
Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
'定義常數
Public Const WM_KEYDOWN As Integer = &H100
Public Const WM_KEYUP As Integer = &H101
Public Const VK_C As Integer = &H43
Public Const WM_CLOSE As Integer = &H10
Public Const WM_LBUTTONDBLCLK As Integer = &H203
Public Const WM_LBUTTONDOWN As Integer = &H201
Public Const WM_LBUTTONUP As Integer = &H202
Public Const WM_MBUTTONDBLCLK As Integer = &H209
Public Const WM_MBUTTONDOWN As Integer = &H207
Public Const WM_MBUTTONUP As Integer = &H208
Public Const WM_RBUTTONDBLCLK As Integer = &H206
Public Const WM_RBUTTONDOWN As Integer = &H204
Public Const WM_RBUTTONUP As Integer = &H205
Public Const WM_MOUSEACTIVATE As Integer = &H21
Public Const WM_MOUSEWHEEL As Integer = &H20A
Public Const WM_MOUSEFIRST As Integer = &H200
Public Const WM_MOUSELAST As Integer = &H209
Public Const WM_MOUSEMOVE As Integer = &H200
Public Const WM_SETCURSOR As Integer = &H20 

沒有留言:

張貼留言