Animated and configurable product cards without leaving PowerBuilder
Animated and configurable product cards without leaving PowerBuilder
A hybrid implementation that combines a business-oriented PowerBuilder window with the visual capabilities of HTML, CSS, and JavaScript to deliver a modern, animated, configurable, and exportable product card.
Modernizing a PowerBuilder interface does not always require replacing the application. A properly encapsulated web component can extend the visual experience while PowerBuilder remains responsible for state, validation, and business flow.
The purpose of the demo
Demo_PB_card_animada recreates a product card inspired by contemporary web interfaces: a gradient background, depth, rounded corners, a prominent image, emerging content, and pointer-driven motion. The difference is that every parameter is managed from a PowerBuilder window.
The user can change the product name and description, button text, gradient colors and direction, animation type, image, and image scale. The result is updated inside a Chromium-based WebBrowser control. At the same time, the demo generates a complete HTML document that can be copied and reused independently.

The running demo


Why a hybrid approach was selected

The separation is intentional. The card does not know about PowerBuilder controls, and the window does not try to reproduce a styling engine. Both sides communicate through a stable JavaScript function, aplicarConfiguracion(), and messages sent through WebView2.
Update lifecycle
- The user changes text, colors, direction, animation, size, or image.
of_actualizar_tarjeta()normalizes the values through the NVO.of_construir_comando()creates a safe JavaScript call.EvaluateJavascriptAsync()executes the command in the loaded document.aplicarConfiguracion()updates CSS variables, text, image, and scale.animarDosVeces()restarts the selected automatic animation.- After two cycles, the automatic class is removed and pointer behavior remains available.
- The exportable HTML is regenerated with the same parameters.
PowerScript as the coordinator
The window keeps its methods short and delegates string transformations to the NVO. The central update obtains visible values, builds the command, and sends it to the browser:

Five animations behind one interface


Native image gallery
The gallery demonstrates that a hybrid design does not require moving every interaction into HTML. GetFolder() selects a directory; an auxiliary ListBox uses DirList() to enumerate files; the NVO accepts compatible extensions; and lv_galeria adds every image to its large-thumbnail list.

Two-way communication
PowerBuilder-to-Web communication uses EvaluateJavascriptAsync(). In the opposite direction, the card button creates a JSON message and sends it with window.chrome.webview.postMessage(). PowerBuilder handles the action in the WebBrowser WebMessageReceived event and updates the window status.
Formatted and exportable HTML
of_generar_html_exportable() starts from the real document and appends a final call to aplicarConfiguracion(). The result retains the CSS, SVG, JavaScript, and user values. The NVO normalizes line endings to CRLF so the document remains readable inside a PowerBuilder MultilineEdit.
The Copy HTML button refreshes the content before placing it on the clipboard. Consequently, the preview and copied document share a single configuration and cannot silently drift apart.
Paths, UTF-8, and free-form input
of_convertir_ruta_uri()converts Windows separators and spaces into a usablefile:///URI.of_escapar_javascript()protects slashes, quotes, and line endings before text interpolation.EncodingUTF8!preserves accented and special characters while reading the HTML document.- The default product is an embedded SVG, so the demo works without an external image.
- Restoring values resets text, colors, scale, image, and animation.
Ways to evolve the pattern
- Persist card presets in JSON or a database.
- Add multiple selectable HTML templates.
- Generate a product grid from a DataWindow.
- Send price, availability, and variants to the HTML component.
- Turn the card action into a real cart or order operation.
- Package images as resources or serve them from a controlled URL.
Conclusion
The demo presents a practical way to modernize focused areas of a PowerBuilder application without rewriting its architecture. PowerBuilder manages parameters, files, validation, interaction, and compilation; Chromium provides visual composition, animation, and fluid response.
The essential step is not merely embedding a page, but defining a small and verifiable contract between both environments. With one configuration function, two-way messaging, and an NVO responsible for safe text handling, a web product card becomes a component governed by the desktop application.
Luis Avilan

This message has an attachment file.
Please log in or register to see it.
Please Log in or Create an account to join the conversation.