minimizing a window to the system tray and not the task bar
minimizing a window to the system tray and not the task bar
how would you go about do it i have no clue
Insanity is over rated, unless you can join me in mine.
Don't post questions at work
Don't post questions at work
Don't post questions at work
Don't post questions at work
Don't post questions at work
Don't post questions at work
Hi,
in your evenments loop, you should have the following Select :
before the loop, in your code, write this :
Then under default, write :
and add after Select EventID :
in your evenments loop, you should have the following Select :
Code: Select all
Select EventID
case xx
case xx
default
endselect
Code: Select all
hwnd = WindowID(#Window_0)
SysTrayIcon.l = ExtractIcon_(hwnd,"yourappname.exe",0)
AddSysTrayIcon(0, WindowID(0), SysTrayIcon)
SysTrayIconToolTip(0, "your text description")
Code: Select all
If IsIconic_(hwnd) <> 0 ;the window has been minimized
HideWindow(#Window_0, 1)
endif
Code: Select all
Case #PB_Event_SysTray
Select EventType()
Case #PB_EventType_LeftDoubleClick
HideWindow(#Window_0, 0)
EndSelect
- Registered PB user -
Using PB 4.00
Using PB 4.00
- NoahPhense
- Addict

- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
Re: minimizing a window to the system tray and not the task
Rookie,
Do you have the 'codearchiv'?
If not you can get it from here:
http://www.purearea.net/
- np
Do you have the 'codearchiv'?
Code: Select all
; German forum: http://robsite.de/php/pureboard/viewtopic.php?t=3339&highlight=
; Author: PWS32
; Date: 05. January 2004
If OpenWindow(0, 100, 200, 195, 260, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "Test Window")
If CreatePopupMenu(0)
MenuItem(1, "Restore Window")
MenuBar()
MenuItem(2, "Quit")
EndIf
MessageRequester("Info", "lass mal verschwinden", 0)
HideWindow(0, 1)
AddSysTrayIcon (1, WindowID(), LoadImage(0, "..\..\Graphics\Gfx\help16.ico")) ; <<--- hier irgend ein 16X16 Icon nehmen
SysTrayIconToolTip (1, "Rechte Maustaste für PopUp")
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_Event_SysTray ; <<-- PopUp bei click auf rechter Maustaste auf Dein Systray Icon
If EventType() = #PB_EventType_RightClick
DisplayPopupMenu(0, WindowID())
EndIf
EndIf
If EventID = #PB_EventMenu ; <<-- PopUp Event
Select EventMenuID()
Case 1 ; Restore
RemoveSysTrayIcon (1)
HideWindow(0, 0)
MessageRequester("Info", "drück mal OK und dann den Minimize Button am Fenster", 0)
Case 2 ; Quit
Quit = 1
EndSelect
EndIf
If IsIconic_(WindowID()) ;<<-- dasselbe mit dem Minimize Button
HideWindow(0, 1)
AddSysTrayIcon (1, WindowID(), LoadImage(0, "..\..\Graphics\Gfx\help16.ico"))
SysTrayIconToolTip (1, "Rechte Maustaste für PopUp")
EndIf
If EventID = #PB_Event_CloseWindow
Quit = 1
EndIf
Until Quit = 1
EndIf
End http://www.purearea.net/
- np
Here is a simple code:
Code: Select all
If OpenWindow(0, 100, 150, 300, 100, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget, "PureBasic - SysTray Example")
AddSysTrayIcon(0, WindowID(), LoadImage(0, "Data\CdPlayer.ico"))
SysTrayIconToolTip(0, "Icon 1")
If CreatePopupMenu(0)
MenuItem(1, "Restaurer")
EndIf
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_SysTray
If EventType() = #PB_EventType_RightClick
DisplayPopupMenu(0, WindowID())
If IsIconic_(WindowID(0))
;cette ligne est utilisée pour l'effet d'agrandissement
ShowWindow_(WindowID(0),#sw_minimize)
;Une tempo est nécessaire sinon ça ne fonctionne pas à tous les coups
Delay(250)
ShowWindow_(WindowID(0),#sw_restore)
EndIf
EndIf
Case #WM_SIZE
If IsIconic_(WindowID(0))
ShowWindow_(WindowID(0),#sw_hide)
EndIf
EndSelect
Until Event = #PB_Event_CloseWindow
EndIf - NoahPhense
- Addict

- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
..
And here is a modified version with the icon embedded in the exe..
- np
Code: Select all
Enumeration
#Image0
EndEnumeration
Image0 = CatchImage(0, ?Image0)
If OpenWindow(0, 100, 150, 300, 100, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget, "PureBasic - SysTray Example")
AddSysTrayIcon(0, WindowID(), Image0)
SysTrayIconToolTip(0, "Icon 1")
If CreatePopupMenu(0)
MenuItem(1, "Restaurer")
EndIf
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_SysTray
If EventType() = #PB_EventType_RightClick
DisplayPopupMenu(0, WindowID())
If IsIconic_(WindowID(0))
;cette ligne est utilisée pour l'effet d'agrandissement
ShowWindow_(WindowID(0),#sw_minimize)
;Une tempo est nécessaire sinon ça ne fonctionne pas à tous les coups
Delay(250)
ShowWindow_(WindowID(0),#sw_restore)
EndIf
EndIf
Case #WM_SIZE
If IsIconic_(WindowID(0))
ShowWindow_(WindowID(0),#sw_hide)
EndIf
EndSelect
Until Event = #PB_Event_CloseWindow
EndIf
; // DataSection // ------------------------------------------------- //
DataSection
Image0:
IncludeBinary "C:\Program Files\NSIS\Contrib\Graphics\Icons\box-install.ico"
EndDataSection