menu in taskbar

Windows specific forum
coma
Enthusiast
Enthusiast
Posts: 164
Joined: Fri Aug 15, 2003 3:46 am
Location: Canada

menu in taskbar

Post by coma »

is it possible to add menu items in the taskbar menu ? (the little menu, opened with a right click over the program button).
I searched the forum, but without success..

thanks.
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

--Kale

Image
coma
Enthusiast
Enthusiast
Posts: 164
Joined: Fri Aug 15, 2003 3:46 am
Location: Canada

Post by coma »

thanks kale. But I don't want to add options in explorer context menu.
I just talking about this menu :

<img border="1" src="http://coma.coma.free.fr/pureforum/menu.gif">
Nico
Enthusiast
Enthusiast
Posts: 274
Joined: Sun Jan 11, 2004 11:34 am
Location: France

Post by Nico »

Hi Coma,

You can use API for modify completely the system menu:
AppendMenu, ModifyMenu, InsertMenu

An example here: :D

Code: Select all

Global id.l

Procedure MyWindowCallback(WindowID,Message,wParam,lParam) 
  result=#PB_ProcessPureBasicEvents
  Select Message 
    Case #WM_SYSCOMMAND
      Select wParam  
        Case id
          MessageRequester("About", "Cool Menu example 1", 0)
          
        Case id+1
          MessageRequester("About", "Cool Menu example 2", 0)          
      EndSelect

EndSelect 
ProcedureReturn result 
EndProcedure 
    
Hwnd_window0=OpenWindow(0,200,200,200,200,#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget,"Menu System") 

id.l=15
hwnd_systeme=GetSystemMenu_(Hwnd_window0,#False)  
AppendMenu_(hwnd_systeme,#Mft_String,id,"Mon Menu 1")
AppendMenu_(hwnd_systeme,#Mft_String,id+1,"Mon Menu 2")

SetWindowCallback(@MyWindowCallback()) 

Repeat
  
  Select WindowEvent() 
    Case #PB_Event_CloseWindow 
      Quit=1 
      ;------------------------------------ 
      ;   The rest of your code here  
      ;------------------------------------      
  EndSelect 
Until Quit = 1 
End
coma
Enthusiast
Enthusiast
Posts: 164
Joined: Fri Aug 15, 2003 3:46 am
Location: Canada

Post by coma »

oh, great, perfect.
I just added AppendMenu_(hwnd_systeme, #Mft_Separator, 0, 0)
(I use 0,0, I don't know if it's very good, but seems that it works...)

Merci beaucoup :D
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

FYI: From the WinAPI Help:
The AppendMenu function has been superseded by the InsertMenuItem function. You can still use AppendMenu, however, if you do not need any of the extended features of InsertMenuItem.
--Kale

Image
Intrigued
Enthusiast
Enthusiast
Posts: 501
Joined: Thu Jun 02, 2005 3:55 am
Location: U.S.A.

Post by Intrigued »

How about doing this sort of activity with regards to a Systray icon for a non-PB based application (.exe)?
Intrigued - Registered PureBasic, lifetime updates user
Intrigued
Enthusiast
Enthusiast
Posts: 501
Joined: Thu Jun 02, 2005 3:55 am
Location: U.S.A.

Post by Intrigued »

{[Bump]}
Intrigued wrote:How about doing this sort of activity with regards to a Systray icon ?
Intrigued - Registered PureBasic, lifetime updates user
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

Create a window then hide it.

Create a popup menu using the internal PB commands, for example:

Code: Select all

  If CreatePopupMenu(#Menu_1)
    OpenSubMenu("Add...")
      MenuItem(#Menu_AddSong,"Song")
      MenuItem(#Menu_AddFolder,"Folder")
    CloseSubMenu()
    OpenSubMenu("Remove...")
      MenuItem(#Menu_RemoveSong,"Song")
      MenuItem(#Menu_RemoveFolder,"Folder")
    CloseSubMenu()
    MenuBar()
    OpenSubMenu("Tracks")
      For t=0 To CountGadgetItems(0)-1
        MenuItem(#Last_Item+t+1,Str(t+1)+". "+GetFilePart(GetGadgetItemText(0,t,0)))
      Next t
    CloseSubMenu()
    MenuBar()
    MenuItem(#Menu_Play,"Play")
    MenuItem(#Menu_Pause,"Pause")
    MenuItem(#Menu_Stop,"Stop")
    MenuItem(#Menu_Skip,"Skip")
    MenuItem(#Menu_Back,"Back")
    MenuBar()
    OpenSubMenu("Play Mode")
      MenuItem(#Menu_Shuffle,"Shuffle")
      MenuItem(#Menu_RepeatSingle,"Repeat current")
      MenuItem(#Menu_RepeatAll,"Repeat all")
    CloseSubMenu()
    MenuBar()
    OpenSubMenu("Volume")
      MenuItem(#Menu_VolumeUp,"Volume Up")
      MenuItem(#Menu_VolumeDown,"Volume Down")
      MenuItem(#Menu_Mute,"Mute")
      MenuItem(#Menu_Volume,"Volume: "+Str(Volume))
      DisableMenuItem(#Menu_Volume,1)
    CloseSubMenu()
    MenuBar()
    MenuItem(#Menu_About,"About")
    MenuBar()
    MenuItem(#Menu_ExitSys,"Exit")
    ProcedureReturn 1
  Else
   ProcedureReturn 0
  EndIf
Then use this in a loop to detect right clicks:

Code: Select all

Select WindowEvent()
  Case #PB_Event_Systray
    
  Select EventType()
      Case #PB_EventType_RightClick
        DisplayPopupMenu(#Menu_1,WindowID(#Main_Window))
    
  EndSelect
EndSelect
This code won't work directly, I've just mdified some code from a project I've done before, but it works pretty well!
~I see one problem with your reasoning: the fact is thats not a chicken~
Intrigued
Enthusiast
Enthusiast
Posts: 501
Joined: Thu Jun 02, 2005 3:55 am
Location: U.S.A.

Post by Intrigued »

Killswitch, thanks for sharing! I'm very much the youngling when it comes to PB. But, I seem to be picking it up pretty quick.

Again, thanks!
Intrigued - Registered PureBasic, lifetime updates user
Post Reply