It is currently Tue Mar 02, 2021 12:31 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: [ToDo ?] SetMenuItemImage
PostPosted: Tue Feb 11, 2020 3:41 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Oct 06, 2007 11:20 pm
Posts: 307
Location: France
Hey,
I didn't find any command to change the image of a MenuItem in a PopupMenu. Jump in destroying and then recreating the menu, which is a bit cumbersome.
A SetMenuItemImage would be welcome.

Code:
SetMenuItemImage(#Menu, Element, ImageID(image))

_________________
~Ar-S~

My webSite (french) with PB apps : LDVMULTIMEDIA
PB - 5.4x LTS / 5.7x - W10 x64 - Ryzen 7 3700x
Repeat : try : until done = 1


Top
 Profile  
Reply with quote  
 Post subject: Re: [ToDo ?] SetMenuItemImage
PostPosted: Tue Feb 23, 2021 7:44 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Mar 02, 2009 9:20 pm
Posts: 112
Location: Germany
Hi there,

I would also prefer a proper "SetMenuItemImage()", but the following code shows how to at least get the the job done without destroying and recreating the whole menu:

Code:
CreateImage(0, 16, 16, 32, #PB_Image_Transparent)

CreateImage(1, 16, 16, 32)
StartDrawing(ImageOutput(1))
For y = 0 To 15
  For x = 0 To 15
    r.a = Random(1)-1
    g.a = Random(1)-1
    b.a = Random(1)-1
    Plot(x, y, RGB(r,g,b))
  Next
Next
StopDrawing()

OpenWindow(0, 200, 200, 200, 120, "Change Popup-Menu Image")

CreatePopupImageMenu(0, #PB_Menu_ModernLook)
MenuItem(1, "get red"  , ImageID(0))
MenuItem(2, "get green", ImageID(0))
MenuItem(3, "get blue" , ImageID(0))
MenuItem(4, "get funky", ImageID(0))
MenuItem(5, "get lost" , ImageID(0))

Repeat
 
  Select WaitWindowEvent()
     
    Case #PB_Event_CloseWindow
      End
     
    Case #PB_Event_RightClick
      DisplayPopupMenu(0, WindowID(0))
     
    Case #PB_Event_Menu
      StartDrawing(ImageOutput(0))
      DrawingMode(#PB_2DDrawing_AllChannels)
      Select EventMenu()
        Case 1 : Box(0,0,16,16,$FF0000FF)
        Case 2 : Box(0,0,16,16,$FF00FF00)
        Case 3 : Box(0,0,16,16,$FFFF0000)
        Case 4 : DrawImage(ImageID(1),0,0)
        Case 5 : Box(0,0,16,16,0)
      EndSelect
      StopDrawing()
     
  EndSelect
 
ForEver

...and sorry for the bad jokes inside the code... ;)


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 9 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