BBC BASIC for Windows
« Red/Green/Blue/Gray buttons Custom designed »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 11:58pm



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: Red/Green/Blue/Gray buttons Custom designed  (Read 213 times)
michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
xx Red/Green/Blue/Gray buttons Custom designed
« Thread started on: Mar 17th, 2016, 03:41am »

Here is post 1 of 2.. these posts will:
1) Create Predefined Buttons for an app named RGB COLOR MIXER TOOL
2) The second post will show the function and look of the buttons
Code:
   
   SWP_HIDEWINDOW = &80
      SWP_NOMOVE = 2
      SWP_NOSIZE = 1
      SWP_NOZORDER = 4
      SWP_SHOWWINDOW = 64
      LR_LOADFROMFILE = 16
      BM_SETIMAGE = 247
      BS_BITMAP = &80
      ON CLOSE : QUIT
      INSTALL @lib$+"winlib5"
      INSTALL @lib$+"timerlib"

      REM SET MODE TO 8 USING VDU
      VDU 22,8
      REM SET LINE THICKNESS TO 3
      VDU 23,23,3|
      REM OFF
      GCOL 1

      REM create and save button images------------------------------------

      REM**********(Filename,H,V,BEGIN,SIZE,R,G,B,Dimmer)    Dont use .BMP as it is automatically added in PROC
      PROC_button("MyGRAYBUTTON",500,500,15,30,200,185,200,15)
      PROC_button("MyREDBUTTON",500,580,15,30,250,0,0,15) REM RED
      PROC_button("MyGREENBUTTON",500,660,15,30,0,250,0,15) REM GREEN
      PROC_button("MyBLUEBUTTON",500,740,15,30,100,100,255,15) REM BLUE

      REM The colors will be hard to adjust as you have no tool to customize the colors (YET) -its coming
      REM its really trial and error with the dimmer setting, and RGB settings.. (too much value gap can make your button look odd)
      REM MAIN --------------------------------
      (mou)
      WAIT 0 : REM just wait, nothing to do !
      GOTO (mou)

      DEF PROC_button(filename$,H,V,BEGIN,SIZE,X,C,A,DI)
      filename$=filename$+".BMP"
      R=X
      G=C
      B=A
      P=SIZE-BEGIN
      P=P/2
      P=BEGIN+P
      FOR Y=P TO SIZE
        COLOUR 1,X,C,A
        LINE H-Y,V-Y,H+Y,V-Y
        LINE H+Y,V-Y,H+Y,V+Y
        LINE H+Y,V+Y,H-Y,V+Y
        LINE H-Y,V+Y,H-Y,V-Y
        X=X-DI
        C=C-DI
        A=A-DI
        IF X<2 THEN X=2
        IF C<2 THEN C=2
        IF A<2 THEN A=2
      NEXT Y
      FOR Y=BEGIN TO P
        COLOUR 1,X,C,A
        LINE H-Y,V-Y,H+Y,V-Y
        LINE H+Y,V-Y,H+Y,V+Y
        LINE H+Y,V+Y,H-Y,V+Y
        LINE H-Y,V+Y,H-Y,V-Y
        X=X+DI
        C=C+DI
        A=A+DI
      NEXT Y
      COLOUR 1,R,G,B
      FILL H,V
      REM I hope I dont burn out any brain cells with this solution...LOL
      file1$=@usr$+ filename$
      h$=STR$(H-SIZE-8)
      v$=STR$(V-SIZE-8)
      size$=STR$(SIZE*2+12)
      combinit$=h$+","+v$+","+size$+","+size$
      pos1$=combinit$
      OSCLI "SCREENSAVE "+file1$+" "+pos1$

      ENDPROC



 

