BugTrapper Posted January 28, 2019 Share Posted January 28, 2019 see Title. Link to comment Share on other sites More sharing options...
Hayri ASLAN Posted January 28, 2019 Share Posted January 28, 2019 Please check ServerModule.OnHTTPCommand Link to comment Share on other sites More sharing options...
albertovesx Posted January 29, 2019 Share Posted January 29, 2019 15 hours ago, Hayri ASLAN said: Please check ServerModule.OnHTTPCommand Is this like webbroker but with unigui? Link to comment Share on other sites More sharing options...
Hayri ASLAN Posted January 29, 2019 Share Posted January 29, 2019 Yes, Before unigui handle request you will process it and show result instead of open mainform. 1 Link to comment Share on other sites More sharing options...
BugTrapper Posted January 29, 2019 Author Share Posted January 29, 2019 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 More sharing options...
Hayri ASLAN Posted January 29, 2019 Share Posted January 29, 2019 I don't understand your idea here. What is your goal? Link to comment Share on other sites More sharing options...
BugTrapper Posted January 29, 2019 Author Share Posted January 29, 2019 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 More sharing options...
Hayri ASLAN Posted January 29, 2019 Share Posted January 29, 2019 I am using same example. Let me share my code so you can understand it. Link to comment Share on other sites More sharing options...
BugTrapper Posted January 29, 2019 Author Share Posted January 29, 2019 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 More sharing options...
BugTrapper Posted January 29, 2019 Author Share Posted January 29, 2019 The creating of instances inside TUniServerModule works only for non-visible classes or components. Not for components, which are visible on the TMainForm of a simple UniGUI app, created with UniGUI wizard. Link to comment Share on other sites More sharing options...
Hayri ASLAN Posted January 29, 2019 Share Posted January 29, 2019 I can't understand why you are creating mainform for response. If you have something in mainform to serve as response, you should move it to somewhere else. It is not good idea Link to comment Share on other sites More sharing options...
BugTrapper Posted January 29, 2019 Author Share Posted January 29, 2019 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 More sharing options...
Ruslan Posted February 3, 2019 Share Posted February 3, 2019 all VCL components you can create at runtime without any forms if I understand, Do you want to create something like REST API but using delphi DB components and UniGUI instead http-server? ) Link to comment Share on other sites More sharing options...
jaromir Posted February 3, 2019 Share Posted February 3, 2019 I think that UniGui is mostly GUI. If You don’t need Gui there is a lot of better option. First (which i use) is remobject sdk. You can make any web server as You wish with this tool. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now