BBC BASIC for Windows
General >> Suggestion Box >> Error in manual
http://bb4w.conforums.com/index.cgi?board=suggestions&action=display&num=1392020988

Error in manual
Post by KenDown on Feb 10th, 2014, 07:29am

I don't know whether anyone else has noticed it or whether I am doing something wrong, but the manual page "Disabling a menu item" states, "third parameter is 0 to enable the item and 1 to disable the item (and change it to grey to indicate that it is disabled)."

In fact I find that 1 enables the item and 0 disables it (though usually it only turns gray when you move the mouse over it).

If I'm doing something wrong, I'd be delighted to know what it is. If I'm not, perhaps the manual could be altered?
Re: Error in manual
Post by sbracken on Feb 10th, 2014, 09:13am

I think you must be doing something wrong!

1 corresponds to MF_GRAYED (disable and turn the item gray), and 0 corresponds to MF_ENABLED. You can also use 2 (MF_DISABLED) to disable the item but not turn it gray.

Simon
Re: Error in manual
Post by KenDown on Feb 10th, 2014, 1:29pm

Thanks, I actually know what the manual says. Have you tried *doing* it? I'd be curious to know how you get on.
Re: Error in manual
Post by sbracken on Feb 10th, 2014, 2:12pm

Yes, I have tried it and it works exactly as it should on XP, Vista and 7.

Simon
Re: Error in manual
Post by Matt on Feb 10th, 2014, 2:30pm

Seems to work fine for me, too. Not sure what's happening at your end. Could you list the part of the program that causes this error?

Matt
Re: Error in manual
Post by KenDown on Feb 10th, 2014, 4:39pm

Thanks to everyone for replying. The following is copied and pasted from BB4W as a short program. Put 1 as the parameter in PROCenablemenu(1) and when you click on the menu options "MailMerge" and "Delete" you will get the VDU7 sound.

Change the parameter to 0 and this time not only do you not get the VDU7 sound, but when you move away from the menu option it is grayed out.

Any ideas?

Thanks again.

PROCinit
*SYS 1

click%=0
ON SYS click%=FNsys(@msg%,@wparam%,@lparam%):RETURN
SYS"DragAcceptFiles",@hwnd%,1

REPEAT
pause%=INKEY(1)
CASEclick%OF
WHEN55:VDU7:click%=0
WHEN56:VDU7:click%=0
ENDCASE
UNTILFALSE
:
DEFFNsys(M%,W%,L%)
CASEM%OF
WHEN273:click%=W%AND&FFF
WHEN563:PROCdrag(W%,L%):click%=0
ENDCASE
=click%
:
DEFPROCdrag(W%,L%):w%=W%
SYS"DragQueryFile",W%,-1,0,0TON%
IFN%=0ENDPROC
SYS"DragQueryFile",w%,I%,K%,255
file$=$$K%
ENDPROC
:
DEFPROCinit
INSTALL @lib$+"WINLIB2"
INSTALL@lib$+"WINLIB5a"

REM Menu bar in main window
SYS"CreateMenu"TOhm%
SYS"SetMenu",@hwnd%,hm%
SYS"AppendMenu",hm%,0,54,"&File"
SYS"AppendMenu",hm%,0,55,"MailMerge"
SYS"AppendMenu",hm%,0,56,"Delete"
SYS"AppendMenu",hm%,0,80,"Help"
SYS"DrawMenuBar",@hwnd%

PROCenablemenu(0)
ENDPROC
:
DEFPROCenablemenu(flg%)
FORi%=55TO56:SYS"EnableMenuItem",hm%,i%,flg%:NEXT
ENDPROC

Re: Error in manual
Post by Andy Parkes on Feb 10th, 2014, 6:18pm

Hi Ken,

See if this helps:

Code:
      SYS"CreateMenu" TO hMenu%
      SYS"SetMenu", @hwnd%, hMenu%

      SYS"AppendMenu", hMenu%, 0, 54, "&File"
      SYS"AppendMenu", hMenu%, 0, 55, "MailMerge"
      SYS"AppendMenu", hMenu%, 0, 56, "Delete"
      SYS"AppendMenu", hMenu%, 0, 80, "Toggle"

      PROC_toggleMenuItems
      PROC_main
      END

      DEF PROC_main
      LOCAL click%,C%
      C% = -1
      ON SYS C% = @wparam% : RETURN
      :
      REPEAT
        WAIT 1
        click% = -1
        SWAP click%, C%
        CASE click% OF
          WHEN 55, 56 : VDU 7
          WHEN 80 : PROC_toggleMenuItems
        ENDCASE
      UNTIL FALSE
      ENDPROC

      DEF PROC_toggleMenuItems
      LOCAL S%,a$
      SYS "GetMenuState", hMenu%, 55, 0 TO S%
      S% = ABS(S%-1)
      SYS"EnableMenuItem", hMenu%, 55, S%
      SYS"EnableMenuItem", hMenu%, 56, S%
      SYS"DrawMenuBar", @hwnd%
      IF S% a$ = "Disabled" ELSE a$ = "Enabled"
      PRINT "MailMerge and Delete: " + a$
      ENDPROC
 


Cheers

Andy
Re: Error in manual
Post by sbracken on Feb 10th, 2014, 6:32pm

Hi Ken,

On my computer, PROCenablemenu(0) causes the menu items to be active. Passing 1 to the procedure caused the items to be grayed out, but only after you click on them. You need to add

SYS "DrawMenu", @hwnd%

after you update the menu states to force Windows to redraw the menu bar.

Simon
Re: Error in manual
Post by KenDown on Feb 10th, 2014, 9:47pm

Er - thanks, Simon. I wondered if there was some such call. The only trouble is that when I use it - copied and pasted from your post - I get the message "No such system call".

I'm using BB4W 5.95a, if that is relevant.
Re: Error in manual
Post by admin on Feb 10th, 2014, 9:59pm

on Feb 10th, 2014, 9:47pm, KenDown wrote:
I get the message "No such system call".

Can I refer you to the BB4W Help documentation, specifically under 'Accessing the Windows API... Adding a menu bar', which you can also read online here:

http://www.bbcbasic.co.uk/bbcwin/manual/bbcwine.html#addingmenu

There you will see that the command you are looking for is:

Code:
      SYS "DrawMenuBar", @hwnd% 

Richard.
Re: Error in manual
Post by KenDown on Feb 10th, 2014, 10:01pm

Andy, thanks. You've given the correct version of the call SYS"DrawMenuBar" and now the menu items are greyed out. However your fancy procedure simply toggles the state and doesn't show what the state is.

The menu items are greyed out and unresponsive when I set the flag to 1 and are not greyed out and do respond when I set the flag to 0. That is as I stated originally and contrary to what the manual states.

You try it with the small program I posted above - though add the SYS"DrawMenuBar",@hwnd% to make the gray appear.

Re: Error in manual
Post by admin on Feb 10th, 2014, 10:11pm

on Feb 10th, 2014, 10:01pm, KenDown wrote:
Andy, thanks. You've given the correct version of the call SYS"DrawMenuBar"

I'm confused. The only message I can see drawing attention to the correct API is the one I posted a few minutes ago.

Quote:
The menu items are greyed out and unresponsive when I set the flag to 1 and are not greyed out and do respond when I set the flag to 0. That is as I stated originally and contrary to what the manual states.

Here is an exact quote from the BB4W manual: "the third parameter is 0 to enable the item and 1 to disable the item (and change it to grey to indicate that it is disabled)":

http://www.bbcbasic.co.uk/bbcwin/manual/bbcwine.html#enablemenuitem

How is that "contrary" to your own findings?

Richard.
Re: Error in manual
Post by KenDown on Feb 11th, 2014, 04:53am

Grrrrr.

1. Someone called S. Bracken posted that the call was SYS"DrawMenu", and both you and Andy gave the correct version. I'm not blaming S. It's all too easy to make such a slip, particularly if you're working from memory.

2. You are absolutely right. The manual does state what I have found. I must be getting old, as I was sure that what I was doing was contrary to the manual - reread it multiple times to work out what I was doing wrong. Bah!

Apologies all round for raising a storm in a teacup (might as well, there's storms everywhere else this week). Possibly, if you felt like it, a reference to SYS"DrawMenuBar" might be useful on that page, as I don't recall ever coming across that call before.
Re: Error in manual
Post by sbracken on Feb 11th, 2014, 3:44pm

Hi Ken,

Sorry about the mistake. Serves me right for not double checking my facts before posting! Hopefully I did not add too much to your confusion!

Simon