FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour 20 buttons with numbers
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
20 buttons with numbers
Posted: Mon Oct 05, 2009 09: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
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: 20 buttons with numbers
Posted: Mon Oct 05, 2009 10:59 PM
Code (fw): Select all Collapse
   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
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: 20 buttons with numbers
Posted: Tue Oct 06, 2009 06: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
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: 20 buttons with numbers
Posted: 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
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: 20 buttons with numbers
Posted: Tue Oct 06, 2009 12:00 PM
Silvio...

it a little modification of sambomb's sample
Code (fw): Select all Collapse
#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 ) )) }
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: 20 buttons with numbers
Posted: Tue Oct 06, 2009 01: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
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: 20 buttons with numbers
Posted: Tue Oct 06, 2009 05:06 PM
thanks but perhaps I not explain good to YOU
I made this small sample :
Code (fw): Select all Collapse
#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
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: 20 buttons with numbers
Posted: Tue Oct 06, 2009 06: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
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: 20 buttons with numbers
Posted: Tue Oct 06, 2009 08: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
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: 20 buttons with numbers
Posted: Tue Oct 06, 2009 08:56 PM
Silvio...

you can use new button class ( TRBbtn )
this is a example...
Code (fw): Select all Collapse
#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
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: 20 buttons with numbers
Posted: Tue Oct 06, 2009 11:18 PM
Silvio...

New sample...
Code (fw): Select all Collapse
#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
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: 20 buttons with numbers
Posted: Wed Oct 07, 2009 08:01 AM

thankssssssssssssss it was that I am searching
Good Mr D

Best Regards, Saludos



Falconi Silvio

Continue the discussion