Create button by variable or macro replacement

53 views
Skip to first unread message

valt...@valtecom.com.br

unread,
May 14, 2025, 12:39:05 PM5/14/25
to Harbour Minigui
Good morning friends,
I would like to know if it is possible to create buttons by variable or macro replacement, because I remember that a few years ago, in the early days, I tried and failed, because creating buttons in a variable quantity in a window using a field of a DBF to give the name to this button.
In the DBF I will have the fields CODE (sequential), NUMBER (numeric of 3), NAME (character of 20) and I need to create buttons as this DBF is filled, one day I will have ten records, another day there may be 15 and so create buttons for each record and a long time ago I tried and it gave an error and I gave up and now the past has returned. The syntax:
@ line,column BUTTON botao001 OF janelagravavendas CAPTION '001' ACTION {||NIL} WIDTH 80 HEIGHT 35 FONT "Times New Roman" SIZE 10 TOOLTIP "Processa 001"

@ line,column BUTTON botao002 OF janelagravavendas CAPTION '002' ACTION {||NIL} WIDTH 80 HEIGHT 35 FONT "Times New Roman" SIZE 10 TOOLTIP "Processa 002"
But what I want:
DO WHILE .T.
@ line, column BUTTON STRZERO(NUMBER,03,0) OF janelagravavendas CAPTION ALLTRIM(NAME) ACTION {||NIL} WIDTH 80 HEIGHT 35 FONT "Times New Roman" SIZE 10 TOOLTIP "Processa
" + ALLTRIM(NAME)
SKIP
IF EOF()
EXIT
ENDIF
ENDDO
And so on, each record will generate a button for it, and when clicked I get the name property and transform it into VAL() and I know which record it refers to.
Waiting.
Thank you.
Valteçom
Uberaba MG Brazil.

José M. C. Quintas

unread,
May 14, 2025, 4:16:17 PM5/14/25
to minigu...@googlegroups.com

check fivelibs

May be a BROWSE ARRAY too

Sometimes I confuse library syntax, but anything like this?

aButtonList  := Array(50), nIndex := 0

nRow := 30

nCol := 30

DO WHILE ! Eof()

   CreateButton( nRow, nCol, RecNo(), nIndex, @aButtonList[ ++nIndex ], field->Name )

  nRow += 30

   IF nRow > GetProperty( xDlg, "height" ) - 30

       nCol += 500

      nRow := 30

  ENDIF

   SKIP

ENDDO

FUNCTION CreateButton( nRow, nCol, nRec, nIndex, cName, cCaption )

  cName := "btn" + StrZero( nIndex, 3 ]

  @ nCol, nRow BUTTON (cName) CAPTION cCaption WIDTH 300, HEIGHT 20 ;

   ACTION { || EditRec( nRec ) }

   RETURN Nil


José M. C. Quintas

Uberaba MG Brazil. --
Visit our website on https://www.hmgextended.com/ or https://www.hmgextended.org/
---
You received this message because you are subscribed to the Google Groups "Harbour Minigui" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minigui-foru...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/minigui-forum/74d261fe-2fbf-4d0c-8ab1-11754b2fe076n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages