1. 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

new topic     » topic index » view message » categorize

2. Re: Win32lib menus

I probably don't understand what you're trying to do, but it seems to me
that all you have to do is execute a sendMessage() in the onMenu
procedure for the event you want to trigger.

Michael J. Sabal

>>> wolfritz at KING.IGS.NET 06/17/02 01:35PM >>>

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

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

3. Re: Win32lib menus

Thanks for the explanation Derek;  I see that in my "RunDemos.exw" I am
completely violating that paradigm of the menu bar, (using buttons instead
of menu selectors), some of which do things immediately, and others offer
the user a selection of things to do.  I had done that originally to
"solve"
the problem Wolf mentioned, namely wanting to let the user cause things to
happen as soon as they were clicked on in a top "menu"-like bar, and then
I
ran into things which needed to allow user choice, so I just made them
function from buttons too.

I see now I should include a menu bar for things with choices, and buttons
for immediate actions.

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);
2.  and, as a complement, auto sizing of any button to the size of the
created text?

Dan Moyer


----- Original Message -----
From: "Derek Parnell" <Derek.Parnell at SYD.RABOBANK.COM>
To: "EUforum" <EUforum at topica.com>
Sent: Monday, June 17, 2002 3:09 PM
Subject: RE: Win32lib menus


>
> 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
> >
> >
> >
> >
>
> ==================================================================
>
>
> ==================================================================
>
>
>
>

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

4. Re: Win32lib menus

Matt,

Yes, you can trap a click on a MenuItem, but that's not what Wolf was asking
about.

He (& as it turns out, me too), wants to be able to click on a *top level*
menu display, and have a programmable action occur;  he's not talking, I
think, about clicking on an *menu item* that's *under* a top level menu
display.

If you have a top level menu display "File", and an item under it, "Open",
you can trap a click on the MenuItem "Open", but not on the top level Menu
"File".

I don't know what Wolf's wants to do, but I have some alternative selection
option windows (windows with a series of selection options in them) that I
would want to open by clicking on a top level Menu, instead of having it
open a regular menu items selection display.

So does anyone have a way to allow for that??

Dan Moyer


----- Original Message -----
From: "Matthew Lewis" <matthewwalkerlewis at YAHOO.COM>
To: "EUforum" <EUforum at topica.com>
Sent: Monday, June 17, 2002 11:05 AM
Subject: 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     » goto parent     » topic index » view message » categorize

5. 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 ?

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

6. 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;

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?)

Dan Moyer


----- Original Message -----
From: "Derek Parnell" <Derek.Parnell at SYD.RABOBANK.COM>
To: "EUforum" <EUforum at topica.com>
Sent: Monday, June 17, 2002 11:34 PM
Subject: RE: Win32lib menus


>
> 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 ?
> >
> >
> >
> ==================================================================
>
>
> ==================================================================
>
>
>
>

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

7. Re: Win32lib menus

> However, to do what you want, please make these
> minor changes to win32lib...

Thanks Derek, for that little lesson in win32lib modification.
Works great !.

... and Dan, that first '!' doesn't show up in the menubar, it's only a tag to
tell win32lib that you want to create a
top level 'command' menu, in the same fashion that '&' is used to indicate the (
underlined ) keyboard shortcut in
menu's.

Wolf

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

8. Re: Win32lib menus

>Thanks Derek, for that little lesson in win32lib modification.
>Works great !.
>
>... and Dan, that first '!' doesn't show up in the menubar, it's only a tag 
>to tell win32lib that you want to create a
>top level 'command' menu, in the same fashion that '&' is used to indicate 
>the ( underlined ) keyboard shortcut in
>menu's.
>
>Wolf

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...

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

If you call this function, a new menu command item will be created and a 
WM_COMMAND message will be sent to the parent window when it is clicked.  
Enjoy.


-=-=-=-=-=-=-=-=-=-=-=-=-
constant
xSetMenuItemInfo = registerw32Function( user32, "SetMenuItemInfoA", 
{C_POINTER,C_LONG,C_LONG,C_POINTER}, C_LONG )

-- create command menu item
function createCMI( sequence Caption, atom ParentID )
	atom NewMenuItem
	atom hMenu, MenuCount
	atom lpmii
	atom MenuID
	atom MenuText
	atom TextBuffer
	atom Void

	NewMenuItem = create( Menu, Caption, ParentID, 0, 0, 0, 0, 0 )
	hMenu = w32Func( xGetMenu, {getHandle(ParentID)} )
	MenuCount = w32Func( xGetMenuItemCount, {hMenu} )

	MenuText = allocate_string( Caption )
	TextBuffer = allocate( length(Caption)+1 )
	for MenuIter = 0 to MenuCount-1 do
		mem_set( TextBuffer, 0, length(Caption) )
		Void = w32Func( xGetMenuString, 
{hMenu,MenuIter,TextBuffer,length(Caption)+1,#400} )
		if compare( peek({TextBuffer,length(Caption)}), Caption ) = 0 then
			MenuID = MenuIter
		end if
	end for
	free( MenuText )
	free( TextBuffer )

	lpmii = allocate( 44 )
	mem_set( lpmii, 0, 44 )
	poke4( lpmii, {44,#4} )
	Void = w32Func( xSetMenuItemInfo, {hMenu,MenuID,1,lpmii} )
	free( lpmii )

	return( NewMenuItem )
end function

HelpMenu = createCMI( "&Help", hWin )
-=-=-=-=-=-=-=-=-=-=-=-=-

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

9. 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, so I thought he was
putting the "!" in the menubar text itself to accomplish both user alert and
program differentiation between immediate and popup behavior.  Plus I didn't
even *see* the line,
setText(self, text[2..length(text)]),
nor did I (yet) modify Win32Lib & *run* the program to see what it looked
like.

Reading the code, though, still seems like any "!" in the menubar names
*are* set & display initially, and are only removed the first time the user
clicks on each one?

Don't have time right now to test it myself, but I guess you did.  Thanks
for raising the question in the first place!  :)

Dan

----- Original Message -----
From: "Wolf" <wolfritz at KING.IGS.NET>
To: "EUforum" <EUforum at topica.com>
Sent: Tuesday, June 18, 2002 5:27 AM
Subject: Re: Win32lib menus


>
> > However, to do what you want, please make these
> > minor changes to win32lib...
>
> Thanks Derek, for that little lesson in win32lib modification.
> Works great !.
>
> ... and Dan, that first '!' doesn't show up in the menubar, it's only a
tag to tell win32lib that you want to create a
> top level 'command' menu, in the same fashion that '&' is used to indicate
the ( underlined ) keyboard shortcut in
> menu's.
>
> Wolf
>
>
>
>

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

10. 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!

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?

Dan Moyer

----- Original Message -----
From: "Don Phillips" <Graebel at hotmail.com>
To: "EUforum" <EUforum at topica.com>
Sent: Tuesday, June 18, 2002 10:48 AM
Subject: Re: Win32lib menus


>
> >Thanks Derek, for that little lesson in win32lib modification.
> >Works great !.
> >
> >... and Dan, that first '!' doesn't show up in the menubar, it's only a
tag
> >to tell win32lib that you want to create a
> >top level 'command' menu, in the same fashion that '&' is used to
indicate
> >the ( underlined ) keyboard shortcut in
> >menu's.
> >
> >Wolf
>
> 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...
>
> Anyways.  On my system (Win 2k) I put together this code (just now) and it
> seems to run just fine.
>
> If you call this function, a new menu command item will be created and a
> WM_COMMAND message will be sent to the parent window when it is clicked.
> Enjoy.
>
>
> -=-=-=-=-=-=-=-=-=-=-=-=-
> constant
> xSetMenuItemInfo = registerw32Function( user32, "SetMenuItemInfoA",
> {C_POINTER,C_LONG,C_LONG,C_POINTER}, C_LONG )
>
> -- create command menu item
> function createCMI( sequence Caption, atom ParentID )
> atom NewMenuItem
> atom hMenu, MenuCount
> atom lpmii
> atom MenuID
> atom MenuText
> atom TextBuffer
> atom Void
>
> NewMenuItem = create( Menu, Caption, ParentID, 0, 0, 0, 0, 0 )
> hMenu = w32Func( xGetMenu, {getHandle(ParentID)} )
> MenuCount = w32Func( xGetMenuItemCount, {hMenu} )
>
> MenuText = allocate_string( Caption )
> TextBuffer = allocate( length(Caption)+1 )
> for MenuIter = 0 to MenuCount-1 do
> mem_set( TextBuffer, 0, length(Caption) )
> Void = w32Func( xGetMenuString,
> {hMenu,MenuIter,TextBuffer,length(Caption)+1,#400} )
> if compare( peek({TextBuffer,length(Caption)}), Caption ) = 0 then
> MenuID = MenuIter
> end if
> end for
> free( MenuText )
> free( TextBuffer )
>
> lpmii = allocate( 44 )
> mem_set( lpmii, 0, 44 )
> poke4( lpmii, {44,#4} )
> Void = w32Func( xSetMenuItemInfo, {hMenu,MenuID,1,lpmii} )
> free( lpmii )
>
> return( NewMenuItem )
> end function
>
> HelpMenu = createCMI( "&Help", hWin )
> -=-=-=-=-=-=-=-=-=-=-=-=-
>
>
>
>

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

11. Re: Win32lib menus

> HelpMenu = createCMI( "&Help", hWin )

Thanks, Don, works great "out of the box" in Win98, as well.
Wolf

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

12. Re: Win32lib menus

I should'a known Wolf was right!  Thanks for the explanation.

Dan

----- Original Message -----
From: "Derek Parnell" <Derek.Parnell at SYD.RABOBANK.COM>
<SNIP>

> 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.
>
>

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

Search



Quick Links

User menu

Not signed in.

Misc Menu