Cascading Menus in Win32lib

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

I've tried sending this patch to David several times, but for whatever reason
it just never seems to get there.  I'm not sure if this week's changes to
Win32Lib will affect the patch, but it works fine with version 15a.

---- begin patch -----
procedure createMenu( integer id, sequence mText, integer owner )
    -- used to assign a menu to a window
    -- the structure is already created by create()

    -- set the class to menu
-- NEW! Fixed in 0.14a
    object attachTo

    window_class[ id ] = MENU

    -- if there is no menu for this window, create one
    if window_menu[ owner ] = 0 and window_class[owner] = WINDOW then

        -- create a menu
        window_menu[ owner ] = c_func( xCreateMenu, {} )
        if window_handle[ id ] = NULL then
            -- couldn't create it
            warnErr( "CreateMenu in createMenu failed." )
        end if

        -- attach the menu to the window
        if not c_func( xSetMenu,
            { window_handle[ owner ], window_menu[ owner ] } )
        then
            warnErr( "SetMenu in createMenu failed." )
        end if

    end if

    if window_class[owner] = MENU then
      attachTo = window_handle[owner]
    elsif window_class[owner] = WINDOW then
      attachTo = window_menu[owner]
    end if

    -- create popup menu for this item
    window_handle[ id ] = c_func( xCreatePopupMenu, {} )
    if window_handle[ id ] = NULL then
        warnErr( "CreatePopupMenu in CreateMenu failed." )
    end if

    -- attach a menu item
    if not c_func( xAppendMenu, {
                attachTo,
                MF_POPUP,
                window_handle[ id ],
                allot_string( mText )} )
    then
        -- error
        warnErr( "AppendMenu in createMenu failed." )
    end if

    -- free the string
    free_strings()

end procedure

---- end patch ----------

Hope this helps!

Michael J. Sabal
mjs at osa.att.ne.jp
http://home.att.ne.jp/gold/mjs/index.html

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

Search



Quick Links

User menu

Not signed in.

Misc Menu