Seite 1 von 1

BallonTips für SysTray

Verfasst: 22.06.2008 22:30
von mx03
Also ich kann überall BallonTips aufrufen bloß wie bekomm ich das so hin das sich ein BallonTip beim SysTray öffnet?

Und wie kann ich systray icons in die exe mit einfügen?

thx :)

Verfasst: 22.06.2008 22:36
von ts-soft
SysTrayIconEx V1.0 for PB4

Um die Icons einzufügen, sollteste ein Resource-Script schreiben, mit PORC
compilieren und mit Import in die Exe einfügen.

// edit
Icon.rc hat geschrieben:100 ICON "C:\\WINDOWS\\TEMP\\Icon.ico"
Wichtig: ein Return am ende und falls Pfad angegeben, immer mit doppelten
Backslashes.
Compilieren mit:
PORC Icon.rc

Laden:

Code: Alles auswählen

Import "Icon.res" : EndImport

hIcon = LoadIcon_(GetModuleHandle_(#NUL), 100)
Ich hoffe Du kommt damit erstmal klar

Gruß
Thomas

Verfasst: 22.06.2008 23:07
von mx03
also ich hab das jetzt so gemacht wie du gesagt hast und es funktioniert auch bei:

Code: Alles auswählen

AddSysTrayIcon(#SysTrayIcon, WindowID(0), hIcon1)
jedoch wenn ich dann

Code: Alles auswählen

ChangeSysTrayIcon(#SysTrayIcon, hIcon2)
aufrufe kommt der Fehler:

Code: Alles auswählen

[ERROR] 'ImageID' is null !

Verfasst: 22.06.2008 23:12
von ts-soft
Haste denn auch ein zweites Icon im Script? Mit anderer Nummer?
Überprüfts Du das Ergebnis von LoadIcon_?

Ohne Code bin ich am Rätseln, was ja auch manchmal Spaß macht, aber
manchmal fehlt mir dazu die Zeit :wink:

Verfasst: 22.06.2008 23:20
von mx03

Code: Alles auswählen

Import "Icon.res" : EndImport 

If hsIcon1 = LoadIcon_(GetModuleHandle_(#NUL), 100)
Debug "geladen1"
EndIf 
If hsIcon2 = LoadIcon_(GetModuleHandle_(#NUL), 101)
Debug "geladen2"
EndIf

Enumeration
  #Window_0
  #Menu_New
  #Menu_Open
  #Menu_Save
  #Menu_Exit
  #POPUP_MENU
  #SysTrayIcon
EndEnumeration

Procedure Open_Window_0()
  If OpenWindow(#Window_0, 275, 10, 100, 0, "Chatstatus",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
    If CreateGadgetList(WindowID(#Window_0))
      
    EndIf
  EndIf
EndProcedure

InitNetwork() 
Open_Window_0()
HideWindow(#Window_0, 1)

CreatePopupMenu(#POPUP_MENU)
MenuItem(#Menu_Exit,  "Be&enden")

     AddSysTrayIcon(#SysTrayIcon, WindowID(#Window_0), hsIcon1)

Repeat ; Start of the event loop
  
  Event = WaitWindowEvent() ; This line waits until an event is received from Windows
  
  WindowID = EventWindow() ; The Window where the event is generated, can be used in the gadget procedures
  
  Menu  = EventMenu()
  
  GadgetID = EventGadget() ; Is it a gadget event?
  
  EventType = EventType() ; The event type
  

  If Event = #PB_Event_Gadget
    
  EndIf
  
  If Event = #PB_Event_Menu
    Select Menu
          Case #Menu_Exit
            Exit = 1
        EndSelect
  EndIf
  
  If Event = #PB_Event_SysTray
  Select EventType
          Case #PB_EventType_LeftClick ;Klick mit der linken Maustaste
            
 ChangeSysTrayIcon(#SysTrayIcon, #ico1)

          Case #PB_EventType_RightClick         ; Klick mit der rechten Maustaste
            DisplayPopupMenu(#POPUP_MENU, WindowID(#Window_0)) ; Menuaufruf
        EndSelect
  EndIf
Until Exit
End
Und hier die .rc file:

Code: Alles auswählen

100 ICON "C:\\chatdead.ico"
101 ICON "C:\\chatalive.ico"
Die Icon.res liegt im Compilers Ordner

Verfasst: 22.06.2008 23:38
von ts-soft
Ändere mal die ersten Zeilen in:

Code: Alles auswählen

Import "Icon.res" : EndImport

hsIcon1 = LoadIcon_(GetModuleHandle_(#NUL), 100)
hsIcon2 = LoadIcon_(GetModuleHandle_(#NUL), 101)

If (Not hsIcon1) Or (Not hsIcon2)
  Debug "No Icon"
  End
EndIf
Bei mir funktionierts
PS: die Icon.res im Programmverzeichnis!