20 buttons with numbers

20 buttons with numbers

Postby Silvio » Mon Oct 05, 2009 9:53 pm

I must create 20 buttons with numbers and when I click on each buttons must be clicked

but I must create it for each letters

sample :

a . 1 2 3 4 5 6 7 8 9 10 11 11 12 13 14 15 16 17 18 19 20
b. 1 2 3 4 5 6 7 8 9 10 11 11 12 13 14 15 16 17 18 19 20
c. 1 2 3 4 5 6 7 8 9 10 11 11 12 13 14 15 16 17 18 19 20
d. 1 2 3 4 5 6 7 8 9 10 11 11 12 13 14 15 16 17 18 19 20

and for each letters I must show with button is clicked

sample :
Letter Number buttons result
c. 1 2 3 4 5 6 7 8 9 10 11 11 12 13 14 15 16 17 18 19 20 11


How I can create it ?



I
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: 20 buttons with numbers

Postby sambomb » Mon Oct 05, 2009 10:59 pm

Code: Select all  Expand view

   DEFINE DIALOG  oDlg             ;
          FROM    10, 20 TO 290,590;
          TITLE   "lalala"         ;
          Of      oWnd;
          Pixel

   MultiButton(4, 10)

   Activate Dialog   oDlg;
            CENTERED

Function MultiButton(nChar, nNumber)

Local x := 0, y := 0, cChar := ""

   For x := 1 to nChar

      For y := 1 to nNumber

         cChar := Chr( 64 + x )

         @ x*25,  y*25 ButtonBmp;
            SIZE     20, 20;
            ACTION   Alert("Button: " + cChar + AllTrim( Str( y ) ));
            OF       oDlg;
            prompt   cChar + AllTrim( Str( y ) );
            Pixel
      end
     
   end

Return
 
Last edited by sambomb on Tue Oct 06, 2009 11:48 am, edited 2 times in total.
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: 20 buttons with numbers

Postby Silvio » Tue Oct 06, 2009 6:30 am

I not Know How Make the buttons
but I Not Know How show the buttons clicked
for sample the clausole on change of buttons not exist
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: 20 buttons with numbers

Postby sambomb » Tue Oct 06, 2009 11:47 am

I'd edited the sample, try it now
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: 20 buttons with numbers

Postby Daniel Garcia-Gil » Tue Oct 06, 2009 12:00 pm

Silvio...

it a little modification of sambomb's sample
Code: Select all  Expand view

#include "fivewin.ch"

function main()

   DEFINE DIALOG  oDlg             ;
          FROM    10, 20 TO 290,590;
          TITLE   "lalala"         ;
          Pixel

   MultiButton(4, 10)

   Activate Dialog   oDlg;
            CENTERED
return nil

Function MultiButton(nChar, nNumber)

Local x := 0, y := 0, cChar := ""
local oBtn

   For x := 1 to nChar

      For y := 1 to nNumber

         cChar := Chr( 64 + x )

         @ x*25,  y*25 ButtonBmp oBtn;
            SIZE     20, 20;
            OF       oDlg;
            prompt   cChar + AllTrim( Str( y ) );
            Pixel
         
         oBtn:bAction = BtnAction( cChar, y )  
         
      end
     
   end

Return
 
function BtnAction( cChar, y )
return { | |Alert("Button: " + cChar + AllTrim( Str( y ) )) }
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: 20 buttons with numbers

Postby sambomb » Tue Oct 06, 2009 1:04 pm

Daniel, with this modification you duplicate the button when assign to the same var each button, you must use something like it:

Local oBtn := Array(nChar*nNumber)

oBtn[ ( ( nchar - 1 ) * x ) + y ]

This way you assign each button to a different var... [;)]
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: 20 buttons with numbers

Postby Silvio » Tue Oct 06, 2009 5:06 pm

thanks but perhaps I not explain good to YOU
I made this small sample :
Code: Select all  Expand view
#include "fivewin.ch"


#define BTN_WIDTH  10
#define BTN_HEIGHT 10

