Re: How to change text of top level menu

new topic     » goto parent     » topic index » view thread      » older message » newer message

----- Original Message -----
From: "Judith Evans" <camping at txcyber.com>
To: "EUforum" <EUforum at topica.com>
Subject: How to change text of top level menu


>
> Here is some code Wolf sent me that works.

Thanks Judith,
what confused me was that the API Documentation talks about modifying
MenuItems and not Menus. And that the code you supply here is almost
identical to what's in win32lib.

> -- Wolf: this modifies the second top level menu in the bar, if pos is 1.
> procedure zmodifymenu(integer pos, sequence newstring, integer MyWin)
> atom main_id, str_ptr, menu_id,jk
> --zero indexed, top bar only sad
>   main_id = getHandle(MyWin)
>   menu_id = w32Func(xGetMenu,{main_id})
>   str_ptr = allocate_string(newstring)
>   jk = w32Func(xModifyMenu,{menu_id,pos,#400,0,str_ptr})
>   free(str_ptr)
>   jk = w32Func(xDrawMenuBar,{main_id})
> end procedure

The difference was that Wolf's code uses BYPOSITION (#400) as the flag
rather than BYCOMMAND. The BYCOMMAND flag is supposed to use the ID of the
menu/menuitem but this was only working for menu items. After some more
exploring I discovered that the 'id' field in Menus (when created) is not
the ID but the ID's handle! So I changed the setTExt() to use the handle
instead and now it works for both menus and menuitems. This also made me
revisit getText() for menus and there I discovered that it would not work
for Menus either. So I fixes that too.

In summary, setText() and getText() should now work for menus and menuitems.

You get a copy from ...

  http://www.users.bigpond.com/ddparnell/euphoria/w32005803.zip



----------------
cheers,
Derek Parnell

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu