TrayIcon (OOP)

Share your advanced PureBasic knowledge/code with the community.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

TrayIcon (OOP)

Post by luis »

; TrayIcon class 1.00 (Windows)
; April 2010
; Written by Luis with PB 4.41

; A Traybar Icon implementation for PureBasic (OOP)

; The "main" icon is always set with TrayIcon_Create() or with SetIcon()

; The icons used in the animations are "secondary" icons and when the animation stops
; the icon in the tray bar reverts to the "main" icon.

; The icons are never copied internally to the object. TrayIcon always reference the icons
; defined in your program, so don't free them while they're in use.

; The "helper" procedure TrayIcon_GetIconFromRGBA() can be used to convert an RGBA
; PureBasic's image to icon format. This can be useful to draw an icon at runtime using the
; PB drawings commands and than convert the image into an icon to be used with a TrayIcon object.
; See the sample program for more info about it.

; The code should be Ascii and Unicode compatible.
; The code should be 32 and 64 bit compatible.

Code: Select all

Interface TrayIcon
 
 ; destroy the tray icon and free the object
 Destroy()
 
 ; set the text tooltip for the icon
 SetTooltip (sText.s)
 
 ; show a balloon tooltip with title, text and optionally a system defined icon
 ShowBalloon (sTitle.s, sText.s, iIconType = #TRAY_ICON_NONE)
 
 ; remove the text tooltip
 RemoveTooltip()
 
 ; remove the balloon tooltip
 RemoveBalloon() 
 
 ; change the icon 
 ; ignored if animation is active
 SetIcon (hIcon)
 
 ; enable / disable the blinking of the icon
 ; ignored if animation is active
 Blink (flgStatus)
 
 ; set the number of frames to be used to animate the icon
 ; ignored if animation is active
 SetAnimationFrames (iFrames)
 
 ; set the time to wait in ms. between each frame
 ; ignored if animation is active
 SetAnimationDelay (iDelay)
 
 ; load the specified icon in a frame slot (0 based)
 ; ignored if animation is active
 LoadFrameIcon (iFrame, hIcon)
 
 ; start the animation and play it forever (-1) or n times (1...n)
 ; disable blinking if is active
 StartAnimation (iCycles)
 
 ; stop the animation and discard the animation data freeing memory
 StopAnimation()
 
 ; hide/show the icon in the tray keeping all the states active
 Hide (flgStatus)
 
 ; return 0/1 if blinking is inactive/active
 IsBlinking()
 
 ; return 0/1 if animation is inactive/active
 IsAnimated()
 
 ; return 0/1 if the tray icon is visible/hidden
 IsHidden()
 
EndInterface
Download [... from someone who got a copy at the time].

Bye :wink:
Last edited by luis on Mon Oct 23, 2017 1:02 pm, edited 3 times in total.
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: TrayIcon (OOP)

Post by ts-soft »

thx, Image
User avatar
omboy
New User
New User
Posts: 6
Joined: Wed Feb 10, 2010 11:28 pm
Location: Russia
Contact:

Re: TrayIcon (OOP)

Post by omboy »

Image
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: TrayIcon (OOP)

Post by Kiffi »

luis wrote:; A Traybar Icon implementation for PureBasic (OOP)
Thanks for sharing! Image

Greetings ... Kiffi
Hygge
Phantomas
User
User
Posts: 96
Joined: Wed Jul 01, 2009 12:59 pm

Re: TrayIcon (OOP)

Post by Phantomas »

Very nice code!
But, how I can move code "Show balloon + icon" to new, clean project? Need only this function.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: TrayIcon (OOP)

Post by Kwai chang caine »

Great !!!
Thanks for sharing 8)
ImageThe happiness is a road...
Not a destination
User avatar
Falko
Enthusiast
Enthusiast
Posts: 271
Joined: Sat Oct 04, 2003 12:57 pm
Location: Germany
Contact:

Re: TrayIcon (OOP)

Post by Falko »

Cool.

Thx
www.falko-pure.de
Win11 Pro 64-Bit, PB_6.11b1
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: TrayIcon (OOP)

Post by ts-soft »

@Kwaï chang caïne @Falco

2 years sleep? :lol:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Falko
Enthusiast
Enthusiast
Posts: 271
Joined: Sat Oct 04, 2003 12:57 pm
Location: Germany
Contact:

Re: TrayIcon (OOP)

Post by Falko »

So it's :shock:
:mrgreen:
www.falko-pure.de
Win11 Pro 64-Bit, PB_6.11b1
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: TrayIcon (OOP)

Post by Kwai chang caine »

ts-soft wrote:@Kwaï chang caïne @Falco
2 years sleep? :lol:
Ooooohhh !!!! not see that :oops:

It's the fault at Image :lol: :lol:

Often, a member put a question several years after, and the others members continue in a single file like Image :lol: :lol: :lol:

After all, thanks to that, this thread live in a second life :mrgreen:

And thanks to Image i see this code i never see before 8)
ImageThe happiness is a road...
Not a destination
A M S
User
User
Posts: 58
Joined: Fri Aug 14, 2009 2:26 pm
Location: Afghanistan

Re: TrayIcon (OOP)

Post by A M S »

very nice :D
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: TrayIcon (OOP)

Post by luis »

And please note the download link still works after two years, like it should be in a perfect world :wink:
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
RichAlgeni
Addict
Addict
Posts: 935
Joined: Wed Sep 22, 2010 1:50 am
Location: Bradenton, FL

Re: TrayIcon (OOP)

Post by RichAlgeni »

WoW! Thanks Luis!
Post Reply