systray and internet explorer

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by cor.

How to start a new internet explorer window from a systray application?


Just a beginner with PB

Thanks in advance

C. de Visser
Author of Super Guitar Chord Finder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Welcome Cor, this is a easy one:

Code: Select all

; (c) 2002 - Franco's template - absolutely freeware
; Place a tray icon and open a internet page.
; left click opens a popup menu
; right click closes the program
;
Procedure OpenInternetPage(Page$)
  ShellExecute_(0, "open", Page$, 0, 0, 1)
EndProcedure
Structure pt
  x.l
  y.l
EndStructure
Cursor.pt

If CreatePopupMenu(0)
  MenuItem(1, "PureBasic Home")
  MenuItem(2, "PureBasic Forum")
  MenuItem(3, "PureBasic Resources")
  MenuItem(4, "About")
EndIf

;open a window (needed...)
If OpenWindow(0,0,0,0,0,#WS_POPUP,"(c) 2002 - Franco's template - absolutely freeware")
  showwindow_(WindowID(),0) ;don't show this fake window
  AddSysTrayIcon(1, WindowID(), LoadIcon_(0, #IDI_WINLOGO))

  Repeat
    Event = WaitWindowEvent()
    
    If Event = #PB_EventSysTray
      If EventMouseButton() = 1
        GetCursorPos_(Cursor)
        xPos=Cursor\x
        yPos=Cursor\y

        DisplayPopupMenu(0, WindowID(), xPos, yPos)
        
        Repeat
          Select WaitWindowEvent()
            Case #PB_EventMenu
              Select EventMenuID()
                Case 1 ; Cut
                  OpenInternetPage("[url]http://www.purebasic.com[/url]")
                  ExitMenu = 1
                Case 2 ; Copy
                  OpenInternetPage("[url]http://forums.purebasic.com[/url]")
                  ExitMenu = 1
                Case 3 ; Paste
                  OpenInternetPage("[url]http://www.reelmediaproductions.com/pb[/url]")
                  ExitMenu = 1
                Case 4 ; About
                  MessageRequester("(c) 2002 - 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) 2002 - 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

Edited by - franco on 07 January 2002 21:36:47
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by cor.

Hello Franco,

Thank you very much for your quick reply.

I have only one other question.

The current page on Internet explorer must not be overwritten, it must start a new explorer window, so the current stays intact.



A registered user of PB.

C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
Post Reply