function test()
   Local oDlg
   Local obtn[200]
   Local nRow,Row,t,k ,xCol

   DEFINE DIALOG oDlg from 1,2 to 28,78
   Xrow:=1
   xCol:=1
    row:=1
   For t=1 to 10
      @ Xrow,xCol say alltrim(str(t))+"."  SIZE BTN_WIDTH,BTN_HEIGHT
                    col:=03
                     For k=1 to 20
                           @  row,col BUTTON obtn[k] PROMPT alltrim(str(k))   SIZE BTN_WIDTH,BTN_HEIGHT
                              col :=col+2
                           next k
                         @ row+1.2,Col+2 say "Result:"
                    Xrow:=xRow+1.2
               row:=row+1
   next t
ACTIVATE DIALOG oDlg
RETURN NIL




On the word "result" I must write wich button is clicked
On each Line of button must be clicked one of 20 buttons
and If I press with the mouse on a button this button must be clicked

the prg must give me a string as " 1 2 3 4 5 6 7 8 9 10" - only ten number , one for each line

or an array with the numbers selected ( only ten numbers)

it is hard to make it ?
thanks in advance
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: 20 buttons with numbers

Postby sambomb » Tue Oct 06, 2009 6:01 pm

Let me understand better...

You'll have 200 buttons, 20 cols * 10 row.

For each row you want only the last pressed?
And at the end of the program you want a return of each row last button?

Example:
Line 1: Last Button = 1
Line 2: Last Button = 2
Line 3: Last Button = 5
Line 4: Last Button = 8
Line 5: Last Button = 9
Line 6: Last Button = 9
Line 7: Last Button = 9
Line 8: Last Button = 9
Line 9: Last Button = 9
Line 10: Last Button = 9

Return {1,2,5,8,9,9,9,9,9}

Right?
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: 20 buttons with numbers

Postby Silvio » Tue Oct 06, 2009 8:27 pm

yes
and that button I click must be pressed toshow on dialog with button ( of each line) is clicked or we can change color ...
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: 20 buttons with numbers

Postby Daniel Garcia-Gil » Tue Oct 06, 2009 8:56 pm

Silvio...

you can use new button class ( TRBbtn )
this is a example...
Code: Select all  Expand view

#include "fivewin.ch"
#include "ribbon.ch"


#define BTN_WIDTH  12
#define BTN_HEIGHT 12

function test()
   Local oDlg
   Local xCol, xRow
   local t, k, nTotRow, nTotCol
   local aSay
   local aBtn, nPos
   local nMaxVal := 10
   
   nTotCol = 20
   nTotRow = 10
   
   aBtn = Array( nTotRow * nTotCol )
   aSay = Array( nTotRow )

   DEFINE DIALOG oDlg size 850, 600 pixel
   xRow:=1
   xCol:=10

   For t=1 to nTotRow
      @ xRow, 1 say alltrim(str(t),2)+"."  SIZE BTN_WIDTH,BTN_HEIGHT pixel
      For k=1 to nTotCol
         nPos = nTotCol * ( t - 1 ) + k
         @  xRow, xCol rbbtn aBtn[ nPos ] PROMPT alltrim(str(k, 2)) ;
            SIZE BTN_WIDTH,BTN_HEIGHT CENTER ROUND BORDER
            xCol += BTN_WIDTH + 5
            aBtn[ nPos ]:bAction = BtnAction( k, t, nTotCol, aBtn, aSay, nMaxVal )

      next k
      @ xRow + 5, xCol  say aSay[ t ] PROMPT "Result:" pixel
      xRow += BTN_HEIGHT + 5
      xCol = 10
   next t
ACTIVATE DIALOG oDlg
RETURN NIL

function BtnAction( x, y, nTotCol, aBtn, aSay, nMaxVal)
return { | oSelf | CheckStatus( oSelf, x, y, nTotCol, aBtn, aSay, nMaxVal ) }
                    
Function CheckStatus( oSelf, x, y, nTotCol, aBtn, aSay, nMaxVal )
   local nCount := 0
   
     
   AEval( aBtn, {| oSelf | If( oSelf:lSelected, nCount++, ) }, ( ( y - 1 ) * nTotCol ) + 1, nTotCol )

   if nCount <= nMaxVal
      aSay[ y ]:Cargo := "Result: "
      if oSelf:lSelected
         oSelf:lSelected := .F.
      else
         oSelf:lSelected := .T. .and. nCount < nMaxVal
         if ! oSelf:lSelected
            MsgStop( "You can't Select" + CRLF + "Max: " + Str( nMaxVal ) )
         endif
      endif
      AEval( aBtn, {| oSelf, nIdx | aSay[ y ]:Cargo += If( oSelf:lSelected, Str( nIdx - ( ( y - 1 ) * nTotCol ), 2 ) + " ", "" ) }, ;
                   ( ( y - 1 ) * nTotCol ) + 1, ( ( nTotCol ) ) )
      aSay[ y ]:SetText( aSay[ y ]:Cargo  )
   endif
