1. RE: Win32lib menus

> -----Original Message-----
> From: Wolf [mailto:wolfritz at KING.IGS.NET]

> Has anyone ever figured out  if / how  ...  a 'command' menu 
> type can be added to win32lib code.
> This is an item in the top menu bar that will trigger an 
> event if clicked. There is no associated 'popup', ( or dropdown
> blink  )

I thought you could simply trap the onClick event for the MenuItem (really a
WM_COMMAND message:).

Matt Lewis

new topic     » topic index » view message » categorize

2. RE: Win32lib menus

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_01C2164B.8E89D0B0
 charset=iso-8859-1

Wolf,
it has been suggested by a few GUI specialists that the "command" type of
Menu is poor programming practice. It is in effect a button on the menu bar.
The paradigm of a menu is that users can browse their options before
selecting. Placing a 'button' that looks like a menu can be confusing for
beginners and experienced users alike. Their normal expectation is that by
clicking on the 'button' that a list of menu items will dropdown. But by
changing this paradigm so that clicking will cause a program action instead,
could lead to an inconsistent user interface. 

The three common solutions to this UI affordance is to either ...
 a) Add some visual clue as to the menu's true nature, such as a "!" in its
text.
 b) Add a single menuitem to it that actually performs the programmed action
when selected.
 c) Don't use a command menu at all, but use a button. Either on the
window's background surface or in a toolbar. In fact I think this is the
very reason that toolbars became into use.

-------------
Derek.

> -----Original Message-----
> From: Wolf [mailto:wolfritz at KING.IGS.NET]
> Sent: Tuesday, 18 June 2002 3:38
> To: EUforum
> Subject: Win32lib menus
> 
> 
> 
> Has anyone ever figured out  if / how  ...  a 'command' menu 
> type can be added to win32lib code.
> This is an item in the top menu bar that will trigger an 
> event if clicked. There is no associated 'popup', ( or dropdown
> blink  )
> 
> Wolf
> 
> 
> 
> 

==================================================================
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_01C2164B.8E89D0B0
Content-Type: application/ms-tnef

new topic     » goto parent     » topic index » view message » categorize

3. RE: Win32lib menus

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_01C21656.FE53F9B0
 charset=iso-8859-1


> -----Original Message-----
> From: Dan Moyer [mailto:DANIELMOYER at prodigy.net]
> Subject: Re: Win32lib menus
> 
> 
 [snip]

> Oh, and here's something(s) you might consider adding to the bottom of
> your
> todo list:
> 1.  toolbar creation work like menu bar, so that each item added is
> automatically placed to right of the previously added one, including
> "spacers" (like Judith does in her IDE);

I've never really worked with toolbars yet so I haven't noticed that it
doesn't do this. It sounds a reasonable request.

> 2.  and, as a complement, auto sizing of any button to the size of the
created text?

This one is already on the list. I'm thinking it will work as 'extended'
styles for some controls, ie. AutoWidth, AutoHeight. Such that when the
control's text is set, the control's dimensions will change so that the text
is always visible.  This can be applied to buttons, static text (LText,
etc...), Edit boxes and maybe StatusBar panels.

----------
Derek.

==================================================================
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_01C21656.FE53F9B0
Content-Type: application/ms-tnef

new topic     » goto parent     » topic index » view message » categorize

4. RE: Win32lib menus

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 message » categorize

5. RE: Win32lib menus

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_01C2170F.56C56300
 charset=iso-8859-1

