RE: Win32lib menus

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

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C21692.24F3F800
 charset=iso-8859-1

Wolf,
the reason that win32lib doesn't do it at the moment, is that it ONLY
creates POPUP styled menus. However, to do what you want, please make these
minor changes to win32lib...

1) Find the routine called "createMenu"

2) Add these local variables to the routine...

    atom mstyle
    atom mid

3) Find the lines ...

        pstr = acquire_mem( 0, mText )
        result = w32Func( xAppendMenu, {
	            attachTo,
	            MF_POPUP,
	            getHandle( id ),
	            pstr} )
        release_mem(pstr)

and replace them with...

        mstyle = find('!', mText) 
        if mstyle != 0 then
            mText = mText[1..mstyle-1] & mText[mstyle+1..length(mText)]
            mstyle = 0
            mid = id
        else
            mstyle = MF_POPUP
            mid = getHandle(id)
        end if
        result = w32Func( xAppendMenu, {
	            attachTo,
	            mstyle,
	            mid,
	            mText} )

**Please note, that you can delete the acquire_mem() and release_mem() pair
as they are redundant.

4) In the routine "getText" replace the lines...

    elsif window_type[id] = MenuItem then
        -- Get Menu's handle
        lHandle = getHandle(findParent(id))

with 

    elsif find(window_type[id], {MenuItem, Menu}) then
        -- Get Menu's handle  
        if window_type[id] = Menu then
            lHandle = window_menu[ window_owner[id] ]
        else
            lHandle = getHandle(findParent(id))
        end if

5) In the routine setText() replace the lines...

    elsif window_type[id] = MenuItem then
        -- Get Menu's handle  
       lHandle = getHandle(findParent(id))

with

    elsif find(window_type[id], {MenuItem, Menu}) then
        -- Get Menu's handle  
        if window_type[id] = Menu then
            lHandle = window_menu[ window_owner[id] ]
        else
            lHandle = getHandle(findParent(id))
        end if

---------------
To cause the effect you want, create the menu in the normal way, except you
must include the '!' character in the menu text.

For example:

-----------------
include win32lib.ew

constant SimpleWin =  create( Window, "Simple Window", 0, 0, 0, 300,200, 0
),
         SB        =  create(StatusBar, "", SimpleWin, 0, 0, 0, 0, 0),
         menu      =  create(Menu,"Options",SimpleWin,0,0,0,0,0),
         menu1     =  create(MenuItem,"Cold",menu,0,0,0,0,0),
         menu2     =  create(MenuItem,"Warm",menu,0,0,0,0,0),
         menu3     =  create(MenuItem,"Hot",menu,0,0,0,0,0), 
         sep1      =  create(MenuItem,"-", menu, 0, 0, 0, 0, 0),         
         menu4     =  create(MenuItem,"Color",menu,0,0,0,0,0),
         menucmd   =  create(Menu, "!BANG", SimpleWin, 0, 0 ,0,0,0),
         menucmd2  =  create(Menu, "!POW", SimpleWin, 0, 0 ,0,0,0)


---------------------------------
procedure w32HClick_menu(integer self,integer event,sequence params)
---------------------------------
    sequence text

    text = getText(self)
    setText(SB, text)
    if text[1] = '!' then
        setText(self, text[2..length(text)])
        repaintWindow(0)  -- Force the menu to be re-rendered.
    end if
end procedure

setHandler({menucmd,menucmd2,menu1,menu2,menu3,menu4},w32HClick,routine_id("
w32HClick_menu"))
WinMain(SimpleWin, Normal)
-----------------
cheers,
Derek.

> -----Original Message-----
> From: Wolf [mailto:wolfritz at KING.IGS.NET]
> Sent: Tuesday, 18 June 2002 15:08
> To: EUforum
> Subject: Re: Win32lib menus
> 
> 
> 
> > So does anyone have a way to allow for that??
> > Dan Moyer
> 
> Apparently not in win32lib, though it's easy in API, or any 
> Win C compiler.
> Win32lib seems to swallow up every menu related message 
> except for WM_INITMENUPOPUP,
> < chuckle here blink >
> ,  and a ( 293 ), I don't know the meaning of, which it 
> passes on to an onEvent[].
> 
> Having seen that awful word paradigm, I assume, loosely 
> translated, it means, let's not point out the obvious illiteracy
> of our colleagues, and make their past blunderings a de-facto 
> standard. Good grief, even Microsoft can't make up it's
> mind whether to use File > Close, or File > Exit, even though 
> the reference to File may only be an inference.
> Program > Quit would have been much more intuitive in the 
> English language.
> The same can be said for the standard Help > About, even 
> though there may be no Help to be found.
> 
> Writing this in Outlook Express, I'm amused that it's main 
> function is buried under:
> Tools > Send and Receive > Send and Receive All.
> Then, to compensate for this mess, they give us a [Ctrl+M] hot-key.
> 
> Personally, I'd prefer those 'button's' in a menu bar, that 
> don't take up any additional real estate, and simply do what
> they say, like Quit, or About, or ( do the obvious ).
> 
> ... so, uh, what's that 293 message ?
> 
> 
> 
> 

==================================================================
De informatie opgenomen in dit bericht kan vertrouwelijk zijn en 
is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht 
onterecht ontvangt wordt u verzocht de inhoud niet te gebruiken en 
de afzender direct te informeren door het bericht te retourneren. 
==================================================================
The information contained in this message may be confidential 
and is intended to be exclusively for the addressee. Should you 
receive this message unintentionally, please do not use the contents 
herein and notify the sender immediately by return e-mail.


==================================================================

------_=_NextPart_000_01C21692.24F3F800
Content-Type: application/ms-tnef

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

Search



Quick Links

User menu

Not signed in.

Misc Menu