-
Content Count
43 -
Joined
-
Last visited
Everything posted by CoMPi74
-
Hi there, I have a problem with TIdHL7 (Windows 8, Delphi XE4, Indy, ver. 10.6.2.0). Of course, I am trying to solve it by myself, but still without success. Anyway, here is a piece of code which makes me crazy... // stopping IdHL7 before configuration if IdHL7.Going then IdHL7.Stop; // setting timeouts and server address IdHL7.ReceiveTimeout := 1 * 60 * 1000; IdHL7.Timeout := 1 * 60 * 1000; IdHL7.IsListener := False; IdHL7.Address := SERVER_ADDRESS; IdHL7.Port := SERVER_PORT; // starting the connection IdHL7.Start; IdHL7.WaitForConnection(10000); // getting and sending some messages from DB while not AQuery.EOF do begin AMessage := AQuery.FieldByName('MessageToSend').AsString; AReturn := IdHL7.SynchronousSend(AMessage, AReply); // This is a problematic line ... AQuery.Next; end; As one can see I want to send some HL7 messages to SERVER. The server is online and it gets the messages send by SynchronousSend method and responds for them (confirmed). My logs show that the code works as expected but only for the very first call SynchronousSend (the method returns srOK and a valid reply sent byt the remote server). Unfortunatelly, every next call of SynchronousSend returns srTimouts, even if the result is returned just a few miliseconds after call, what is strange because, as you can see, the timeouts are set for 60 seconds ๐ What I am doing wrong? What I am missing? @Remy Lebeau as everyone knows, You are the undisputed Guru on this topic, so I am sure it is a piece of cake for you. Could you be so nice to help?
-
In fact, I managed to solve the problem by creating a new instance of the TIdHL7 object every time I try to send a HL7 message. In this case, everything works as it should. However, as I wrote earlier, when I tried to send a second message using the same instance of the component (with exactly the same settings), I received the srTimeout message. There's clearly something going on, but I can't find it myself. Especially since I use TIdHL7 component in a Windows service, which makes debugging very difficult... Anyway, thank you, @Remy Lebeau. PS. Is there any smart way to debugging windows services?
-
@Remy Lebeau The Indy components have been upgraded a month ago, or so, and now I use Indy ver. 10.6.2.0. Anyway, today's tests show that the app sends the messages every second time (I mean, the first call returns srOK and a valid reply, the second, srTimout and no reply, the third, as the first, srOK and the fourth, as the second, srTimeout, and so on). Looking into code I noticed that when the AsynchronousSend returns srTimeout the method DropClientConnection is called... I suppose that could be the cause of such a behavior... I also tried to use another approach. I changed the CommunicationMode to cmSingleThread, and then I was calling SendMessage and GetReply. Unfortunatelly, without success. GetReply returned srNone evere time. It is quite strange because, as one can read in comments, the state srNone is internally used and (should be) never returned ๐ Any idea?
-
@Primoลพ Gabrijelฤiฤ Trying to compile following code: fController := CreateTask(TWorker.Create).MsgWait.Run; I got an error with a message: [dcc32 Error] Unit1.pas(269): E2250 There is no overloaded version of 'CreateTask' that can be called with these arguments. Any clue?
-
Is there a way to create a kind of custom form (or custom form descendant) which would be completely transparent for all mouse and keyboard activities. More precisely, I need a custom form (or other control) to show a message which will disappear after a certain amount of time.
-
@Uwe Raabe I can not believe it. Is it really so simple? No way ๐
-
@KodeZwerg I did not test it but I am afraid such a form can be activated (gets focus) when clicked. I want to avoid such behaviour.
-
@dummzeuch That is exactly what I need :) Thank you
-
Is it possible to modify the templates? Or are they hardcoded? I mean I would like to paste my strings as '%s +', so without 'sLineBreak +' and similar.
-
How to set event handler for generic TControl descendant using RTTI
CoMPi74 posted a topic in General Help
Hi there, I'm struggling with the problem for several hours and I can't solve it. function TMyForm.CreateControl(AClass: TControlClass): TControl; procedure SetDefaultEventHandlerIfEventExists(const AControl: TControl; const AEvent, AHandler: string); begin if IsPublishedProp(AControl, AEvent) then SetMethodProp(AControl, AEvent, GetMethodProp(Self, AHandler)); end; begin Result := AClass.Create(Self); Result.Parent := Self; SetDefaultEventHandlerIfEventExists(Result, 'OnClick', 'DoOnClick'); SetDefaultEventHandlerIfEventExists(Result, 'OnDblClick', 'DoOnDblClick'); [... a few other events ...] // Since all 'DoOnEvent's are private, local methods of TMyForm I would prefer to use something like below, but I can not manage it to work. What have I missed? SetDefaultEventHandlerIfEventExists2(Result, 'OnClick', DoOnClick); SetDefaultEventHandlerIfEventExists2(Result, 'OnDblClick', DoOnDblClick); end; Can anyone enlighten me? What have I missed? PS. I forgot to mention, I use Delphi XE4. Yes, I know, it's a bit old ๐ -
How to set event handler for generic TControl descendant using RTTI
CoMPi74 replied to CoMPi74's topic in General Help
@PeterBelowIt does not work with @Self but works, perfectly, with @TMyForm. Nice catch! Thank you. -
How to set event handler for generic TControl descendant using RTTI
CoMPi74 replied to CoMPi74's topic in General Help
@programmerdelphi2k Thank you :) -
How to set event handler for generic TControl descendant using RTTI
CoMPi74 replied to CoMPi74's topic in General Help
Nice piece of code. But I can not compile it. I get 'E2036 Variable required' in SetEvent('OnClick', @DoOnClick). To be honest, I experienced similar problem - I was not able to get the address of the event handler method. -
How to set event handler for generic TControl descendant using RTTI
CoMPi74 replied to CoMPi74's topic in General Help
Actually, there is. "DoOnClick" can not be a strict private method if you want to use GetMethodProp. That was I wanted to say. Anyway, thank you for you response, which shows me different point of view for my problem :) -
How to set event handler for generic TControl descendant using RTTI
CoMPi74 replied to CoMPi74's topic in General Help
@Stefan Glienke you are genius, really. Now it works as expected. Thanks a million. But, by the way, I have another question. Because all these overloads shades the code, then, instead of function TMyForm.CreateControl(AClass: TControlClass): TControl; procedure SetEventHandler(const AControl: TControl; const AEventName: string; const AEventHandler: TNotifyEvent); overload; begin if IsPublishedProp(AControl, AEventName) then SetMethodProp(AControl, AEventName, TMethod(AEventHandler)); end; procedure SetEventHandler(const AControl: TControl; const AEventName: string; const AEventHandler: TKeyEvent); overload; begin if IsPublishedProp(AControl, AEventName) then SetMethodProp(AControl, AEventName, TMethod(AEventHandler)); end; [...] begin Result := AClass.Create(Self); Result.Parent := Self; SetEventHandler(Result, 'OnClick', DoOnClick); SetEventHandler(Result, 'OnKeyDown', DoOnKeyDown); SetEventHandler(Result, 'OnChange', DoOnChange); SetEventHandler(Result, 'OnSelect', DoOnSelect); end; I wanted to use something like this function TMyForm.CreateControl(AClass: TControlClass): TControl; begin Result := AClass.Create(Self); Result.Parent := Self; if IsPublishedProp(Result, 'OnClick') then SetMethodProp(Result, 'OnClick', TMethod(TNotifyEvent(DoOnClick))); if IsPublishedProp(Result, 'OnKeyDown') then SetMethodProp(Result, 'OnKeyDown', TMethod(TKeyEvent(DoOnKeyDown))); [...] end; But I get 'E2089 Invalid typecast' error. Is not it the same? Any suggestions? -
How to set event handler for generic TControl descendant using RTTI
CoMPi74 replied to CoMPi74's topic in General Help
Can' t use GetMethodProp because I prefer all my event handlers to be strict private. -
How to set event handler for generic TControl descendant using RTTI
CoMPi74 replied to CoMPi74's topic in General Help
For implementation, like below, function TMyForm.CreateControl(AClass: TControlClass): TControl; procedure SetDefaultEventHandlerIfEventExists2(const AControl: TControl; const AEvent: string; const AHandler: TMethod); begin if IsPublishedProp(AControl, AEvent) then SetMethodProp(AControl, AEvent, AHandler); end; begin Result := AClass.Create(Self); Result.Parent := Self; SetDefaultEventHandlerIfEventExists2(Result, 'OnClick', DoOnClick); SetDefaultEventHandlerIfEventExists2(Result, 'OnDblClick', DoOnDblClick); [... a few other events ...] end; I got 'E2035 Not enough actual parameters' error... Using '@DoOnClick gives exactly the same error... -
How to set event handler for generic TControl descendant using RTTI
CoMPi74 replied to CoMPi74's topic in General Help
That's the problem :) I do not know. But, in general, it would be modified version of `SetDefaultEventHandlerIfEventExists`... -
I think @Stefan Glienkeis very busy right now. As far as I remember, he mentioned two new machines, so it may take a while ๐ It's a pity because I would also like to "hug" this tool ๐
-
Patch a private virtual method
CoMPi74 replied to pyscripter's topic in RTL and Delphi Object Pascal
@Stefan Glienke Should this also work for 'AfterConstruction'? -
Hi there, I am looking for the IDE's (or a third party add-on's) option which auto sets the editor in a readonly mode when opening a file from search path. I remember that years ago I was using such an option but now I can not find it again. Any ideas? Piotr
-
Thank you @Ondrej Kelle. I will check it soon :)
-
Actually, I was talking about all files on path defined in Options (Delphi Options -> Library -> Directories -> Library / Browsing path). My fault, I should explain it better. Sorry. My problem is that using Ctrl+LMB I often get to a source code I don't want to modify (like VirtualTrees.pas) what, unfortunatelly, happens to me very often. So is there a way to have those files 'protected' against accidental, unintentional modifications?
-
1. Is it possible to persistently hide history pane in grep results? I am not sure but I think I remember that some time ago it was possible. Anyway, now (since version 1.3.20) I am not able to achieve that ๐ Deselecting 'View -> History list' checkbox does not work because, from time to time, the pane is showing anyway. Of course, when it happens, the checkbox is checked. I hope I not need to mention that I don't turn on this checkbox myself;) 2. Almost everytime I use grep for searching some (any?) string in all files in project group (maybe it also happens with other settings but I did not check it) I got 'Out of memory' error. The situation happens regardless of whether there is, or not, free memory. Followed grep options are checked: Whole word, Search form files, All file in project group, Parse map file and all options in Delphi Code Content Types and Delphi Code Sections. Can anyone confirm these problems? PS. Delphi XE4, GExperts 1.3.21
-
Nobody? Really? Maybe @dummzeuch?