PB5.73 AddSysTrayIcon() supports PNGs on Windows

Found an issue in the documentation ? Please report it here !

Moderator: Documentation Editors

User avatar
Regenduft
Enthusiast
Enthusiast
Posts: 116
Joined: Mon Mar 02, 2009 9:20 pm
Location: Germany

PB5.73 AddSysTrayIcon() supports PNGs on Windows

Post by Regenduft »

The documentation states, that windows does only support ICO images as SysTrayIcons. This is wrong. PNG images work just fine on windows, too.
AddSysTrayIcon (link to doc) wrote:[...]Only icon image type (.ico) are supported on Windows, for Linux and OS X it is advised to use a PNG image[...]
ChangeSysTrayIcon (link to doc) wrote:[...]Only icon image type (.ico) are supported on Windows, for Linux and OS X it is advised to use a PNG image[...]

Code: Select all

CompilerIf #PB_Compiler_OS <> #PB_OS_Windows
  CompilerError "only concerning windows specific documentation"
CompilerEndIf

UsePNGImageDecoder()
UsePNGImageEncoder()

; draw temporary image (red plus)
CreateImage(1, 16, 16, 32, #PB_Image_Transparent)
StartDrawing(ImageOutput(1))
DrawingMode(#PB_2DDrawing_AllChannels)
Box(6, 0,  4, 16, $FF0000FF)
Box(0, 6, 16,  4, $FF0000FF)
StopDrawing()

; encode temporary image as PNG and free it
*png = EncodeImage(1, #PB_ImagePlugin_PNG)
FreeImage(1)

; catch PNG
CatchImage(1, *png)

OpenWindow(1,0,0,0,0,"PNG-SysTrayIcon on Windows is working!")
AddSysTrayIcon(1, WindowID(1), ImageID(1))

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EDIT: Changed code a bit to make correct alpha channel support visible.
User_Russian
Addict
Addict
Posts: 1195
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: PB5.73 AddSysTrayIcon() supports PNGs on Windows

Post by User_Russian »

In the help it is written that ico is only supported on Windows. But this does not mean that other image formats are not supported on Windows.
User avatar
spikey
Enthusiast
Enthusiast
Posts: 396
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: PB5.73 AddSysTrayIcon() supports PNGs on Windows

Post by spikey »

The wording is ambiguous. It might be less ambiguous to say:
The icon image type (.ico) is supported on Windows only. For Linux and OS X and cross platform applications, it is advised to use a PNG image...
Additionally - isn't this really a remark not a parameter explanation?
User avatar
Regenduft
Enthusiast
Enthusiast
Posts: 116
Joined: Mon Mar 02, 2009 9:20 pm
Location: Germany

Re: PB5.73 AddSysTrayIcon() supports PNGs on Windows

Post by Regenduft »

English is a foreign language to me, so no further comment from me on the English documentation directly.
But it seems like André also got it wrong. The German documentation "reproduces" my misunderstanding:
AddSysTrayIcon (link to German doc) wrote:[...]Auf Windows werden nur Icon-Bildtypen (.ico) unterstützt, auf Linux und OS X ist die Verwendung eines PNG-Bildes ratsam[...]
ChangeSysTrayIcon (link to German doc) wrote:[...]Auf Windows werden nur Icon-Bildtypen (.ico) unterstützt, auf Linux und OS X ist die Verwendung eines PNG-Bildes ratsam[...]
Post Reply