Visual components in AdvPL
DEFINE ... · @ ... SAY · @ ... GET · @ ... BUTTON · ACTIVATE ...Understand how visual commands provide readable syntax for instantiating and configuring interface classes.
Overview
AdvPL visual component commands make interface classes available through simpler instructions. During compilation, these commands are translated into constructor and method calls on the corresponding classes. Keywords such as FROM, TO, SIZE, OF and ACTION make parameters easier to recognize and improve code readability and maintenance.
Syntax
DEFINE ... · @ ... SAY · @ ... GET · @ ... BUTTON · ACTIVATE ...Simple dialog with SAY, GET and BUTTON
#Include "TOTVS.ch"
User Function ExVisual()
Local oDlg
Local cName := Space(40)
Define MsDialog oDlg Title "Quick entry" ;
From 0, 0 To 150, 360 Pixel
@ 20, 20 Say "Name:" Size 40, 10 Of oDlg Pixel
@ 18, 65 Get cName Size 110, 10 Of oDlg Pixel
@ 50, 65 Button "Confirm" Size 55, 14 ;
Action MsgInfo("Hello, " + AllTrim(cName)) Of oDlg Pixel
Activate MsDialog oDlg Centered
ReturnThe dialog is the container. SAY shows a label, GET edits the variable and BUTTON runs an action block.
Event forwarded to a function
#Include "TOTVS.ch"
User Function ExAcaoVisual()
Local oDlg
Define MsDialog oDlg Title "Processamento" ;
From 0, 0 To 120, 300 Pixel
@ 35, 85 Button "Executar" Size 55, 14 ;
Action ProcessarPedido() Of oDlg Pixel
Activate MsDialog oDlg Centered
Return
Static Function ProcessarPedido()
MsgInfo("Processamento iniciado")
ReturnThe ACTION block remains short and delegates the rule to a function, improving readability and testing.
Command and class responsibilities
// Forma declarativa por comando:
@ 20, 20 Say "Cliente:" Size 45, 10 Of oDlg Pixel
// Na compilação, o comando é convertido em chamadas
// da classe visual correspondente. A implementação
// exata depende do componente e da versão da LIB.Keyword syntax makes source intent clearer, while the class supplies the component’s actual behavior.
- Command syntax is a compiler-provided layer; at runtime, behavior is performed by the corresponding visual classes.
- Use OF to explicitly identify the dialog or container that owns the component.
- Organize interface creation, configuration and activation in a clear order.
- Code blocks are commonly used for ACTION, VALID, WHEN and other component events.
- Consult the command or class documentation to confirm parameters, include files and availability in the LIB in use.
- Do not mix PIXEL coordinates with other units without checking the container’s expected convention.
- A component without the correct dialog association may not appear or may have an unexpected lifecycle.
- Large event blocks make maintenance and debugging harder; call a dedicated function instead.
- Command/class equivalence does not mean every class option is necessarily exposed by command syntax.
- Historical interfaces may depend on SmartClient and routine context; confirm compatibility with the environment and execution type.
