Note that there are some explanatory texts on larger screens.

plurals
  1. POUnicode/WideString BalloonTray
    text
    copied!<p>I have a function that shows a balloon tray in Windows it has a structure too like this:</p> <pre><code>const NIF_INFO = $00000010; NIIF_NONE = $00000000; NIIF_INFO = $00000001; NIIF_WARNING = $00000002; NIIF_ERROR = $00000003; type BalloonData = record cbSize: DWORD; Wnd: HWND; uID: UINT; uFlags: UINT; uCallbackMessage: UINT; hIcon: HICON; szTip: array[0..MAXCHAR] of AnsiChar; dwState: DWORD; dwStateMask: DWORD; szInfo: array[0..MAXBYTE] of AnsiChar; uTimeout: UINT; szInfoTitle: array[0..63] of AnsiChar; dwInfoFlags: DWORD; end; type TBalloonTimeout = 2..30; TBalloonIconType = (bitNone, bitInfo, bitWarning, bitError); function DZBalloonTrayIcon(const Window: HWND; const IconID: Byte; const Timeout: TBalloonTimeout; const BalloonText, BalloonTitle: String; const BalloonIconType: TBalloonIconType): Boolean; const aBalloonIconTypes : array[TBalloonIconType] of Byte = (NIIF_NONE, NIIF_INFO, NIIF_WARNING, NIIF_ERROR); var TheBalloon : BalloonData; begin FillChar(TheBalloon, SizeOf(BalloonData), 0); with TheBalloon do begin cbSize := SizeOf(BalloonData); Wnd := Window; uID := IconID; uFlags := NIF_INFO; StrCopy(szInfo, pchar(BalloonText)); uTimeout := Timeout * 1000; StrCopy(szInfoTitle, pchar(BalloonTitle)); dwInfoFlags := aBalloonIconTypes[BalloonIconType]; end; Result := Shell_NotifyIcon(NIM_MODIFY, @TheBalloon); end; </code></pre> <p>Usage :</p> <pre><code>procedure MakeBaloonTray; var TrayIconData : TNotifyIconData; begin DZBalloonTrayIcon(TrayIconData.Wnd, TrayIconData.uID, 2,'Test', 'Test', bitInfo); end; </code></pre> <p>then I changed everything to WideString:</p> <pre><code>const NIF_INFO = $00000010; NIIF_NONE = $00000000; NIIF_INFO = $00000001; NIIF_WARNING = $00000002; NIIF_ERROR = $00000003; type BalloonData = record cbSize: DWORD; Wnd: HWND; uID: UINT; uFlags: UINT; uCallbackMessage: UINT; hIcon: HICON; szTip: array[0..MAXCHAR] of WideChar; dwState: DWORD; dwStateMask: DWORD; szInfo: array[0..MAXBYTE] of WideChar; uTimeout: UINT; szInfoTitle: array[0..63] of WideChar; dwInfoFlags: DWORD; end; type TBalloonTimeout = 2..30; TBalloonIconType = (bitNone, bitInfo, bitWarning, bitError); function StrLCopyW(Dest, Source: PWideChar; MaxLen: Cardinal): PWideChar; var Count: Cardinal; begin Result := Dest; Count := 0; While (Count &lt; MaxLen) and (Source^ &lt;&gt; #0) do begin Dest^ := Source^; Inc(Source); Inc(Dest); Inc(Count); end; Dest^ := #0; end; function StrCopyW(Dest, Source: PWideChar): PWideChar; begin Result := StrLCopyW(Dest, Source, MaxInt); end; function DZBalloonTrayIcon(const Window: HWND; const IconID: Byte; const Timeout: TBalloonTimeout; const BalloonText, BalloonTitle: WideString; const BalloonIconType: TBalloonIconType): Boolean; const aBalloonIconTypes : array[TBalloonIconType] of Byte = (NIIF_NONE, NIIF_INFO, NIIF_WARNING, NIIF_ERROR); var TheBalloon : BalloonData; begin FillChar(TheBalloon, SizeOf(BalloonData), 0); with TheBalloon do begin cbSize := SizeOf(BalloonData); Wnd := Window; uID := IconID; uFlags := NIF_INFO; StrCopyW(szInfo, pwidechar(BalloonText)); uTimeout := Timeout * 1000; StrCopyW(szInfoTitle, pwidechar(BalloonTitle)); dwInfoFlags := aBalloonIconTypes[BalloonIconType]; end; Result := Shell_NotifyIcon(NIM_MODIFY, @TheBalloon); end; </code></pre> <p>I also tried:</p> <pre><code>procedure MakeBaloonTray; var TrayIconData : TNotifyIconData; WideStringTest : WideString; begin WideStringTest := 'someunicodechars'; DZBalloonTrayIcon(TrayIconData.Wnd, TrayIconData.uID, 2,UTF8Encode(WideStringTest), UTF8Encode(WideStringTest), bitInfo); end; </code></pre> <p>I thought Windows supports UTF8 in Balloons but I got question marks only. Any Idea how to show a WideString/Unicode in a balloon? Thank you for your help :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload