Jump to content

How can I create an UniGUI app without showing the MainForm, only output HTML text ?


BugTrapper

Recommended Posts

Thank you, ServerModule.OnHTTPCommand is working, here you can output pure HTML text to the browser, and no form will be displayed afterwards, if Handled:=True is set.

But disavantage is, that you can't use any GUI controls or other controls from the palette, cause no form has been created.

Is there any method, so that the form will be created, and afterwards one can only output only HTML text without showing the form ?

Link to comment
Share on other sites

1 example for understanding:

From any desktop program (written in any other programming language), that has online access, I can make a "GET" HTTP call, with parameters for example:

www.test.com/givemesomedatabasedata?databasename=xxx&sqlcommand=yyy

Now I can write a small UniGUI app, that fetches the data from the database and respond with HTML text, for example in JSON format or in plain text back.

In Delphi database programming is much more easier than in other programming languages.

So I can take advantages from the RAD development and advantage of fast database programming in delphi.

But because for database programming you have to drag some controls on the form, for example the firedac components, there should be a possibility,

that one can create the form, but don't display it, but use them to fetch the database data, and response only with the resulting data as JSON or HTML text.

that is the idea behind it, only as an example ..., similar like a web service, only with UniGUI.........

Link to comment
Share on other sites

Yes, I see, but some components can only be created with parent, that has a window handle. Some components, like VCL components need a TForm as parent and not a TUniFrame, or anything else,

so you can't call for all visible elements call MyControl:=TMyControl.Create(self).

For example I wanted to do something like this, inside OnHTTPCommand():

var

  MyForm: TMainForm;

 begin

  MyForm:=TMainForm.Create(self);

  //now call and freel free to use some methods of controls from the form

  MyForm.Free;

.

.

end

that didn't work, an error message will be displayed inside the browser, something like: 'Form cannot created because parent must be TUniApplicationFrame' or similar.

The cause is, that "self" is here TUniServerModule and not a TUniFrame or TUniForm.

Link to comment
Share on other sites

One solution could be, not to use OnHTTPCommand(), instead show the main form, catch the parameters in MainForm.FormCreate, now you have all features and can use all UniGUI controls, then write the result of any procedure or calculation to a file.

In your second program, that calls the above web site with a HTTPRequest("GET"), call the site, after response wait a moment and read the file content with another HTTPRequest("GET",...

Now you have the result.

But I didn't test it this way.

 

I only want to use all the functionalities of controls on the main form and afterwards want to break the showing of the main form or hide the main form and respond with an HTML text. But that's too easy and didn't work with UniGUI......

That's all.

My real plans I didn't will tell on this board, of course ....... :o)

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...