And here is the buttons in Action: Keep the buttons for later when I post RGB COLOR MIXER TOOL
Code:
     
 SWP_HIDEWINDOW = &80
      SWP_NOMOVE = 2
      SWP_NOSIZE = 1
      SWP_NOZORDER = 4
      SWP_SHOWWINDOW = 64
      LR_LOADFROMFILE = 16
      BM_SETIMAGE = 247
      BS_BITMAP = &80
      ON CLOSE : PROCclose : QUIT
      INSTALL @lib$+"winlib5"
      INSTALL @lib$+"timerlib"
      REM SET MODE TO 8 USING VDU
      VDU 22,8
      REM SET LINE THICKNESS TO 3
      VDU 23,23,3|
      REM OFF
      GCOL 1
      REM create and save button images------------------------------------
      file1$=@usr$+"MyREDBUTTON.bmp"
      file2$=@usr$+"MyGREENBUTTON.bmp"
      file3$=@usr$+"MyBLUEBUTTON.bmp"
      file1b$=@usr$+"MyGRAYBUTTON.bmp"
      CLS
      REM -----------------------------------------------------------------
      REM create buttons --------------------------------------------------
      butnu1=FN_button("",300,200,40,40,FN_setproc(PROCbutnu1),BS_BITMAP)
      butnu2=FN_button("",340,200,40,40,FN_setproc(PROCbutnu2),BS_BITMAP)
      butnu3=FN_button("",380,200,40,40,FN_setproc(PROCbutnu3),BS_BITMAP)
      REM -----------------------------------------------------------------
      REM assign images to buttons----------------------------------------
      SYS "LoadImage", 0, file1$, 0, 40, 40, LR_LOADFROMFILE TO hbitmap1
      SYS "SendMessage", butnu1, BM_SETIMAGE, 0, hbitmap1
      SYS "LoadImage", 0, file2$, 0, 40, 40, LR_LOADFROMFILE TO hbitmap2
      SYS "SendMessage", butnu2, BM_SETIMAGE, 0, hbitmap2
      SYS "LoadImage", 0, file3$, 0, 40, 40, LR_LOADFROMFILE TO hbitmap3
      SYS "SendMessage", butnu3, BM_SETIMAGE, 0, hbitmap3
      SYS "LoadImage", 0, file1b$, 0, 40, 40, LR_LOADFROMFILE TO hbitmap1b
      REM -----------------------------------------------------------------
      REM MAIN --------------------------------
      (mou)
      WAIT 0 : REM just wait, nothing to do !
      GOTO (mou)
      END
      REM -------------------------------------
      REM clicking buttons will jump here automatically -------------------
      DEF PROCbutnu1 : PRINTTAB(0,27);"Button 1" : PROCflash1
      DEF PROCbutnu2 : PRINTTAB(0,27);"Button 2" : PROCflash2
      DEF PROCbutnu3 : PRINTTAB(0,27);"Button 3" : PROCflash3
      LOCAL X,Y,CC,I%
      FOR I%=1 TO 20000
        X=RND(100)
        Y=RND(100)
        CC=RND(200)
        COLOUR 1,X+Y,CC,Y+X
        LINE X,Y,X,Y
      NEXT I%
      ENDPROC
      REM -----------------------------------------------------------------
      DEF PROCflash1 : LOCAL A%
      SYS "SendMessage", butnu1, BM_SETIMAGE, 0, hbitmap1b
      A%=FN_ontimer(100,PROCflash1off,0)
      ENDPROC
      DEF PROCflash1off
      SYS "SendMessage", butnu1, BM_SETIMAGE, 0, hbitmap1
      ENDPROC
      DEF PROCflash2 : LOCAL A%
      SYS "SendMessage", butnu2, BM_SETIMAGE, 0, hbitmap1b
      A%=FN_ontimer(100,PROCflash2off,0)
      ENDPROC
      DEF PROCflash2off
      SYS "SendMessage", butnu2, BM_SETIMAGE, 0, hbitmap2

      ENDPROC
      DEF PROCflash3 : LOCAL A%
      SYS "SendMessage", butnu3, BM_SETIMAGE, 0, hbitmap1b
      A%=FN_ontimer(100,PROCflash3off,0)
      ENDPROC
      DEF PROCflash3off
      SYS "SendMessage", butnu3, BM_SETIMAGE, 0, hbitmap3
      ENDPROC
            REM delete the stuff we made
      DEF PROCclose
      SYS "DeleteObject", hbitmap1
      SYS "DeleteObject", hbitmap2
      SYS "DeleteObject", hbitmap3
      SYS "DeleteObject", hbitmap1b
      PROC_closewindow(butnu1)
      PROC_closewindow(butnu2)
      PROC_closewindow(butnu3)
      ENDPROC
 

« Last Edit: Mar 17th, 2016, 1:54pm by michael » User IP Logged

I like making program generators and like reinventing the wheel
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