vba - 如何在标题栏上添加图标?
问题描述
下面的代码可以很好地将用户表单最小化到任务栏,但不知道如何插入图像工作。出现错误Sub AddIcon(myForm)
Sub AddIcon(myForm)
#If VBA7 Then
Dim hWnd As LongPtr
Dim lngRet As LongPtr
#Else
Dim hWnd As Long
Dim lngRet As Long
#End If
Dim hIcon As Long
'hIcon = Sheet1.Image1.Picture.Handle
hWnd = FindWindow(vbNullString, myForm.Caption)
lngRet = SendMessage(hWnd, WM_SETICON, ICON_SMALL, ByVal hIcon)
lngRet = SendMessage(hWnd, WM_SETICON, ICON_BIG, ByVal hIcon)
lngRet = DrawMenuBar(hWnd)
End Sub
Sub AddMinimizeButton()
#If VBA7 Then
Dim hWnd As LongPtr
#Else
Dim hWnd As Long
#End If
hWnd = GetActiveWindow
Call SetWindowLongPtr(hWnd, GWL_STYLE, _
GetWindowLongPtr(hWnd, GWL_STYLE) Or _
WS_MINIMIZEBOX)
Call SetWindowPos(hWnd, 0, 0, 0, 0, 0, _
SWP_FRAMECHANGED Or _
SWP_NOMOVE Or _
SWP_NOSIZE)
End Sub
Sub AppTasklist(myForm)
'Add this userform into the Task bar
#If VBA7 Then
Dim WStyle As LongPtr
Dim Result As LongPtr
Dim hWnd As LongPtr
#Else
Dim WStyle As Long
Dim Result As Long
Dim hWnd As Long
#End If
hWnd = FindWindow(vbNullString, myForm.Caption)
WStyle = GetWindowLongPtr(hWnd, GWL_EXSTYLE)
WStyle = WStyle Or WS_EX_APPWINDOW
Result = SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, _
SWP_NOMOVE Or _
SWP_NOSIZE Or _
SWP_NOACTIVATE Or _
SWP_HIDEWINDOW)
Result = SetWindowLongPtr(hWnd, GWL_EXSTYLE, WStyle)
Result = SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, _
SWP_NOMOVE Or _
SWP_NOSIZE Or _
SWP_NOACTIVATE Or _
SWP_SHOWWINDOW)
End Sub
解决方案
推荐阅读
- ios - Swift 4:didSet @IBOutlet 调用 viewDidLayoutSubviews,但不使用 addSubview()
- character-encoding - UTF-8 Chars in FTP Greeting
- java - Bas64 解码错误
- android - Gradle sync failed access is denied in android studio
- c# - IdentityServer4 with ASP.NET Core 2.1 Identity - 加载外部登录信息时出错
- netsuite - Execution log not working in Suitescript 2.0 Client script
- ssis - duplicate set key value in SSIS
- conditional - How do you conditionally show fields in "Show" component in react-admin?
- node.js - Node.js Bytecode Constant Pool Output
- linux - 同一个 git 提交的几个作者?