-
Content Count
1167 -
Joined
-
Last visited
-
Days Won
16
Everything posted by FPiette
-
How do I enumerate all properties of a Variant?
FPiette replied to Phil Brinkle's topic in General Help
Thanks. If you like my answer, please mark it as such (The heart icon on the right side of my answer). Maybe you have a type library ? If you import it into Delphi, you'll have all the information. -
How do I enumerate all properties of a Variant?
FPiette replied to Phil Brinkle's topic in General Help
Yes, you can. Basically, you have to call GetTypeInfoCount(), GetTypeInfo(), GetTypeAttr() and other functions (All documented by Microsoft). Here is a function to list all method names including property getter/setter. Similar code can enumerate argument list, argument data types and return value data type. procedure DisplayMethodNames( const DispIntf : IDispatch; const IntfName : String; Strings : TStrings); var Count : Integer; TypeInfo : ITypeInfo; TypeAttr : PTypeAttr; FuncDesc : PFuncDesc; HR : HRESULT; I : Integer; FuncName : WideString; begin if IntfName <> '' then Strings.Add(IntfName); Count := 0; HR := DispIntf.GetTypeInfoCount(Count); if Failed(HR) or (Count = 0) then Exit; HR := DispIntf.GetTypeInfo(0, 0, TypeInfo); if Succeeded(HR) and (TypeInfo <> nil) then begin TypeAttr := nil; HR := TypeInfo.GetTypeAttr(TypeAttr); if Succeeded(HR) and (TypeAttr <> nil) then begin for I := 0 to TypeAttr.cFuncs - 1 do begin FuncDesc := nil; HR := TypeInfo.GetFuncDesc(I, FuncDesc); if Succeeded(HR) and (FuncDesc <> nil) then begin TypeInfo.GetDocumentation(FuncDesc.memid, @FuncName, nil, // DocString, nil, // HelpContext nil); // HelpFile if Length(FuncName) <> 0 then Strings.Add(Format(' %-3d %s', [I, FuncName])); TypeInfo.ReleaseFuncDesc(FuncDesc); end; end; TypeInfo.ReleaseTypeAttr(TypeAttr); end; end; end; -
Common callback functions, or not?
FPiette replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
Your are right: an event is a kind of callback. But not all callbacks are events. In Delphi there is a pattern for the events. I explained that pattern in a few previous messages and @Fr0sT.Brutal expressed it again using different words. -
Common callback functions, or not?
FPiette replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
I really like event very much. I don't see any use case which requires a callback. Do you? -
There are several TriggerSendData. In which class do you need it?
-
Common callback functions, or not?
FPiette replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
No exactly. You need to pass the arguments for the call: if Assigned(FOnGetSearchTextLine) then FOnGetSearchTextLine(Self, ADataIdx, Result); -
Common callback functions, or not?
FPiette replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
Where is the "thanks" button? As I said: hover the "like" button and you'll see it. The like button is the heart icon on the bottom right corner of a message. -
Common callback functions, or not?
FPiette replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
Instead of writing "thanks" in the message, you should click the "thanks" button (Hover the "like" button to see it). -
Common callback functions, or not?
FPiette replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
The idea is that when no event handler is assigned, the component/class/object works correctly. That's why they are procedure and returned values are passed as var argument, just like I have done in my example: function TSearchFrom.GetSearchTextLine(ADataIdx : Integer) : String; begin Result := ''; // This will be the search line if no event handler assigned if Assigned(FOnGetSearchTextLine) then FOnGetSearchTextLine(Self, ADataIdx, Result); end; Another design tips is that if an event is triggered several times, a procedure is created for that: procedure TSearchForm.TriggerGetSearchTextLine(ADataIdex : Integer; var SearchText : String); begin if Assigned(FOnGetSearchTextLine) then FOnGetSearchTextLine(Self, ADataIdx, Result); end; and then you'll write: function TSearchFrom.GetSearchTextLine(ADataIdx : Integer) : String; begin Result := ''; // This will be the search line if no event handler assigned TriggerGetSearchTextLine(ADataIdx, Result); end; -
Common callback functions, or not?
FPiette replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
OK, I understand better. Your design is correct. You need an event in the search form to get text line at given index. Each frame initialize the search form event to a handler. TGetSearchTextLineEvent = procedure function (Sender : TObject; aDataIdx: integer; var TextLine : String) of object; TSearchForm = class(TForm) private FDataIdx : Integer; FOnGetSearchTextLine : TGetSearchTextLineEvent; function GetSearchTextLine(ADataIdx : Integer) : String; public function Search(ADataIdx : Integer) : String; property OnGetSearchTextLine : TGetSearchTextLineEvent read FOnGetSearchTextLine write FOnGetSearchTextLine; end; function TSearchFrom.GetSearchTextLine(ADataIdx : Integer) : String; begin Result := ''; // This will be the search line if no event handler assigned if Assigned(FOnGetSearchTextLine) then FOnGetSearchTextLine(Self, ADataIdx, Result); end; -
Common callback functions, or not?
FPiette replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
No, they are not events. An event would looks like: TGetSearchTextLineEvent = procedure function (Sender : TObject; aDataIdx: integer; var TextLine : String) of object; Your code is not very clear to me. I understand you have a TFrame which has to do a search and for that, it create and display a form. Right? Why not simply have a function Search in the form, taking what to search in arguments and return search result? No event nor callback required at all. -
Common callback functions, or not?
FPiette replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
Usually, with Delphi we use events which are a form of callbacks which are 1st category citizen in Delphi language. Callbacks as you are doing will of course work in Delphi but are more C/C++ style. I usually define all event types where they are used and duplicate it at will. Sometimes, I use a unit having "Types" as suffix in his name to put those definitions along with other related data types. -
Maybe a new Win8 or Win10 feature not supported by Win7.
-
Is the missing System.TStringHelper SetChars in Chars property on purpose ?
FPiette replied to Rollo62's topic in RTL and Delphi Object Pascal
In my opinion, using zero based strings is a source of a lot of headaches. I was very upset when Embarcadero introduced that for mobile platform. Now I'm happy they abandoned the idea. -
Is the missing System.TStringHelper SetChars in Chars property on purpose ?
FPiette replied to Rollo62's topic in RTL and Delphi Object Pascal
Better for you, but not for user of the code page feature... -
SSL GetRemoteFile not transferring the whole image
FPiette replied to Brian Culverwell's topic in ICS - Internet Component Suite
I cannot find it. What is the sample project name? Look into the source and see if you can find who wrote it? Where did you have downloaded this sample? Make sure you have the latest ICS source code -
Would be nice if you publish the code you have already tried so that we can review it and even try to make it work without having to invent a full test program.
-
For voice communication, UDP is usually used because it is no necessary to have a communication without error, but the most real time as possible.
-
HTTP/1.1 + 302 + Cloudflare = 404
FPiette replied to Shira's topic in ICS - Internet Component Suite
There is only a problem if there is no corresponding DocEnd. The real problem is you don't handle all possibles values for ContentLength, including the perfectly correct -1 value. -
HTTP/1.1 + 302 + Cloudflare = 404
FPiette replied to Shira's topic in ICS - Internet Component Suite
You should make sure ContentLength value is suitable for the ProgressBar Max property. If the content length is unknown, then the value returned is -1. And this is definitely not an ICS bug: A server may not advertise the length of the content it will send to the client. It is your responsibility as client side developer to take this kind of perfect correct issue. -
OverbyteIcsWSocket: ~25500 lines 😄 😞 OverbyteIcsWSocket is not a main unit. And it includes 18 other units (not counting the standard Delphi units). The first code line is line 4800. There are THOUSANDS of comment lines. The rest is what is really necessary to have a significant socket class which serves as the base for higher protocols. The first version of OverbyteIcsWSocket is dated April 1996. Probably today, 24 years later, I would not write it the same way. I gained some experience during all those years after all.
-
I almost always use TFrame or TForm from each page of a TPageControl. And from elsewhere I don't reference the components they are made of. Instead, the frame or form expose properties, methods and events related to what is on the page. I strongly agree with you. Having huge main unit is how newbies are coding.
-
Class TSslHttpCli not found - DELPHI5
FPiette replied to 2nd-Snoopy's topic in ICS - Internet Component Suite
That is wrong. Delphi 2009 introduced Unicode. This doesn't prevent compiling it with current Delphi version. You just have to replace in the source code "String" by "AnsiString". That's it ! Of course current Delphi still support ANSI strings (Data type is AnsiString and AnsiChar, String and Char are mapped to Unicode. Anyway, looking at Delphi Toolbox I see it has been maintained and support Delphi 10.3 which is the latest Delphi Community Editon. I don't understand that. Could you give a simple trivial example showing the problem? -
Class TSslHttpCli not found - DELPHI5
FPiette replied to 2nd-Snoopy's topic in ICS - Internet Component Suite
I made SSL part of ICS after reading the book "Network Security with OpenSSL". This is now an old book, but all the concepts and most of programming is still valid today. -
Class TSslHttpCli not found - DELPHI5
FPiette replied to 2nd-Snoopy's topic in ICS - Internet Component Suite
A certificate is used to make sure someone is really what he pretend to be. For example you want to make sure that when you connect to your bank, it is really your bank. You verify this by the certificate your bank send in the SSL session. That certificate is signed by a "certification authority" (Or a chain of such certification authorities) that you trust. A client can also use a certificate to prove he is the one he pretend to be. The server will check the certificate to see if it is one that he expect. Usually, client don't use certificate except for some VPN. Most banks don't care about your certificate, if any, because they use other authentication methods such as a physical digipass. No matter if a certificate is used or not, SSL (Or TLS) communication is stronglly crypted. Now that I have introduced the subject, I can answer: As a client you only need a certificate if the server requires a certificate.