大家好,又见面了,我是你们的朋友全栈君。
‘添加 Command1
Const WS_CHILD = &H40000000
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
Const SW_HIDE = 0
Const SW_NORMAL = 1
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function FindWindowEx Lib “user32” Alias “FindWindowExA” (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function FindWindow Lib “user32” Alias “FindWindowA” (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib “user32” (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function GetWindowRect Lib “user32” (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function CreateWindowEx Lib “user32” Alias “CreateWindowExA” (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
Private Declare Function DestroyWindow Lib “user32” (ByVal hwnd As Long) As Long
Dim tWnd As Long, bWnd As Long, ncWnd As Long
Private Sub Form_Load()
Dim R As RECT
tWnd = FindWindow(“Shell_TrayWnd”, vbNullString)
bWnd = FindWindowEx(tWnd, ByVal 0&, “BUTTON”, vbNullString)
GetWindowRect bWnd, R
ncWnd = CreateWindowEx(ByVal 0&, “BUTTON”, “Hello!”, WS_CHILD, 0, 0, R.Right – R.Left, R.Bottom – R.Top, tWnd, ByVal 0&, App.hInstance, ByVal 0&)
ShowWindow ncWnd, SW_NORMAL
ShowWindow bWnd, SW_HIDE
End Sub
Private Sub Form_Unload(Cancel As Integer)
ShowWindow bWnd, SW_NORMAL
DestroyWindow ncWnd
End
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
摘自:网络整理
★VB部分相关文章推荐:★
☆关于VB中Shell及ShellExecute的总结与记录
☆[vb]On Error GoTo 0和On Error resume区别
☆VB抓图
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/138458.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...