return nil
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: 20 buttons with numbers

Postby Daniel Garcia-Gil » Tue Oct 06, 2009 11:18 pm

Silvio...

New sample...
Code: Select all  Expand view

#include "fivewin.ch"
#include "ribbon.ch"


#define BTN_WIDTH  12
#define BTN_HEIGHT 12

function test()
   Local oDlg
   Local xCol, xRow
   local t, k, nTotRow, nTotCol
   local aSay
   local aBtn, nPos
   local nMaxVal := 1
   
   nTotCol = 20
   nTotRow = 10
   
   aBtn = Array( nTotRow * nTotCol )
   aSay = Array( nTotRow )

   DEFINE DIALOG oDlg size 850, 600 pixel
   xRow:=1
   xCol:=10

   For t=1 to nTotRow
      @ xRow, 1 say alltrim(str(t),2)+"."  SIZE BTN_WIDTH,BTN_HEIGHT pixel
      For k=1 to nTotCol
         nPos = nTotCol * ( t - 1 ) + k
         @  xRow, xCol rbbtn aBtn[ nPos ] PROMPT alltrim(str(k, 2)) ;
            SIZE BTN_WIDTH,BTN_HEIGHT CENTER ROUND BORDER
            xCol += BTN_WIDTH + 5
            aBtn[ nPos ]:bAction = BtnAction( k, t, nTotCol, nTotRow, aBtn, aSay, nMaxVal )

      next k
      @ xRow + 5, xCol  say aSay[ t ] PROMPT "Result:" pixel
      xRow += BTN_HEIGHT + 5
      xCol = 10
   next t
ACTIVATE DIALOG oDlg
RETURN NIL

function BtnAction( x, y, nTotCol, nTotRow, aBtn, aSay, nMaxVal)
return { | oSelf | CheckStatus( oSelf, x, y, nTotCol, nTotRow, aBtn, aSay, nMaxVal ) }
                    
Function CheckStatus( oSelf, x, y, nTotCol, nTotRow, aBtn, aSay, nMaxVal )
   local nCount := 0
   local j
   
     
   AEval( aBtn, {| oSelf | If( oSelf:lSelected, nCount++, ) }, ( ( y - 1 ) * nTotCol ) + 1, nTotCol )

   if nCount <= nMaxVal
      aSay[ y ]:Cargo := "Result: "
      if oSelf:lSelected
         oSelf:lSelected := .F.
      else
         oSelf:lSelected := .T. .and. nCount < nMaxVal
         if ! oSelf:lSelected
            MsgStop( "You can't Select" + CRLF + "Max: " + Str( nMaxVal ) )
         else
           for j = 0 to nTotRow - 1
              if aBtn[ j * nTotCol + x ]:lSelected .and. ( j + 1 )#y
                 MsgStop( "You can't Select this number" + CRLF + "was selected in Row: " + Str( j + 1 ) )
                 aBtn[ (y - 1) * nTotCol + x ]:lSelected = .F.
                 aBtn[ (y - 1) * nTotCol + x ]:Refresh()
                 exit
              endif
           next
         endif
      endif
      AEval( aBtn, {| oSelf, nIdx | aSay[ y ]:Cargo += If( oSelf:lSelected, Str( nIdx - ( ( y - 1 ) * nTotCol ), 2 ) + " ", "" ) }, ;
                   ( ( y - 1 ) * nTotCol ) + 1, ( ( nTotCol ) ) )
      aSay[ y ]:SetText( aSay[ y ]:Cargo  )
   endif
   
return nil
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: 20 buttons with numbers

Postby Silvio » Wed Oct 07, 2009 8:01 am

thankssssssssssssss it was that I am searching
Good Mr D
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 68 guests