FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour HOW TO CHANGE FW MENU THEMES AT RUNTIME
Posts: 654
Joined: Fri Oct 21, 2005 05:54 AM
HOW TO CHANGE FW MENU THEMES AT RUNTIME
Posted: Sat Dec 06, 2025 01:57 AM

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

#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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: HOW TO CHANGE FW MENU THEMES AT RUNTIME
Posted: Sun Dec 07, 2025 05:43 PM

Dear Ramesh, wait please

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: HOW TO CHANGE FW MENU THEMES AT RUNTIME
Posted: Sun Dec 07, 2025 06:59 PM

Dear Ramesh, try with this sample

#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

   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.

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 654
Joined: Fri Oct 21, 2005 05:54 AM
Re: HOW TO CHANGE FW MENU THEMES AT RUNTIME
Posted: Mon Dec 08, 2025 01:07 AM

Dear Cristobal,

Your sample has solved my problem.

Thank you very much.

-Ramesh Babu

Continue the discussion