PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → WinDev Dynamic Menu
WinDev Dynamic Menu
Iniciado por asawyer, 04,nov. 2019 23:19 - 3 respuestas
Publicado el 04,noviembre 2019 - 23:19
I am wanting to create a horizontal menu but fill it dynamically from the database.
I would have a menu table that would have the Menu, submenu, Title, what to run, etc in it. Would probably have roles to show the menu item but I can deal with that.

Does anyone have any simple code to create this? It doesn't have to be fancy, just something to get me started.

Thanks
Miembro registrado
52 mensajes
Publicado el 05,noviembre 2019 - 13:47
you must create an initial menu using Window Editor, then use

MenuAddMenu( source_menu, menu_to_create, caption)

for "header menu items" you must give a source_menu, so you must take this initial menu ( _MENU ):

MenuAddMenu(_Menu, "menu2", "caption_menu2") // this create a new menu called "menu2"
MenuAddMenu(_Menu, "menu3", "caption_menu3") // this create a new menu called "menu3"
MenuAddMenu(_Menu, "menu4", "caption_menu4") // this create a new menu called "menu4"
MenuAddMenu(_Menu, "menu5", "caption_menu5") // this create a new menu called "menu5"

MenuAddMenu("menu2", "menu2_a", "caption_menu2_a") // this create a new submenu called "menu2_a" at "menu2"
MenuAddMenu("menu2", "menu2_b", "caption_menu2_b")
MenuAddMenu("menu2", "menu2_c", "caption_menu2_c")

MenuAddMenu("menu3", "menu3_a", "caption_menu3_a")
MenuAddMenu("menu3", "menu3_b", "caption_menu3_b")

MenuAddOption("menu3_a", "delete_menu2_b", "lets hide/show2b", "hide_show_2b") // this create a new option called "delete_menu2_b" at "menu3_a", wich calls "hide_show_2b" procedure

MenuAddOption("menu3_b", "delete_menu2", "lets hide/show menu2 ", "hide_show_menu2") // this create a new option called "delete_menu2_b" at "menu3_a", wich calls "hide_show_2b" procedure


also create procedures:

Procedure hide_show_2b()
{"menu2_b", indControl}..Visible= NOT {"menu2_b", indControl}..Visible


Procedure hide_show_menu2()
{"menu2", indControl}..Visible= NOT {"menu2", indControl}..Visible



when you create first menu, it was named by system, in spanish it's called "OPT_menú", if you want to change it's caption, use:

OPT_Menú..Caption="mycaptionmenu"



hope to be helpful
Mensaje modificado, 05,noviembre 2019 - 13:49
Miembro registrado
14 mensajes
Publicado el 08,febrero 2020 - 23:36
Sorry I didn't reply sooner, didn't see this answer until yesterday. I was able to get my dynamic menu working, but I have one question.
The app can make a change that would require me to redo my menu. I tried to see if I could understand the enumerate menu command, but not understanding using the WD example they have.

Can someone tell me how I could delete my menu options and menus that I have now create dynamically so I can create the menu again? Maybe there is a simple way, just don't know what it is.

Thanks in advance,
Alan
Miembro registrado
14 mensajes
Publicado el 10,febrero 2020 - 22:00
I ended up creating an Array and loading the names of the menus/submenus into it, then using that to delete the menus... Seems to be working just fine.