BBC BASIC for Windows
« Reassigning buttons »

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



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: Reassigning buttons  (Read 482 times)
Joe68
New Member
Image


member is offline

Avatar




PM


Posts: 19
xx Reassigning buttons
« Thread started on: Jun 5th, 2016, 08:30am »

Hi All.

The attached program snippet simply sets up some buttons (using WINLIB5), and checks which button has been pressed.
When I try to reassign the buttons, i.e. when button 5 'CHANGE' is pressed, the new labels appear correctly but as soon as the mouse pointer touches buttons 1-4 they revert to their original values.

Code:
      INSTALL @lib$+"WINLIB5"

      x=50:w=100:h=30

      REM create buttons
      b=FN_button("Alice",  x,100,w,h,1,0)
      b=FN_button("Bob",    x,150,w,h,2,0)
      b=FN_button("Charlie",x,200,w,h,3,0)
      b=FN_button("Diane",  x,250,w,h,4,0)
      b=FN_button("CHANGE", x,300,w,h,5,0)


      REM activate Windows system
      Click%=-1
      ON SYS Click%=@wparam%:RETURN

      REM main loop
      REPEAT
        SYS "Sleep",10
        click%=-1
        SWAP click%,Click%
        IF click%<>-1 PROCChecks(click%)
      UNTIL FALSE
      END


      DEFPROCChecks(k)
      PRINT TAB(0,1)"Button ";STR$k;" selected"
      PRINT TAB(0,2)h%
      REM if 'CHANGE' is selected then...
      IF k=5 THEN
        REM ...reassign buttons
        b=FN_button("Jack", x,100,w,h,1,0)
        b=FN_button("Karen",x,150,w,h,2,0)
        b=FN_button("Lucy", x,200,w,h,3,0)
        b=FN_button("Mark", x,250,w,h,4,0)
      ENDIF
      ENDPROC
 


Can anyone tell me how to ensure the reassigned buttons retain their new values?

Thanks.
Joe.
User IP Logged

Joe
Zaphod
Guest
xx Re: Reassigning buttons
« Reply #1 on: Jun 5th, 2016, 12:41pm »

The problem is that what you are doing is actually defining new buttons that are overlaying the original ones, not just changing the names of the original buttons.

It is more likely that you intended to do this:
Code:
      INSTALL @lib$+"WINLIB5"

      WM_SETTEXT = &C

      x=50:w=100:h=30

      REM create buttons
      b1=FN_button("Alice",  x,100,w,h,1,0)
      b2=FN_button("Bob",    x,150,w,h,2,0)
      b3=FN_button("Charlie",x,200,w,h,3,0)
      b4=FN_button("Diane",  x,250,w,h,4,0)
      b5=FN_button("CHANGE", x,300,w,h,5,0)


      REM activate Windows system
      Click%=-1
      ON SYS Click%=@wparam%:RETURN

      REM main loop
      REPEAT
        SYS "Sleep",10
        click%=-1
        SWAP click%,Click%
        IF click%<>-1 PROCChecks(click%)
      UNTIL FALSE
      END


      DEFPROCChecks(k)
      PRINT TAB(0,1)"Button ";STR$k;" selected"
      REM  PRINT TAB(0,2)h%
      REM if 'CHANGE' is selected then...
      IF k=5 THEN
        REM ...reassign buttons
        SYS"SendMessage",b1,WM_SETTEXT,0,"Jack"
        SYS"SendMessage",b2,WM_SETTEXT,0,"Karen"
        SYS"SendMessage",b3,WM_SETTEXT,0,"Lucy"
        SYS"SendMessage",b4,WM_SETTEXT,0,"Mark"
      ENDIF
      ENDPROC
 
User IP Logged

Joe68
New Member
Image


member is offline

Avatar




PM


Posts: 19
xx Re: Reassigning buttons
« Reply #2 on: Jun 8th, 2016, 10:18am »

Thank you Zaphod.

Your answer works perfectly!

If you don't mind my asking, where can I find similar information about BB4W's call messages to Windows?
User IP Logged

Joe
Zaphod
Guest
xx Re: Reassigning buttons
« Reply #3 on: Jun 8th, 2016, 12:43pm »

That is a difficult question.
Read lots of code and the manual!
Unfortunately some tutorials on this that were on the old BB4W Yahoo site recently became unavailable as the site was shut down.
This is the best way to access the Win32 API information.
http://www.oxygenbasic.org/o2zips/Win32.chm
User IP Logged

DDRM
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 321
xx Re: Reassigning buttons
« Reply #4 on: Jun 9th, 2016, 08:55am »

Hi Both,

Yes, I like that help file too.

MSDN is good, but it does take a while to learn your way around it. After a while you get a feel for how the code examples they show there are going to map into BB4W SYS calls.

It's also worth having a look on the wiki (linked as "BBC BASIC for Windows Programmers' Reference" in the box above) - there's a lot of stuff there.

If there are specific examples you want to know about, do post - there may be someone who's already done it, which will save you a lot of work, and it may teach the rest of us something useful, too!

Best wishes,

D
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