1. setEnable MENU

Hello,

is it possible to disable Menu with command setEnable in Win32lib? 
I can disable menuItem, but no Menu. I tried it with arwen and it worked.

Thanks Vlado

new topic     » topic index » view message » categorize

2. Re: setEnable MENU

Vlado Kusnirak wrote:
> 
> Hello,
> 
> is it possible to disable Menu with command setEnable in Win32lib? 
> I can disable menuItem, but no Menu. I tried it with arwen and it worked.
> 

I've found a solution ( I think).

You need to make a small change to the setEnable() routine inside win32lib.ew.

Replace

  if w32Func( xEnableMenuItem, {
        lHandle,        -- menu handle
        id,                     -- id
        flag} )= #FFFFFFFF      -- enable/disble
  then


with 

  if w32Func( xEnableMenuItem, {
        lHandle,        -- menu handle
        w32iff(ctrl_Family[id]=MENU, ctrl_Menu[id][3],id),
        flag} )= #FFFFFFFF      -- enable/disble
  then




-- 
Derek Parnell
Melbourne, Australia
Skype name: derek.j.parnell

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

3. Re: setEnable MENU

Derek Parnell wrote:
> 
> Vlado Kusnirak wrote:
> > 
> > Hello,
> > 
> > is it possible to disable Menu with command setEnable in Win32lib? 
> > I can disable menuItem, but no Menu. I tried it with arwen and it worked.
> > 
> 
> I've found a solution ( I think).
> 
> You need to make a small change to the setEnable() routine inside win32lib.ew.
> 
> Replace
> 
>   if w32Func( xEnableMenuItem, {
>         lHandle,        -- menu handle
>         id,                     -- id
>         flag} )= #FFFFFFFF      -- enable/disble
>   then
> 
> 
> with 
> 
>   if w32Func( xEnableMenuItem, {
>         lHandle,        -- menu handle
>         w32iff(ctrl_Family[id]=MENU, ctrl_Menu[id][3],id),
>         flag} )= #FFFFFFFF      -- enable/disble
>   then
> 

Hmm...it doesn't work. I have version 0.60.6 of WinLib. There is a code...

include win32lib.ew

without warning
atom void


constant win_title = "Demonstration of Menu features in ARWEN"
constant CHECKSUBMENU = {"Check SubMenu", "Uncheck SubMenu"}

constant DEMO = create(Window,  win_title, 0, 0, 10,10,650,350)

constant MENU = create(Menu, "&A Menu" , 0, DEMO, 0,0,0,0)

constant MENU1 = create(MenuItem,  "&These are" , 0, MENU, 0,0,0,0)
constant MENU2 = create(MenuItem,  "t&ypical" , 0, MENU, 0,0,0,0)
void =  create(MenuItem, "-" , 0, MENU, 0,0,0,0)
constant MENU3 = create(MenuItem,  "menu" , 0, MENU, 0,0,0,0)
constant MENU4 = create(MenuItem,  "entries" , 0, MENU, 0,0,0,0)
void =  create(MenuItem,  "-" , 0, MENU, 0,0,0,0)
constant MENU5 = create(MenuItem,  "[ Exit ]" , 0, MENU, 0,0,0,0)

openWindow(DEMO, 0)

setEnable(MENU, w32False)
setEnable(MENU1, w32False)

WinMain(DEMO, SW_NORMAL)


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

4. Re: setEnable MENU

