-- modify menu texts --
include win32lib.ew
without warning

constant
main=create(Window,"Changing Menu's",0,10,10,300,150,0),
menu=create(Menu,"Menu",main,0,0,0,0,0),
sub=create(MenuItem,"Change 2 New",menu,0,0,0,0,0),
sub2=create(MenuItem,"Undo",menu,0,0,0,0,0),
sub3=create(MenuItem,"E&xit",menu,0,0,0,0,0),
menu2=create(Menu,"Old",main,0,0,0,0,0),
menu2_dropdown=create(MenuItem,"DropDown",menu2,0,0,0,0,0)

atom id,jk

id=getHandle(main)

procedure change()
atom id1,str

-- get handle of main menu bar
id1=w32Func(xGetMenu,{id})

-- poke the new text to memory.
str=acquire_mem(0,"New")
-- modify the second item in the top bar.
jk=w32Func(xModifyMenu,{id1,1,MF_BYPOSITION,1,str})
-- modify the first item in the dropdown.
jk=w32Func(xModifyMenu,{id1,sub,MF_BYCOMMAND,sub,str})
-- modify the first item in the second dropdown.
jk=w32Func(xModifyMenu,
   {id1,menu2_dropdown,MF_BYCOMMAND,menu2_dropdown,str})
release_mem(str)
-- re-draw the main window's menubar to show changes.
jk=w32Func(xDrawMenuBar,{id})
end procedure
----
onClick[sub]=routine_id("change")


procedure un_change()
atom id1,str

-- get handle of main menu bar
id1=w32Func(xGetMenu,{id})

-- poke the original text to memory.
str=acquire_mem(0,"Old")
-- restore the second item in the top bar.
jk=w32Func(xModifyMenu,{id1,1,MF_BYPOSITION,1,str})
release_mem(str)
-- poke the original text to memory.
str=acquire_mem(0,"Change 2 New")
-- restore the first item in the dropdown.
jk=w32Func(xModifyMenu,{id1,sub,MF_BYCOMMAND,sub,str})
release_mem(str)
-- poke the original text to memory.
str=acquire_mem(0,"DropDown")
-- restore the first item in the second dropdown.
jk=w32Func(xModifyMenu,
   {id1,menu2_dropdown,MF_BYCOMMAND,menu2_dropdown,str})
release_mem(str)
-- re-draw the main window's menubar to show changes.
jk=w32Func(xDrawMenuBar,{id})
end procedure
----
onClick[sub2]=routine_id("un_change")

procedure leave()
closeWindow(main)
end procedure
----
onClick[sub3]=routine_id("leave")

WinMain(main,Normal)
