Tray icon example needed, please !

Just starting out? Need help? Post your questions and find answers here.
Large
User
User
Posts: 56
Joined: Tue Apr 29, 2003 8:24 pm

Tray icon example needed, please !

Post by Large »

Could someone please provide me with an example to do the following :

I have an open window and when I click on the tray icon associated to that window it brings it to the front and when I click it again it sends it to the back.

This is the code I'm working with and I want to add the above feature to it.

Code: Select all

OpenPreferences("Preferences.prefs")
PreferenceGroup("Window")
Window_X = ReadPreferenceLong ("Window_X", 20)
Window_Y = ReadPreferenceLong ("Window_Y", 20)
Window_W = ReadPreferenceLong ("Window_W", 170) 
Window_H = ReadPreferenceLong ("Window_H", 76)
PreferenceGroup("Webgadget")
Webgadget_X = ReadPreferenceLong ("Webgadget_X", 0)
Webgadget_Y = ReadPreferenceLong ("Webgadget_Y", 0)
Webgadget_W = ReadPreferenceLong ("Webgadget_W", 170) 
Webgadget_H = ReadPreferenceLong ("Webgadget_H", 100)
Webgadget_URL$ = ReadPreferenceString("Webgadget_URL", "http://server/intranet/check/check.php")
ClosePreferences()

win = OpenWindow(0, Window_X, Window_Y, Window_W, Window_H, #PB_Window_Invisible|#PB_Window_BorderLess, "Desktop Intranet") 
SetWindowLong_(WindowID(),#GWL_EXSTYLE,#WS_EX_TOOLWINDOW) 
ResizeWindow(Window_W,Window_H) : ShowWindow_(WindowID(),#SW_SHOW) 

CreateGadgetList(win) 
WebGadget(0,Webgadget_X,Webgadget_Y,Webgadget_W,Webgadget_H, Webgadget_URL$) 

Repeat 
  Select WaitWindowEvent() 
    Case #PB_EventGadget; check for a pushed button 
    Case 1 ; #PB_EventCloseWindow 
    Quit = 1 
  EndSelect    
Until Quit = 1 
Any help much appreciated.

Kind regards

Andy
Saboteur
Enthusiast
Enthusiast
Posts: 273
Joined: Fri Apr 25, 2003 7:09 pm
Location: (Madrid) Spain
Contact:

Post by Saboteur »

Did you see the example: examples\sources\systray.pb???
You only need to add mouse click events. :)

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - SysTray example file
;
;    (c) 2003 - Fantaisie Software
;
; ------------------------------------------------------------
;

If OpenWindow(0, 100, 150, 300, 100, #PB_Window_SystemMenu, "PureBasic - SysTray Example")

  AddSysTrayIcon(1, WindowID(), LoadImage(0, "Data\CdPlayer.ico"))
  AddSysTrayIcon(2, WindowID(), LoadImage(1, "Data\CdPlayer.ico"))
  SysTrayIconToolTip(1, "Icon 1")
  SysTrayIconToolTip(2, "Icon 2")
  
  Repeat
    Event = WaitWindowEvent()
    
    If Event = #PB_Event_SysTray
      If EventType() = #PB_EventType_LeftDoubleClick
        MessageRequester("SysTray", "Left DoubleClick on SysTrayIcon "+Str(EventGadgetID()),0)
        
        ChangeSysTrayIcon (EventGadgetID(), LoadImage(0, "Data\CdPlayer.ico"))
        SysTrayIconToolTip(EventGadgetID(), "Changed !")
      EndIf
      
    EndIf
  Until Event = #PB_Event_CloseWindow
  
EndIf 
[:: PB Registered ::]

Win10 Intel core i5-3330 8GB RAM Nvidia GTX 1050Ti
Post Reply