Vlado Kusnirak wrote:
> 
> Derek Parnell wrote:
> > 
> > Vlado Kusnirak wrote:
> > > 
> > > Hello,
> > > 
> > > is it possible to disable Menu with command setEnable in Win32lib? 
> > > I can disable menuItem, but no Menu. I tried it with arwen and it worked.
> > > 
> > 
> > I've found a solution ( I think).
> > 
> > You need to make a small change to the setEnable() routine inside
> > win32lib.ew.
> > 
> > Replace
> > 
> >   if w32Func( xEnableMenuItem, {
> >         lHandle,        -- menu handle
> >         id,                     -- id
> >         flag} )= #FFFFFFFF      -- enable/disble
> >   then
> > 
> > 
> > with 
> > 
> >   if w32Func( xEnableMenuItem, {
> >         lHandle,        -- menu handle
> >         w32iff(ctrl_Family[id]=MENU, ctrl_Menu[id][3],id),
> >         flag} )= #FFFFFFFF      -- enable/disble
> >   then
> > 
> 
> Hmm...it doesn't work. I have version 0.60.6 of WinLib. There is a code...
> 
> }}}
<eucode>
> include win32lib.ew
> 
> without warning
> atom void
> 
> 
> constant win_title = "Demonstration of Menu features in ARWEN"
> constant CHECKSUBMENU = {"Check SubMenu", "Uncheck SubMenu"}
> 
> constant DEMO = create(Window,  win_title, 0, 0, 10,10,650,350)
> 
> constant MENU = create(Menu, "&A Menu" , 0, DEMO, 0,0,0,0)
> 
> constant MENU1 = create(MenuItem,  "&These are" , 0, MENU, 0,0,0,0)
> constant MENU2 = create(MenuItem,  "t&ypical" , 0, MENU, 0,0,0,0)
> void =  create(MenuItem, "-" , 0, MENU, 0,0,0,0)
> constant MENU3 = create(MenuItem,  "menu" , 0, MENU, 0,0,0,0)
> constant MENU4 = create(MenuItem,  "entries" , 0, MENU, 0,0,0,0)
> void =  create(MenuItem,  "-" , 0, MENU, 0,0,0,0)
> constant MENU5 = create(MenuItem,  "[ Exit ]" , 0, MENU, 0,0,0,0)
> 
> openWindow(DEMO, 0)
> 
> setEnable(MENU, w32False)
> setEnable(MENU1, w32False)
> 
> WinMain(DEMO, SW_NORMAL)
> 
> </eucode>
{{{


And it couldn't work:
<MSDN>
An application must use the MF_BYPOSITION flag to specify the correct menu 
handle. If the menu handle of the menu bar is specified, the top-level menu 
item (an item in the menu bar) is affected. To set the state of an item in 
a pop-up or nested pop-up menu by position, an application must specify the 
handle of the pop-up menu. 
</MSDN>

In the mods I'm working on, I changed a few "by command" actions to 
"by position" ones, because they wouldn't work on pop up menus, but only on 
menu items (because menus have no id). Note that getMenuPosn() has the same 
problem, for the same reason.

CChris

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

5. Re: setEnable MENU

Vlado Kusnirak wrote:
> 
 
> Hmm...it doesn't work. I have version 0.60.6 of WinLib. There is a code...

Does for me. I ran your code verbatim and the "A Menu" was disabled.

You can use the win32lib.ew that I used 

   http://www.users.bigpond.com/ddparnell/win32lib.ew 

-- 
Derek Parnell
Melbourne, Australia
Skype name: derek.j.parnell

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

6. Re: setEnable MENU

CChris wrote:

> And it couldn't work:

And yet it does. 

-- 
Derek Parnell
Melbourne, Australia
Skype name: derek.j.parnell

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

7. Re: setEnable MENU

Derek Parnell wrote:
> 
> Vlado Kusnirak wrote:
> > 
>  
> > Hmm...it doesn't work. I have version 0.60.6 of WinLib. There is a code...
> 
> Does for me. I ran your code verbatim and the "A Menu" was disabled.
> 
> You can use the win32lib.ew that I used 
> 
>    <a
>    href="http://www.users.bigpond.com/ddparnell/win32lib.ew">http://www.users.bigpond.com/ddparnell/win32lib.ew</a>
>

Derek, Are there major changes in this version compared to 0.60.6?
> 
> -- 
> Derek Parnell
> Melbourne, Australia
> Skype name: derek.j.parnell

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

8. Re: setEnable MENU

Derek Parnell wrote:
> 
> Vlado Kusnirak wrote:
> > 
>  
> > Hmm...it doesn't work. I have version 0.60.6 of WinLib. There is a code...
> 
> Does for me. I ran your code verbatim and the "A Menu" was disabled.
> 
> You can use the win32lib.ew that I used 
> 
>    <a
>    href="http://www.users.bigpond.com/ddparnell/win32lib.ew">http://www.users.bigpond.com/ddparnell/win32lib.ew</a>
>
> 

Thank you very much. It works now.

Vlado

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

9. Re: setEnable MENU

Derek Parnell wrote:
> You can use the win32lib.ew that I used 
>    <a
>    href="http://www.users.bigpond.com/ddparnell/win32lib.ew">http://www.users.bigpond.com/ddparnell/win32lib.ew</a>
>

Derek, your version doesn't have getTVChildren(). It's in my win32lib as
modified by Sascha Zindel and Derek Parnell.

Here's the added code in my version. Maybe you can add it to yours...?

--BEG CJT01
-----------------------------------------------------------------------------
--/topic Tree View Control
--/func deleteTVChildren( TheTreeView, position )
--/desc Deletes all children at "position" in the /i tree view.
--
-- Example:
--/code
--          atom position
--          position = getTVIndex(TheTreeView)
--          /deleteTVChildren( TheTreeView, position )
--/endcode

global procedure deleteTVChildren( atom id, integer pos )

    atom iItem

    -- Is a treeview?
    if ctrl_Type[ id ] = TreeView then
        -- take care of any children
        iItem = find(pos, tvitem_parent)
        while iItem do
            VOID = deleteItem( id, iItem )
	        iItem = find(pos, tvitem_parent)
        end while
    end if

end procedure

-----------------------------------------------------------------------------
--/topic Tree View Control
--/func getTVChildren( TheTreeView, position )
--/desc Returns all child items for the passed item in the /i tree view.
--
-- Example:
--/code
--          atom position
--          sequence children
--
--          position = getTVIndex(TheTreeView)
--          children = /getTVChildren( TheTreeView, position )
--/endcode

global function getTVChildren(atom id, integer pos)

    sequence children

    children = {}

    -- Is a treeview?
    if ctrl_Type[ id ] = TreeView then
        -- take care of any children
        for i = 1 to length(tvitem_parent) do
            if tvitem_owner[i] = id and tvitem_parent[i] = pos then
                children &= i
                children &= getTVChildren(id, i)
            end if
        end for
    end if
    return children
end function
--END CJT01

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

10. Re: setEnable MENU

Derek Parnell wrote:
> 
> CChris wrote:
> 
> > And it couldn't work:
> 
> And yet it does. 
> 
> -- 
> Derek Parnell
> Melbourne, Australia
> Skype name: derek.j.parnell

Interesting, because I had the same problem as Vlado. And I cant remember
any note about this popup menu id issue being diffrent across OS versions...

CChris

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

Search



Quick Links

User menu

Not signed in.

Misc Menu