It is currently Sat May 25, 2013 3:40 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject:
PostPosted: Fri Sep 07, 2001 9:18 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777210
Restored from previous forum. Originally posted by Franco.

; Place a tray icon
; left click opens a popup menu
; right click closes the program
; (c) 2001 - Franco's template - absolutely freeware

Procedure.l ScreenWidth ()
ProcedureReturn GetSystemMetrics_(#SM_CXSCREEN)
EndProcedure

Procedure.l ScreenHeight ()
ProcedureReturn GetSystemMetrics_ (#SM_CYSCREEN)
EndProcedure

Structure pt
x.l
y.l
EndStructure
Cursor.pt

If CreatePopupMenu(0)
MenuItem(1, "Cut")
MenuItem(2, "Copy")
MenuItem(3, "Paste")
MenuBar()
OpenSubMenu("Options")
MenuItem(4, "Window...")
MenuItem(5, "Gadget...")
CloseSubMenu()
MenuBar()
MenuItem( 6, "About")
EndIf
;open a window (needed...) but put it outside the desktop
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
MoveWindow(ScreenWidth (), ScreenHeight ()) ;if somebody resizes the desktop
GetCursorPos_(Cursor)
xPos=Cursor\x
yPos=Cursor\y

DisplayPopupMenu(0, WindowID(), xPos, yPos)

Repeat
Select WaitWindowEvent()
Case #PB_EventMenu
Select EventMenuID()
Case 1 ; Cut
MessageRequester("(c) 2001 - Franco's template", "Cut", 0)
ExitMenu = 1
Case 2 ; Copy
MessageRequester("(c) 2001 - Franco's template", "Copy", 0)
ExitMenu = 1
Case 3 ; Paste
MessageRequester("(c) 2001 - Franco's template", "Paste", 0)
ExitMenu = 1
Case 4 ; Options
MessageRequester("(c) 2001 - Franco's template", "Options", 0)
ExitMenu = 1
Case 5 ; Gadget
MessageRequester("(c) 2001 - Franco's template", "Gadget", 0)
ExitMenu = 1
Case 6 ; About
MessageRequester("(c) 2001 - Franco's template", "Absolutely Freeware!", 0)
ExitMenu = 1
EndSelect
Case #PB_EventCloseWindow
ExitMenu = 1
EndSelect

Until ExitMenu = 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
End
EndSelect
EndIf

EndIf

Until Event = #PB_EventCloseWindow

EndIf
End
;---------------------------------------------------------



Have a nice day...
Franco


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 08, 2001 2:58 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777210
Restored from previous forum. Originally posted by ricardo.

Great example Franco

only one thing: why make the window visible but out of the screen?
i think the is some way to work around this making a hidden window


Regards,
Ricardo


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 17, 2001 5:36 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777210
Restored from previous forum. Originally posted by Franco.

Yes Ricardo, after creating the window I forgot this command:

showwindow_(windowid(),0)

I like to put invisible windows outside the desktop, but you have right it is not necessary.



Have a nice day...
Franco


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye