Page 1 of 1

HOW TO CHANGE FW MENU THEMES AT RUNTIME

Posted: Sat Dec 06, 2025 1:57 am
by RAMESHBABU

Dear Friends,

Attn: Mr.Cristobal

Using the following code, I am not able to apply the respective
menu thems like l2007, l2010, l2013 and l2015 to the sub-menu
items at runtime. They are properly applied to the main menu
but not to the sub-menu items.

And How I can I get the Default Windows Menu Theme. I am
not getting this even after disable all l2007, l2010, l2013
and l2015 themes and define oMenu:lColors := .F.

Please suggest me the right way.

-Ramesh Babu P

Code: Select all | Expand

#include "FiveWin.ch"

STATIC oWnd, oMenu, n 

//-------------------------------------------------------------------//

FUNCTION Main()

   n := 0

   DEFINE WINDOW oWnd TITLE "Menu Theme Change - Runtime" ;

   @ 10, 1 BUTTON "2007 Theme" SIZE 100,28 ;
      ACTION SetMenuTheme(oMenu, 1) // CLR_WHITE, CLR_BLACK )

   @ 10,18 BUTTON "2010 Theme" SIZE 100,28 ;
      ACTION SetMenuTheme(oMenu, 2) // RGB(40,40,40), CLR_WHITE )

   @ 10,35 BUTTON "2013 Theme" SIZE 100,28 ;
      ACTION SetMenuTheme(oMenu, 3) // RGB(40,70,120), CLR_YELLOW )

   @ 10,52 BUTTON "2015 Theme" SIZE 100,28 ;
      ACTION SetMenuTheme(oMenu, 4) // RGB(40,70,120), CLR_YELLOW )

   @ 10,69 BUTTON "Win.Default" SIZE 100,28 ;
      ACTION SetMenuTheme(oMenu, 0) // RGB(40,70,120), CLR_YELLOW )

   BuildMenu()

   ACTIVATE WINDOW oWnd CENTERED

return nil

//-------------------------------------------------------------------//

FUNCTION BuildMenu()

   LOCAL oMenuFont

   DEFINE FONT oMenuFont NAME "Tahoma"  SIZE 0, -14 WEIGHT 300

   MENU oMenu FONT oMenuFont HEIGHT -2.00 COLORBMP CLR_HGRAY //"MEDICAL.BMP"

  MENUITEM "File"
     MENU
        MENUITEM "New"
        MENUITEM "Open"
        MENUITEM "Exit" ACTION oWnd:End()
     ENDMENU

  MENUITEM "Edit"
     MENU
        MENUITEM "Copy"
        MENUITEM "Paste"
     ENDMENU

  MENUITEM "Help"
     MENU
        MENUITEM "About"
     ENDMENU
   ENDMENU

   oWnd:SetMenu(oMenu)

   RELEASE FONT oMenuFont 

RETURN nil

//-------------------------------------------------------------------//

FUNCTION SetMenuTheme(oMenu, n) 

   DO CASE
      CASE n = 1
           oMenu:l2007   := .T.
           oMenu:l2010   := .F.
           oMenu:l2013   := .F.
           oMenu:l2015   := .F.
           oMenu:lColors := .T.
      CASE n = 2
           oMenu:l2007   := .F.
           oMenu:l2010   := .T.
           oMenu:l2013   := .F.
           oMenu:l2015   := .F.
           oMenu:lColors := .T.
      CASE n = 3
           oMenu:l2007   := .F.
           oMenu:l2010   := .F.
           oMenu:l2013   := .T.
           oMenu:l2015   := .F.
           oMenu:lColors := .T.
      CASE n = 4
           oMenu:l2007   := .F.
           oMenu:l2010   := .F.
           oMenu:l2013   := .F.
           oMenu:l2015   := .T.
           oMenu:lColors := .T.
      CASE n = 0
           oMenu:l2007   := .F.
           oMenu:l2010   := .F.
           oMenu:l2013   := .F.
           oMenu:l2015   := .F.
           oMenu:lColors := .F.
   ENDCASE 

   oMenu:SetSkin()
   oMenu:Refresh()

   ApplyMenuItemColors(oMenu, n)

RETURN nil

//-------------------------------------------------------------------//

FUNCTION ApplyMenuItemColors(oMenu, n)

   local oItem

   // Loop through menu items and apply color
   FOR EACH oItem IN oMenu:aItems
       DO CASE
          CASE n = 1
               oItem:l2007   := .T.
               oItem:l2010   := .F.
               oItem:l2013   := .F.
               oItem:l2015   := .F.
               oItem:lColors := .T.
          CASE n = 2
               oItem:l2007   := .F.
               oItem:l2010   := .T.
               oItem:l2013   := .F.
               oItem:l2015   := .F.
               oItem:lColors := .T.
          CASE n = 3
               oItem:l2007   := .F.
               oItem:l2010   := .F.
               oItem:l2013   := .T.
               oItem:l2015   := .F.
               oItem:lColors := .T.
          CASE n = 4
               oItem:l2007   := .F.
               oItem:l2010   := .F.
               oItem:l2013   := .F.
               oItem:l2015   := .T.
               oItem:lColors := .T.
          CASE n = 0
               oItem:l2007   := .F.
               oItem:l2010   := .F.
               oItem:l2013   := .F.
               oItem:l2015   := .F.
               oItem:lColors := .F.
       ENDCASE 

   oItem:nClrMenu := oMenu:nClrMenu
   oItem:nClrText := oMenu:nClrText
   oItem:nClrToBa := oMenu:nClrToBa
   oItem:nClrBkBa := oMenu:nClrBkBa
   oItem:nClrHiLi := oMenu:nClrHiLi
   oItem:nClrHiLf := oMenu:nClrHiLf
   oItem:nClrHitx := oMenu:nClrHitx
   oItem:nClrHiBr := oMenu:nClrHiBr
   oItem:nClrToBr := oMenu:nClrToBr
   oItem:nClrBkBr := oMenu:nClrBkBr
   oItem:nClrBox1 := oMenu:nClrBox1

   CColorSubMenu()

   NEXT

   oWnd:Refresh()

RETURN nil

Re: HOW TO CHANGE FW MENU THEMES AT RUNTIME

Posted: Sun Dec 07, 2025 5:43 pm
by cnavarro

Dear Ramesh, wait please


Re: HOW TO CHANGE FW MENU THEMES AT RUNTIME

Posted: Sun Dec 07, 2025 6:59 pm
by cnavarro

Dear Ramesh, try with this sample

Code: Select all | Expand

#include "FiveWin.ch"

STATIC oWnd, oMenu, n 
STATIC cTheme    := ""
STATIC oMenuFont

//-------------------------------------------------------------------//

FUNCTION Main()

   n := 0

   DEFINE FONT oMenuFont NAME "Tahoma"  SIZE 0, -14 WEIGHT 300

   DEFINE WINDOW oWnd TITLE "Menu Theme Change - Runtime: " + cTheme

   @ 10, 1 BUTTON "2007 Theme" SIZE 100,28 ;
      ACTION SetMenuTheme(1) // CLR_WHITE, CLR_BLACK )

   @ 10,18 BUTTON "2010 Theme" SIZE 100,28 ;
      ACTION SetMenuTheme(2) // RGB(40,40,40), CLR_WHITE )

   @ 10,35 BUTTON "2013 Theme" SIZE 100,28 ;
      ACTION SetMenuTheme(3) // RGB(40,70,120), CLR_YELLOW )

   @ 10,52 BUTTON "2015 Theme" SIZE 100,28 ;
      ACTION SetMenuTheme(4) // RGB(40,70,120), CLR_YELLOW )

   @ 10,69 BUTTON "Win.Default" SIZE 100,28 ;
      ACTION SetMenuTheme(0) // RGB(40,70,120), CLR_YELLOW )

   SetMenuTheme(0)

   ACTIVATE WINDOW oWnd CENTERED

   RELEASE FONT oMenuFont 

return nil

//-------------------------------------------------------------------//

FUNCTION BuildMenu( n )

   if n = 0
   MENU oMenu FONT oMenuFont HEIGHT -2.00 // COLORBMP CLR_HGRAY //"MEDICAL.BMP"
   else
   MENU oMenu FONT oMenuFont HEIGHT -2.00 COLORBMP CLR_HGRAY //"MEDICAL.BMP"
   endif

  oMenu:l2007   := .F.
  oMenu:l2010   := .F.
  oMenu:l2013   := .F.
  oMenu:l2015   := .F.
  oMenu:lColors := .F.
  DO CASE
     CASE n = 1
        oMenu:l2007   := .T.
     CASE n = 2
        oMenu:l2010   := .T.
     CASE n = 3
        oMenu:l2013   := .T.
     CASE n = 4
        oMenu:l2015   := .T.
  ENDCASE
  // if n > 0
     // ONLY IF FONT, HEIGHT OR ANY COLORS IS CHANGED, EVEN IF THERE IS NO ACTIVE THEME
     oMenu:lColors := .T.
  // endif

  MENUITEM "File"
     MENU
        MENUITEM "New"
        MENUITEM "Open"
        MENUITEM "Exit" ACTION oWnd:End()
     ENDMENU

  MENUITEM "Edit"
     MENU
        MENUITEM "Copy"
        MENUITEM "Paste"
     ENDMENU

  MENUITEM "Help"
     MENU
        MENUITEM "About"
     ENDMENU
   ENDMENU

   oWnd:SetMenu(oMenu)

RETURN nil

//-------------------------------------------------------------------//

FUNCTION SetMenuTheme(n) 

   DO CASE
      CASE n = 1
           cTheme        := "2007"
      CASE n = 2
           cTheme        := "2010"
      CASE n = 3
           cTheme        := "2013"
      CASE n = 4
           cTheme        := "2015"
      CASE n = 0
           cTheme        := "NONE"
   ENDCASE 

   oWnd:SetText( "Menu Theme Change - Runtime: " + cTheme )
   BuildMenu( n )

RETURN nil

//-------------------------------------------------------------------//

Please note that any changes you make to the menu's color characteristics will only take effect if the selected style is 2013; the other styles are predefined and cannot be changed. The 2013 style is for this purpose.
Then

Code: Select all | Expand

   oItem:nClrMenu := oMenu:nClrMenu
   oItem:nClrText := oMenu:nClrText
   oItem:nClrToBa := oMenu:nClrToBa
   oItem:nClrBkBa := oMenu:nClrBkBa
   oItem:nClrHiLi := oMenu:nClrHiLi
   oItem:nClrHiLf := oMenu:nClrHiLf
   oItem:nClrHitx := oMenu:nClrHitx
   oItem:nClrHiBr := oMenu:nClrHiBr
   oItem:nClrToBr := oMenu:nClrToBr
   oItem:nClrBkBr := oMenu:nClrBkBr
   oItem:nClrBox1 := oMenu:nClrBox1

has no effect, only with l2013 := .T.


Re: HOW TO CHANGE FW MENU THEMES AT RUNTIME

Posted: Mon Dec 08, 2025 1:07 am
by RAMESHBABU

Dear Cristobal,

Your sample has solved my problem.

Thank you very much.

-Ramesh Babu