GithubHelp home page GithubHelp logo

salvadordf / webui4delphi Goto Github PK

View Code? Open in Web Editor NEW
101.0 9.0 14.0 9.8 MB

WebUI4Delphi is a WebUI wrapper, which allows you to use any web browser as a GUI, with Delphi or Lazarus/FPC in the backend and HTML5 in the frontend.

Home Page: https://www.briskbard.com/forum/

License: MIT License

Batchfile 0.22% Pascal 89.41% C++ 0.06% HTML 6.73% Python 0.10% TypeScript 0.58% CSS 1.65% JavaScript 1.26%
browser console delphi delphinuspackage embarcadero fmx javascript vcl web webui

webui4delphi's Introduction

WebUI4Delphi Tweet

WebUI4Delphi is a WebUI wrapper, which allows you to use any web browser as a GUI, with Delphi or Lazarus/FPC in the backend and HTML5 in the frontend.

WebUI allows you to link your Delphi or Lazarus application with a web app that runs in a web browser installed in the operating system. Originally WebUI was created to have all the UI code in the web browser and the rest of the code in your hidden Delphi or Lazarus application. However, you can also decide to have a visible Delphi or Lazarus application communicating with a HTML5 app. You can get web browser events in your desktop application, call Pascal functions from JS, call JS functions from Pascal code, execute JavaScript, etc.

WebUI4Delphi can be used in Delphi or Lazarus applications for Windows, Linux and MacOS.

WebUI4Delphi was developed and tested on Delphi 12.1 and Lazarus 3.4/FPC 3.2.2 but it also supports Delphi 2010.

WebUI4Delphi includes VCL, FireMonkey (FMX), LCL and console examples.

WebUI4Delphi demos have been tested in Windows 10, Windows 11, Linux Mint 21.2 and Raspberry Pi OS.

WebUI doesn't embed a web browser in your application. It's used as a bridge between a desktop application and the web browser running an HTML5 app. If you need to embed a web browser instead of using the installed web browser then consider using CEF4Delphi or WebView4Delphi.

Features

  • Fully Independent (No need for any third-party runtimes)
  • Lightweight & Small memory footprint
  • Fast binary communication protocol between WebUI and the browser (Instead of JSON)
  • Multi-platform & Multi-Browser
  • Using private profile for safety
  • Original library written in Pure C
  • Help insight documentation.
  • Help file available.

Minimal Example

program Minimal;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils, uWebUI, uWebUIWindow, uWebUITypes;

var
  LWindow : IWebUIWindow;

begin
  try
    WebUI := TWebUI.Create;
    if WebUI.Initialize then
      begin
        LWindow := TWebUIWindow.Create;
        LWindow.Show('<html><head><script src="webui.js"></script></head> Hello World ! </html>');
        WebUI.Wait;
      end;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

More examples

Text editor

This text_editor is a lightweight and portable example written in Delphi and JavaScript using WebUI as the GUI.

text_editor

Installation

  • Open the file packages\WebUI4Delphi.dproj.
  • Select the Projects→Build all projects menu option.
  • Add the source directory to the search path in your applications.
  • Add the "FMX" conditional define in your project options. This define is only required for Firemonkey applications.

Links

Support

If you find this project useful, please consider making a donation.

paypal

You can also support this project with Patreon.

Patreon donate button

You can also support this project with Liberapay.

Donate using Liberapay

Related projects

Other resources

Additional: Delphinus-Support

webui4delphi's People

Contributors

salvadordf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webui4delphi's Issues

Hello, could you please modify the return value of TWebUIFileHandlerCallback to support resources other than strings!

Hello, could you please modify the return value of TWebUIFileHandlerCallback to support resources other than strings? You can change the return value to Pointer, so it can support images, videos, or other types of files.

//in uWebUITypes TWebUIFileHandlerCallback = function(const filename: PWebUIChar; len: PInteger): PWebUIChar; cdecl; //change to : TWebUIFileHandlerCallback = function(const filename: PWebUIChar; len: PInteger): Pointer; cdecl;
Then I can use in SetFileHandler like this:
ResStream := TResourceStream.Create(HInstance, pansichar(tmpstr), RT_RCDATA); len^ := ResStream.Size; LRsltBuffer := webui_malloc(len^); ResStream.ReadBuffer(LRsltBuffer^, len^); Result := LRsltBuffer;
I have tested, it worked fine!

Problem with set_file_handler in version 2.5.0 beta2 !

Hi,
It seems that there is an issue with using webui_set_file_handler in version 2.5.0 beta2. When returning resources with this, the page shows an ERR_INVALID_HTTP_RESPONSE, but this problem does not occur in version 2.4.2. Is this a bug in WebUI?

The main application freezes after loading a URL instead of an HTML page

Hey, I've found what might be a bug when I open a URL instead of an HTML file like this :

procedure TMainForm.ShowBrowserBtnClick(Sender: TObject);
var
  LMyHTML : string;
begin
  if assigned(WebUI) then
  begin
    if (WebUI.IsAppRunning) then
    begin
      exit;
    end;
  end;

  LMyHTML := '<html><head><script src="webui.js"></script></head> Hello World ! </html>';
  FWindow := TWebUIWindow.Create;
  //FWindow.Show(LMyHTML);
  FWindow.Show('https://github.com/');
end;

And after I close the browser, the application freezes. Do you know what might be causing this?

I almost forgot to mention, I'm using Delphi XE2 on Windows 11

Problem reopening WebUI Window from desktop app after user closes it voluntarily

I'm trying to use WebUI4Delphi to serve html documents from a database with about 60k documents. The wrapper is straightforward and easy to use. It also works as good as I ever hoped for, but... The special case is: I'm using a desktop app for selecting the documents and call Show() with a virtual URL that is going to be served from inside the filehandler.

When the user choses to close the WebUI window and selects another document afterwards, the window (with same ID as the window_id from previous calls) is reopened for a second and closes itself half a second later. The file handler is called with the new "virtual url" and then the app comes to a halt for about 10 seconds. No events are dispatched to my OnWebUIEvent function anymore.

Is there anything I have to do to "fix" the Window object after the user closes the window manually? And how do I find out if the Window object is in such state?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.