Shell_NotifyIcon Windows API sends a message to the taskbar's status area.
I'm looking a way to make Windows notification API works with UTF-8 characters.
The code below works well, but only with ANSI characters.
The UTF-8 Characters are displayed as "??".
Option Explicit
Private Declare PtrSafe Function Shell_NotifyIconA Lib "shell32.dll" (ByVal dwMessage As Long, ByRef nfIconData As NOTIFYICONDATA) As LongPtr
Public nfIconData As NOTIFYICONDATA
Private Type NOTIFYICONDATA
cbSize As Long
hwnd As LongPtr
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As LongPtr
szTip As String * 128
dwState As Long
dwStateMask As Long
szInfo As String * 256
uTimeout As Long
szInfoTitle As String * 64
dwInfoFlags As Long
End Type
Public Function toast(Optional ByVal title As String, Optional ByVal info As String, Optional ByVal flag As Long)
With nfIconData
.dwInfoFlags = flag
.uFlags = &H10
.szInfoTitle = title
.szInfo = info
.cbSize = &H1F8
End With
Shell_NotifyIconW &H0, nfIconData
Shell_NotifyIconW &H1, nfIconData
End Function
'Flags for the balloon message..
'None = 0
'Information = 1
'Exclamation = 2
'Critical = 3
Sub TestANSI()
toast "Hi"
End Sub
Sub testUTF8()
toast ChrW(55357) & ChrW(56397)
End Sub
Simply changing the A to W in windows API declaration doesn't fix it.
Anyone have experience using Shell_NotifyIconW for UTF-8 charachters?
I've tried with the code below, but it doesn't work.
Option Explicit
Private Declare PtrSafe Function Shell_NotifyIconW Lib "shell32.dll" (ByVal dwMessage As Long, ByRef nfIconData As NOTIFYICONDATA) As LongPtr
Public nfIconData As NOTIFYICONDATA
Private Type NOTIFYICONDATA
cbSize As Long
hwnd As LongPtr
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As LongPtr
szTip As String * 128
dwState As Long
dwStateMask As Long
szInfo As String * 256
uTimeout As Long
szInfoTitle As String * 64
dwInfoFlags As Long
End Type
Public Function toast(Optional ByVal title As String, Optional ByVal info As String, Optional ByVal flag As Long)
With nfIconData
.dwInfoFlags = flag
.uFlags = &H10
.szInfoTitle = title
.szInfo = info
.cbSize = &H1F8
End With
Shell_NotifyIconW &H0, nfIconData
Shell_NotifyIconW &H1, nfIconData
End Function
'Flags for the balloon message..
'None = 0
'Information = 1
'Exclamation = 2
'Critical = 3
Sub TestANSI()
toast "Hi"
End Sub
Sub testUTF8()
toast ChrW(55357) & ChrW(56397)
End Sub