> -----Original Message-----
> From: Dan Moyer [mailto:DANIELMOYER at prodigy.net]
> Subject: Re: Win32lib menus
> 
> 
> 
> Derek,
> 
> Two questions about your code to allow immediate action from 
> a top-level
> menu "thingy"  (can't call it a menu "item"):
> 
> 1.  will this code be included in Win32Lib?  I ask because 
> I'd use it in
> RunDemos, but since that's for showing Win32Lib demos, the 
> fix would have to
> be available to anyone who was running Win32Lib;

Yes. I've added it already.  That's how I knew what to do.
 
> 2. I'm assuming you're using "!" in the menu text partly to 
> distinguish
> top-level "command" menu thingys from top-level "regular" 
> menu thingys in
> their *behavior*, and partly to *alert* users that a click on 
> a menu thingy
> with "!" in it will result in an immediate action rather than 
> opening up a
> selection pop-up;  but I want to be able to utilize some 
> alternative option
> selection windows rather than the regular selection pop-ups, 
> which wouldn't
> exactly be the normal "immediate" action that would require 
> the "!" to alert
> users.  In other words, I would like to be able to allow 
> users to click on a
> top-level menu thingy and instead of getting some *overt* 
> immediate action,
> it would open up a window with options to select from, 
> similar to a regular
> menu popup, so the menu thingy wouldn't need the "!" to alert 
> them to an
> "immediate" action.  An example of what I mean would be the 
> "Constants" or
> "Help" buttons in RunDemos.exw.
> 
> So would it be possible to allow for *3* possibilities:
> a.  regular menu behavior;
> b.  immediate action discerned & alerted to by "!";
> c.  immediate action used to activate selection options 
> *similar* to regular
> menu behavior, but not using the "!" in the menu thingy text? 
>  (maybe use a
> leading space?)

The first '!' in such a menubar item is removed. So it doesn't show up on
screen. If you want to alert the user that the item has immediate effects,
you would need to add a second '!'.

eg.

    doit = create(Menu, "!!Wipe Hard Drives", myWindow, 0, 0, 0, 0, 0)

-----------
Derek.

==================================================================
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_01C2170F.56C56300
Content-Type: application/ms-tnef

new topic     » goto parent     » topic index » view message » categorize

6. RE: Win32lib menus

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_01C21745.1EEDD300
 charset=iso-8859-1

> -----Original Message-----
> From: Don Phillips [mailto:Graebel at hotmail.com]
> Subject: Re: Win32lib menus
> 
 
> Perhaps it is just me, but anything that needs to modify 
> Win32Lib directly 
> (imho) is just coded wrong.  Makes it very hard to pass code 
> around to other 
> people if your version of Win32Lib is custom...

Yes it would be useful if there was only one library called "win32lib".
However, I can't prevent somebody from changing their copy of the library.

The two ways of getting around the "need" to change one's copy is to get the
changes into the offical library (but this takes time) or create an add-on
to the library. I hope that I've structured the library to enable add-ons to
be created without too much work. I can see you support the add-on approach.

> Anyways.  On my system (Win 2k) I put together this code 
> (just now) and it 
> seems to run just fine.

[snip]

You have done essentially the same as I have. The main difference is that I
do it at create time and you do it after create time.

To summarize your routine...
  --Create a menu (or more accurately - a menubar item -) in the normal
manner.
  --Scan through the window's menubar until you find the one just created.
  --Convert it from a POPUP style to a COMMAND style.

To summarize my routine...
  --If the user asks for a COMMAND style create a COMMAND style menu else
create a POPUP style menu.

Thanks for your routine. It is a neat example that shows that add-ons are
very possible for the library.

-----------
cheers,
Derek.

==================================================================
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_01C21745.1EEDD300
Content-Type: application/ms-tnef

new topic     » goto parent     » topic index » view message » categorize

7. RE: Win32lib menus

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_01C21750.D9CF9E00
 charset=iso-8859-1

> -----Original Message-----
> From: Dan Moyer [mailto:DANIELMOYER at prodigy.net]
> Subject: Re: Win32lib menus
> 
> 
> 
> Wolf,
> 
> Oh, ok, I must have misunderstood; I thought Derek had said 
> it would be good
> to alert the user if clicking on a top-level menu was going 
> to result in an
> immediate action, like with a "!" in the menu bar name

True, I do think this way, but I won't force you to do that though.

>  Plus I didn't
> even *see* the line,
> setText(self, text[2..length(text)]),

That's 'cos I allow the '!' to be anywhere in the text, not just the first
character.

-----------
Derek.

==================================================================
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_01C21750.D9CF9E00
Content-Type: application/ms-tnef

new topic     » goto parent     » topic index » view message » categorize

8. RE: Win32lib menus

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_01C21751.16815640
 charset=iso-8859-1


> -----Original Message-----
> From: Dan Moyer [mailto:DANIELMOYER at prodigy.net]
> Subject: Re: Win32lib menus
> 
> 
> 
> Don,
> 
> That's why I had wondered if Derek was going to include that 
> command menu
> option *in* Win32Lib, but in the meantime I'll try your 
> solution.  Thanks!

It will be in the next release, plus you can still use Don's method as well.

> Does the fact that a WM_COMMAND message will be sent to the 
> parent window
> when it is clicked mean that the event will be picked up by 
> the regular
> on_someEvent handler (or the newer one) in Win32Lib, or does 
> it have to be
> picked up with some kind of "sendMessage" thingy?

Don's method will allow the normal Click handler to pick up the event.

---------
Derek.

==================================================================
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_01C21751.16815640
Content-Type: application/ms-tnef

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu