Skip to content

Commit

Permalink
fix: tray icons' text was garbage
Browse files Browse the repository at this point in the history
  • Loading branch information
rejetto committed May 6, 2020
1 parent 4fe5445 commit a9f954e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions optionsDlg.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ object optionsFrm: ToptionsFrm
object Label7: TLabel
Left = 251
Top = 349
Width = 299
Width = 430
Height = 28
Hint = 'You also need to right click on the folder, then restrict access'
Anchors = [akLeft, akBottom]
Expand Down Expand Up @@ -161,7 +161,7 @@ object optionsFrm: ToptionsFrm
WordWrap = True
end
object Label8: TLabel
Left = 336
Left = 345
Top = 20
Width = 28
Height = 14
Expand Down
21 changes: 11 additions & 10 deletions traylib.pas
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,26 @@ interface
TM_ERROR = NIIF_ERROR
);

TNotifyIconDataEx = record
TNotifyIconData = record
cbSize: DWORD;
wnd: HWND;
uID: UINT;
uFlags: UINT;
uCallbackMessage: UINT;
hIcon: HICON;
szTip: array [0..127] of AnsiChar;
szTip: array [0..127] of Char;
dwState: DWORD;
dwStateMask: DWORD;
szInfo: array[0..255] of AnsiChar;
szInfo: array[0..255] of Char;
uVersion: UINT;
szInfoTitle: array[0..63] of AnsiChar;
szInfoTitle: array[0..63] of Char;
dwInfoFlags: DWORD;
hBaloonIcon: HICON;
end;

TmyTrayIcon=class
private
icondata: TNotifyIconDataEx;
icondata: TNotifyIconData;
shown: boolean;
procedure wndProc(var Message: TMessage);
procedure notify(ev:TtrayEvent);
Expand Down Expand Up @@ -114,8 +115,8 @@ procedure TmyTrayIcon.updateHandle(handle:HWND);
procedure TmyTrayIcon.update();
begin
if shown then
if not Shell_NotifyIcon(NIM_MODIFY, @icondata) then
Shell_NotifyIcon(NIM_ADD, @icondata);
if not Shell_NotifyIconW(NIM_MODIFY, @icondata) then
Shell_NotifyIconW(NIM_ADD, @icondata);
end; { update }

procedure TmyTrayIcon.setIcon(icon:Ticon);
Expand All @@ -141,7 +142,7 @@ procedure TmyTrayIcon.setTip(s:string);
s:=stringReplace(s,'&','&&',[rfReplaceAll]);
if length(s) > maxTipLength then setlength(s,maxTipLength);
if string(icondata.szTip) = s then exit;
strPLCopy(icondata.szTip, ansiString(s), sizeOf(icondata.szTip)-1);
strPLCopy(icondata.szTip, s, sizeOf(icondata.szTip)-1);
update();
end; // setTip

Expand Down Expand Up @@ -200,8 +201,8 @@ function TmyTrayIcon.balloon(msg:string; secondsTimeout:real; kind:TtrayMessageT
TM_INFO: icondata.dwInfoFlags:=NIIF_INFO;
else icondata.dwInfoFlags:=NIIF_NONE;
end;
strPLCopy(icondata.szInfo, ansiString(msg), sizeOf(icondata.szInfo)-1);
strPLCopy(icondata.szInfoTitle, ansiString(title), sizeOf(icondata.szInfoTitle)-1);
strPLCopy(icondata.szInfo, msg, sizeOf(icondata.szInfo)-1);
strPLCopy(icondata.szInfoTitle, title, sizeOf(icondata.szInfoTitle)-1);
icondata.uVersion:=round(secondsTimeout*1000);
icondata.uFlags := icondata.uFlags or NIF_INFO;
update();
Expand Down

0 comments on commit a9f954e

Please sign in to comment.