Menu-question
Posted: Wed Dec 11, 2019 2:33 pm
Can we change the colors of a menu at runtime with oMenu:setcolors()?
www.FiveTechSoft.com
https://fivetechsoft.com/forums/
Code: Select all
oWnd:oMenu:End()
oWnd:SetMenu( BuildMenu( aColors ) )
// And in your function BuildMenu( aColors )
Function BuildMenu( aColors )
local oMenu
MENU oMenu // COLORS or 2013
oMenu:SetColors( aColors )
ENDMENU
.../...
Return oMenu
Code: Select all
Static oFont
Static oFontMenu
Static oWnd
Function Main()
Local oMnu
Local cFont := "Tahoma"
Local cFontH := -14
DEFINE FONT oFont NAME "TIMES NEW ROMAN" SIZE 0,-12
DEFINE FONT oFontMenu NAME cFont SIZE 0, cFontH WEIGHT 300
DEFINE WINDOW oWnd MENU ( oMnu := MakeMenu() ) TITLE FWVERSION
oWnd:nWidth := 600
oWnd:nHeight := 600
oWnd:bRClicked := { | r, c | MyPopup( r, c ) }
ACTIVATE WINDOW oWnd CENTERED
RELEASE FONT oFont
RELEASE FONT oFontMenu
Return nil
//----------------------------------------------------------------------------//
function MakeMenu()
local oMenu, oMnu1, oMnu2
MENU oMenu 2015 HEIGHT -2.8 FONT oFontMenu
MENUITEM "One" //FILE "..\bitmaps\full.bmp" // Also try with this
MENU
MENUITEM "Sunday" CHECKED
MENUITEM SEPARATOR Upper( "Select" )
MENUITEM "Monday" + CRLF + "Other" BOLD RADIOCHECK 3, 2
MENUITEM "Tuesday" ACTION MsgInfo( "Hola" ) ITALIC
MENUITEM "Wednesday"
MENU
MENUITEM "Other"
MENUITEM "More"
ENDMENU
SEPARATOR
MENUITEM "Thursday" FILE "..\bitmaps\full.bmp"
SEPARATOR
MENUITEM "Exit" ACTION oWnd:End() HSYSBITMAP 5
ENDMENU
MENUITEM "Two"
MENU
MENUITEM "Sunday" HSYSBITMAP 9
SEPARATOR
MENUITEM "Monday" HSYSBITMAP 11
ENDMENU
ENDMENU
return oMenu
//----------------------------------------------------------------------------//
Function MyPopup( nRow, nCol )
local oMenuNew
local nOldH := GetnHeightItem() // Save Height Item
MENU oMenuNew POPUP 2015 HEIGHT 4 FONT oFontMenu
MENUITEM "New &Dialog"
SEPARATOR
MENUITEM "New &Bitmap" CHARICON 57696
SEPARATOR
MENUITEM "New &Bitmap" CHARICON 57698
SEPARATOR
MENUITEM "New &Icon" CHARICON 57697
ENDMENU
ACTIVATE POPUP oMenuNew OF oWnd AT nRow, nCol
GetnHeightItem( nOldH ) // Restore old height
Return nil
//----------------------------------------------------------------------------//