Re: win32lib Q: Can a MenuItem be changed?

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

I've got an example here which may help you...

-------------
include win32lib.ew
without warning

constant
Win = create(Window, "test", 0, 0, 0, 500, 500, 0),
MyMenu1 = create( Menu, "List of Male Authors", Win, 0, 0, 0, 0, 0 ),
  Menu_item1 = create(MenuItem,"Matthew Reilly",MyMenu1,0,0,0,0,0),
  Menu_item2 = create(MenuItem,"Andy McNabb",MyMenu1,0,0,0,0,0),
  Menu_item3 = create(MenuItem,"Chris Ryan",MyMenu1,0,0,0,0,0),
MyMenu2 = create( Menu, "List of Female Authors", Win, 0, 0, 0, 0, 0 ),
  Menu_item4 = create(MenuItem,"Anne McCaffrey",MyMenu2,0,0,0,0,0),
  Menu_item5 = create(MenuItem,"Ursula le Guin",MyMenu2,0,0,0,0,0),
  Menu_item6 = create(MenuItem,"Nancy Kress",MyMenu2,0,0,0,0,0)

procedure onClick_MI(integer self, integer event, sequence parms)
    atom void
    atom posn
    atom hmenu
    atom pstring
    sequence text
    integer parent
trace(1)
    -- Find out which menu this belongs to.
    parent = findParent(self)
    -- The menu's handle
    hmenu = getHandle(parent)

    -- Allocate a largish text buffer
    pstring = acquire_mem(0, 3000)
    -- Get the current menu item text
    void = w32Func(xGetMenuString, {hmenu, self, pstring, 3000,
MF_BYCOMMAND})
    text = peek_string(pstring)
    release_mem(pstring)

    -- Append a '!' to the menu item text.
    pstring = acquire_mem(0, text & "!")
    void = w32Func(xModifyMenu, {hmenu, self, MF_BYCOMMAND, self, pstring})
    release_mem(pstring)

end procedure

setHandler({Menu_item1, Menu_item2, Menu_item3,
            Menu_item4, Menu_item5, Menu_item6}, w32HClick,
              routine_id("onClick_MI"))

  WinMain(Win,0)
-------------
Derek


----- Original Message -----
From: <jstory at freenet.edmonton.ab.ca>
To: "EUforum" <EUforum at topica.com>
Sent: Tuesday, February 05, 2002 8:11 AM
Subject: win32lib Q: Can a MenuItem be changed?


>
>
> ------ EXAMPLE
> constant
> MyMenu = create( Menu, "List of Items", Win, 0, 0, 0, 0, 0 ),
>   Menu_item = create(MenuItem,"Baba Yaga the Witch",MyMenu,0,0,0,0,0)
>
> setText(Menu_item,"Santa Claus")  -- This doesn't work.
>
> setCaption(Menu_item,"Santa Claus")  -- This doesn't work.
>
> ------ END OF EXAMPLE
>
> Can a MenuItem be changed?  If so, how in win32lib?
>
>
>        Jerry Story
>
>
>
>

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

Search



Quick Links

User menu

Not signed in.

Misc Menu