Recent

Author Topic: Is there a way to combine fpweb and a GUI application in the same application?  (Read 1624 times)

vfclists

  • Hero Member
  • *****
  • Posts: 1013
    • HowTos Considered Harmful?
I am developing fpweb and I want to be able to change some parameters in the GUI that fpweb will load at runtime between requests without having to recompile.

eg. When I'm developing a table grid, I want to be able to set some the parameters of the fields quickly in a TBGrid, such as hiding some fields, changing their color, width etc, and the TFPWebModule should be able to read the new values and change the HTML table accordingly.

When I add the FPWebModule to a GUI Application, commands such  Application.Port := 8989 cause a syntax error, and I when I add a form to an application created as a web application, the form doesn't show at runtime.

Is there some way to combine the two?

Or are there other web components which can work in a GUI app?

Lazarus 3.0/FPC 3.2.2

krolikbest

  • Full Member
  • ***
  • Posts: 246
Hi
I did it keeping fphttpServer in separate thread.


vfclists

  • Hero Member
  • *****
  • Posts: 1013
    • HowTos Considered Harmful?
Can you show the code?
Lazarus 3.0/FPC 3.2.2

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
When I add the FPWebModule to a GUI Application, commands such  Application.Port := 8989 cause a syntax error, and I when I add a form to an application created as a web application, the form doesn't show at runtime.
Syntax error? Unlikely, should be a semantic error since both web and gui application has Application object on each own (with different set of properties).
The web handler part must be run on its own thread, since Application.Run is a blocking procedure. See attached project for a starting point.

vfclists

  • Hero Member
  • *****
  • Posts: 1013
    • HowTos Considered Harmful?
When I add the FPWebModule to a GUI Application, commands such  Application.Port := 8989 cause a syntax error, and I when I add a form to an application created as a web application, the form doesn't show at runtime.
Syntax error? Unlikely, should be a semantic error since both web and gui application has Application object on each own (with different set of properties).
The web handler part must be run on its own thread, since Application.Run is a blocking procedure. See attached project for a starting point.

You are right about it being a sematic error. I have to check the type that Application in the lpr refers to. They both seem to be TApplication rather than a subclassed type.

PS. After reading the code it seems that both project1.lpr and unit2.pas have their own application types.

Does the Application type in unit2.pas derive from its being in a thread? Do threads have the own application object, or does fphttpapp have its own Application type defined within it?


Thanks for the sample project.
« Last Edit: January 26, 2021, 06:06:34 pm by vfclists »
Lazarus 3.0/FPC 3.2.2

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Does the Application type in unit2.pas derive from its being in a thread?

Do threads have the own application object, or does fphttpapp have its own Application type defined within it?
The last one. You should be able to ctrl+click the application object to get directed to respective unit.

vfclists

  • Hero Member
  • *****
  • Posts: 1013
    • HowTos Considered Harmful?
Does the Application type in unit2.pas derive from its being in a thread?

Do threads have the own application object, or does fphttpapp have its own Application type defined within it?
The last one. You should be able to ctrl+click the application object to get directed to respective unit.

I just did that. I have been away from Lazarus for while and I need to refresh my mind on its workings. :)

I have used Indy components in threaded applications in the past and I need to pull them up to see exactly what I did.
Lazarus 3.0/FPC 3.2.2

 

TinyPortal © 2005-2018