BBC BASIC for Windows
« Error in manual »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 9:52pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Error in manual  (Read 1268 times)
KenDown
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 181
xx Error in manual
« Thread started 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?
User IP Logged

sbracken
New Member
Image


member is offline

Avatar




PM


Posts: 19
xx Re: Error in manual
« Reply #1 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
User IP Logged

KenDown
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 181
xx Re: Error in manual
« Reply #2 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.
User IP Logged

sbracken
New Member
Image


member is offline

Avatar




PM


Posts: 19
xx Re: Error in manual
« Reply #3 on: Feb 10th, 2014, 2:12pm »

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

Simon
User IP Logged

Matt
Developer

member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: Error in manual
« Reply #4 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
User IP Logged

KenDown
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 181
xx Re: Error in manual
« Reply #5 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
User IP Logged

Andy Parkes
Developer

member is offline

Avatar




PM

Gender: Male
Posts: 25
xx Re: Error in manual
« Reply #6 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
User IP Logged

sbracken
New Member
Image


member is offline

Avatar




PM


Posts: 19
xx Re: Error in manual
« Reply #7 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
User IP Logged

KenDown
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 181
xx Re: Error in manual
« Reply #8 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.
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Error in manual
« Reply #9 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.
User IP Logged

KenDown
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 181
xx Re: Error in manual
« Reply #10 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.
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Error in manual
« Reply #11 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.
« Last Edit: Feb 10th, 2014, 10:32pm by admin » User IP Logged

KenDown
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 181
xx Re: Error in manual
« Reply #12 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.
User IP Logged

sbracken
New Member
Image


member is offline

Avatar




PM


Posts: 19
xx Re: Error in manual
« Reply #13 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

User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls