docjones Posted January 17, 2012 Posted January 17, 2012 Hi I'm trying to create a unigui console standalone application, and it's working fine , no tray icon, and not vcl form interface. (perhaps this is not the best way to create console ungui application but is the only that occurred to me). But have a problem, if i try to change the server port, uniservermodule.port:=xxxx , or server.port, it's not working, always is running on port 8077. I tried to overload uniservermodule constructor, and passing port on constructor Tuniguiservermodule.create(application,port), but same problem, always running on port 8077. How can i do to run on diferent port ?. I attach a example. thanks. console01.zip Quote
Administrators Farshad Mohajeri Posted January 17, 2012 Administrators Posted January 17, 2012 procedure TUniServerModule.UniGUIServerModuleBeforeInit(Sender: TObject); begin Port:=1234; end; Quote
docjones Posted January 17, 2012 Author Posted January 17, 2012 thanks for your quick answer, solved. but a question, why if i put port=xxxx property on overloaded constructor uniservermodule.create(..), then miss port asigned value in ServerModuleBeforeinit(..). ?, it's a bug?. thanks again. Constructor TUniserverModule.Create(Aowner:Tcomponent;DefaultPort:Integer); Begin Fport:=DefaultPort; port:=Fport; //first asignment. writeln('Tuniservermodule.Create() Port='+inttostr(port)); inherited create(Aowner); End; procedure TUniServerModule.UniGUIServerModuleBeforeInit(Sender: TObject); begin Writeln('Tuniservermodule.BeforeInit() Port='+inttostr(port)); if port<>FPort then begin Writeln('Detected diferent port than assigned oncreate(), Port='+inttostr(port)); port:=FPort; //asigned again. end; end; Quote
Administrators Farshad Mohajeri Posted January 17, 2012 Administrators Posted January 17, 2012 thanks for your quick answer, solved. but a question, why if i put port=xxxx property on overloaded constructor uniservermodule.create(..), then miss port asigned value in ServerModuleBeforeinit(..). ?, it's a bug?. thanks again. Constructor TUniserverModule.Create(Aowner:Tcomponent;DefaultPort:Integer); Begin Fport:=DefaultPort; port:=Fport; //first asignment. writeln('Tuniservermodule.Create() Port='+inttostr(port)); inherited create(Aowner); End; procedure TUniServerModule.UniGUIServerModuleBeforeInit(Sender: TObject); begin Writeln('Tuniservermodule.BeforeInit() Port='+inttostr(port)); if port<>FPort then begin Writeln('Detected diferent port than assigned oncreate(), Port='+inttostr(port)); port:=FPort; //asigned again. end; end; TUniGUIServerModule is a TDataModule descendant and it reads properties from DFM file when constructor Create() is called. You can try overriding AfterConstruction for this purpose. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.