Restored from previous forum. Originally posted by Paul.
Ok, this may seem like a dumb question but how do you hide a window?
If I use CloseWindow, this closes the window and the app terminates. What I want to do is hide the window and put an icon in the icon tray to show the app is still running. Then click the icon to unhide the window.
Thanks,
Paul.
Hide Window
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Franco.
Hi Paul,
the only thing I dislike with this example is the fact, that there is a button in the taskbar and I can't swith it off.
The only function I know [RegisterServiceProcess_(WindowID(), 1)] is not working because it is not implemented in PureBasic.
Maybe somebody else has a solution.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; Place a tray icon and on left click opens a window ;
; a right click closes the window after asking ;
; (c) 2001 - Franco's template - absolutely freeware ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Procedure.l ScreenWidth ()
ProcedureReturn GetSystemMetrics_(#SM_CXSCREEN)
EndProcedure
Procedure.l ScreenHeight ()
ProcedureReturn GetSystemMetrics_ (#SM_CYSCREEN)
EndProcedure
If OpenWindow(0, ScreenWidth (), ScreenHeight (), 0, 0, #PB_Window_SystemMenu,"(c) 2001 - Franco's template - absolutely freeware")
AddSysTrayIcon(1, WindowID(), LoadIcon_(0, #IDI_WINLOGO))
Repeat
Event = WaitWindowEvent()
If Event = #PB_EventSysTray
If EventMouseButton() = 1
SetForegroundWindow_(WindowID())
ResizeWindow(640,480)
xPos = (ScreenWidth () / 2) - (WindowWidth() / 2)
yPos = (ScreenHeight () / 2) - (WindowHeight() / 2)
MoveWindow(xPos,yPos)
If CreateMenu(0)
MenuTitle("File")
MenuItem(1,"&Load...")
MenuItem(2,"Save")
MenuItem(3,"Save As...")
MenuBar()
MenuItem(4,"Close Window")
MenuTitle("Help")
MenuItem(5, "About")
EndIf
AttachMenu(0,WindowID())
Repeat
Select WaitWindowEvent()
Case #PB_EventMenu
Select EventMenuID()
Case 1 ; Load
MessageRequester("(c) 2001 - Franco's template", "Load", 0)
Case 2 ; Save
MessageRequester("(c) 2001 - Franco's template", "Save", 0)
Case 3 ; Save As
MessageRequester("(c) 2001 - Franco's template", "Save As", 0)
Case 4 ; Quit
Quit = 1
ResizeWindow(0,0)
MoveWindow(ScreenWidth (), ScreenHeight ())
Case 5 ; About
MessageRequester("(c) 2001 - Franco's template", "absolutely freeware", 0)
EndSelect
Case #PB_EventCloseWindow
Quit = 1
ResizeWindow(0,0)
MoveWindow(ScreenWidth (), ScreenHeight ())
EndSelect
Until Quit = 1
Quit = 0
EndIf
If EventMouseButton() = 2
SetForegroundWindow_(WindowID())
MessageID = MessageRequester("(c) 2001 - Franco's template", "Do you want to exit the program?", 4)
Select MessageID
Case 6 ; Yes Button
Goto ProgramEnd
EndSelect
EndIf
EndIf
Until Event = #PB_EventCloseWindow
EndIf
ProgramEnd:
End
Have a nice day...
Franco
Hi Paul,
the only thing I dislike with this example is the fact, that there is a button in the taskbar and I can't swith it off.
The only function I know [RegisterServiceProcess_(WindowID(), 1)] is not working because it is not implemented in PureBasic.
Maybe somebody else has a solution.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; Place a tray icon and on left click opens a window ;
; a right click closes the window after asking ;
; (c) 2001 - Franco's template - absolutely freeware ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Procedure.l ScreenWidth ()
ProcedureReturn GetSystemMetrics_(#SM_CXSCREEN)
EndProcedure
Procedure.l ScreenHeight ()
ProcedureReturn GetSystemMetrics_ (#SM_CYSCREEN)
EndProcedure
If OpenWindow(0, ScreenWidth (), ScreenHeight (), 0, 0, #PB_Window_SystemMenu,"(c) 2001 - Franco's template - absolutely freeware")
AddSysTrayIcon(1, WindowID(), LoadIcon_(0, #IDI_WINLOGO))
Repeat
Event = WaitWindowEvent()
If Event = #PB_EventSysTray
If EventMouseButton() = 1
SetForegroundWindow_(WindowID())
ResizeWindow(640,480)
xPos = (ScreenWidth () / 2) - (WindowWidth() / 2)
yPos = (ScreenHeight () / 2) - (WindowHeight() / 2)
MoveWindow(xPos,yPos)
If CreateMenu(0)
MenuTitle("File")
MenuItem(1,"&Load...")
MenuItem(2,"Save")
MenuItem(3,"Save As...")
MenuBar()
MenuItem(4,"Close Window")
MenuTitle("Help")
MenuItem(5, "About")
EndIf
AttachMenu(0,WindowID())
Repeat
Select WaitWindowEvent()
Case #PB_EventMenu
Select EventMenuID()
Case 1 ; Load
MessageRequester("(c) 2001 - Franco's template", "Load", 0)
Case 2 ; Save
MessageRequester("(c) 2001 - Franco's template", "Save", 0)
Case 3 ; Save As
MessageRequester("(c) 2001 - Franco's template", "Save As", 0)
Case 4 ; Quit
Quit = 1
ResizeWindow(0,0)
MoveWindow(ScreenWidth (), ScreenHeight ())
Case 5 ; About
MessageRequester("(c) 2001 - Franco's template", "absolutely freeware", 0)
EndSelect
Case #PB_EventCloseWindow
Quit = 1
ResizeWindow(0,0)
MoveWindow(ScreenWidth (), ScreenHeight ())
EndSelect
Until Quit = 1
Quit = 0
EndIf
If EventMouseButton() = 2
SetForegroundWindow_(WindowID())
MessageID = MessageRequester("(c) 2001 - Franco's template", "Do you want to exit the program?", 4)
Select MessageID
Case 6 ; Yes Button
Goto ProgramEnd
EndSelect
EndIf
EndIf
Until Event = #PB_EventCloseWindow
EndIf
ProgramEnd:
End
Have a nice day...
Franco
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Mr.Skunk.
Hi,
You can use the showwindow_(windowid(),0|1)
0 to hide the window
1 to show the window
This API show/hide the button in the taskbar with the window.
Mr Skunk
Mr Skunk's PureBasic Web Page
http://www.skunknet.fr.st
Hi,
You can use the showwindow_(windowid(),0|1)
0 to hide the window
1 to show the window
This API show/hide the button in the taskbar with the window.
Mr Skunk
Mr Skunk's PureBasic Web Page
http://www.skunknet.fr.st
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm