You can only do this using 4gl code and its impossible to have your dynamic widgets visible in design mode.
This example will create a dynamic button:
Create an empty (smart) window or use an existing window.
Create a new procedure in the section editor.
Add the following code:
DEFINE VARIABLE hn AS WIDGET-HANDLE NO-UNDO.
CREATE BUTTON hn
ASSIGN X = 10
Y = 10
WIDTH-PIXELS = 100
HEIGHT-PIXELS = 20
LABEL = "button"
VISIBLE = TRUE
FRAME = FRAME {&FRAME-NAME}:HANDLE
TRIGGERS:
ON CHOOSE PERSISTENT RUN VALUE ('doSomething') IN THIS-PROCEDURE.
END TRIGGERS.
ASSIGN hn:SENSITIVE = TRUE.
Create an override of the 'createObjects' procedure (smartwindow) and add a 'run' of the created procedure behind the 'RUN SUPER' statement, or place this code in the main-block behind the 'enable-ui' statement (simple window).
Add a procedure 'doSomething' which contains the actual trigger code.
Although this button isn't really dynamic, you can make all 'hardcoded' stuff in here variable- of parameterbased. And by using an array or temp-table construction for your handles you can add as many buttons or other widgets as you wish.
Remember that when using dynamic widgets you have to free the object if you're done with it. When your window runs persistent all the time and new objects are generated and removed you have to use the
DELETE WIDGET <handle> to remove them!