Jump to content

Kryvich

Members
  • Content Count

    407
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by Kryvich

  1. Kryvich

    My custom component becomes NI>

    Have you set the overflow and range checking in the project options?
  2. Kryvich

    Need help with IDhttp and Thread

    Yes, it's possible. And just in case an user needs to stop the download, I added the corresponding button. Now there are 3 states: dsIdle, dsExecuted and dsStopped. Downloader.zip
  3. Kryvich

    Need help with IDhttp and Thread

    Hi, @clubreseau @Remy Lebeau gave you everything you needed to finish the job. But OK, in the attachment to this message is a ready test application based on Remy's code, with the addition of a thread pool. Tested on Delphi CE. Downloader.zip
  4. Kryvich

    Having fun with Delphi

    With Marat's proposal, you should not explicitly free the memory. Moreover, the record will be located in the stack, as opposed to the object.
  5. Kryvich

    Having fun with Delphi

    There are two points. 1. It would be possible to add a helper for the string type, but then the standard helper for this type will stop working. 2. It is considered good style to have specialized string or numeric types for special uses.
  6. Kryvich

    Having fun with Delphi

    First, I must note that IncludeTrailingURLDelimiter(IncludeTrailingURLDelimiter(dir1)+dir2) equals to IncludeTrailingURLDelimiter(dir1)+IncludeTrailingURLDelimiter(dir2) If your problems are 1) the function name is too long, and 2) you prefer the dot notation, then type TURL = type string; TURLHelper = record helper for TURL function AddDelimiter: TURL; end; function TURLHelper.AddDelimiter: TURL; begin Result := IncludeTrailingURLDelimiter(Self); end; and use it as follows: myURI := Dir1.AddDelimiter + Dir2.AddDelimiter + FileName;
  7. Kryvich

    Common callback functions, or not?

    Nowadays, callbacks (not events) are often replaced by anonymous functions.
  8. Kryvich

    Character spacing in RichEdit control

    The fun part is that WordPad, which uses the same Rich Edit control, can display text correctly in Windows 7 (but not in XP).
  9. Kryvich

    Common callback functions, or not?

    @Mike Torrettinni I think procedures are more preferable than functions for events, because you can easily recognize where an event is called and where it is assigned. I mean FOnGetSearchTextLine := GetSearchTextLine; // Assigning s := GetSearchTextLine(123); // Calling in your initial design
  10. Kryvich

    Character spacing in RichEdit control

    Yes, I see the same. It's strange, because when I generate tom_TLB.pas, even in Windows XP there is Spacing property in ITextFont interface. After doc.Selection.Font.Spacing := ASpaces, the Spacing property is actually returns the new value, but the edit control is not displaying as expected.
  11. @Stefan Glienke I have always considered strings with reference counting and automatic memory allocation as one of Delphi/Pascal's best features. This is one of those features that makes it worth staying on Delphi and not switching to NET or Java.
  12. Delphi already has the best string type, there is nothing to improve. But if they remove the code page identifier from each instance of a string in memory, the type will be even better. Because then all unwanted implicit string conversions will be gone.
  13. Also you can check this library:
  14. mORMot has AES encryption/decryption.
  15. Kryvich

    ANN: HTML Office Library

    Make ActiveX control for C#/VB and you will beat them all.
  16. Kryvich

    ANN: HTML Office Library

    Hi, Alexander. You create incredible software! They are rich in functionality, cost money and they deserve it. But perhaps you would consider creating a simplified HTML component with basic functionality only for Community Edition users, to use in free and open source projects?
  17. Kryvich

    MiTeC DFM Editor 8.0.0

    New developer's instruments are always welcomed! (Fix the link, should be "dfm.html" instead of "pm.html")
  18. Kryvich

    Character spacing in RichEdit control

    You need RichEdit50W, but TRichEdit utilize Riched32.dll / Riched20.dll, not MsftEdit.dll. In my program I used JvRichEdit from JVCL library, modified to utilize MsftEdit.dll instead of Riched32.dll. Updating the component version also significantly speeds up a loading of large RTF files.
  19. Kryvich

    Organizing enums

    I have several open-source projects, old and new, but there is no active use of enumerations. But they are actively used in my amateur projects related to linguistics and others. To give a hint of how the enumerations can be used, take for example the syntactic analyzer messages, warnings and errors: TSyntaxMessage = (smNone, // Here are suggestions of syntax analyzer: smRareLinkForWord, // Rare syntactic link smFirstSuggestion = smRareLinkForWord, smAdjToVerb, //... smSuggestionN, smLastSuggestion = smSuggestionN, // Here are warnings smNotLinkedWord, smFirstWarning = smNotLinkedWord, // ... smWarningN, smLastWarning = smWarningN // Here are errors ); We have a list of messages logically divided into groups: 1) no message smNone, 2) suggestions smFirstSuggestion..smLastSuggestion, 3) warnings smFirstWarning..smLastWarning, 4)... I don't need to set numerical values of members and check if they fall into the required sub-ranges. This happens automatically. Now I can write: case SyntaxMessage of smNone: ; // All is OK smFirstSuggestion..smLastSuggestion: ProcessSuggestion; smFirstWarning..smLastWarning: ProcessWarning; else Assert(False, 'Ops...'); end; We can create a helper to work with messages: TSyntaxMessageHelper = record helper for TSyntaxMessage class function FromString(S: string): TSyntaxMessageHelper; static; // Returns TSyntaxMessage by the name function ToString: string; // Returns the name of message function Text: string; // Get a text of user's message end; And use this as follows: Mess1 := TSyntaxMessage.FromString('smBadUseOfVerb'); // when loading from XML etc. s := Mess1.ToString; // when saving to XML, JSON,... ShowMessage(Mess1.Text); Then we can declare a set of messages, add a helper for it, and work in a convenient manner. TSyntaxMessages = set of TSyntaxMessage; TSyntaxMessagesHelper = record helper for TSyntaxMessages class function FromString(S: string): TSyntaxMessages; static; function ToString: string; function Text: string; function First: TSyntaxMessage; function IsEmpty: Boolean; function Count: Integer; procedure ExcludeWarnings; procedure Include(const Messages: TSyntaxMessages); procedure Exclude(const Messages: TSyntaxMessages); procedure ForEach(Proc: TSomeProcedure); //... end; MyMessages := TSyntaxMessages.FromString('smRareLinkForWord smAdjToVerb smNotLinkedWord'); if not MyMessages.IsEmpty then Mess := MyMessages.First; MyMessages.Include(OtherMessages); MyMessages.ForEach(DoSomething); We can add inline to the method declarations for faster code. A variable of type TSyntaxMessages will have a minimum size sufficient to store the set. The compiler will automatically check for ranges.
  20. Kryvich

    Organizing enums

    Don't take it to heart. Sometimes it is difficult to find the right English words, which makes my sentences sound too categorical.
  21. Kryvich

    Organizing enums

    As for its own database, the program may store the enumerations in a field of any type: text, binary. But if a programmer chooses the binary format, then it is his responsibility to correctly interpret the stored data. It is possible, for example, to add a format version to the database and interpret the stored data accordingly.
  22. Kryvich

    Organizing enums

    It is why textual exchange and API formats were invented. XML, JSON, YAML. It's why Microsoft replaced the binary format DOC with DOCX. Do not pass an enumeration member by its numeric value, use its name.
  23. Kryvich

    Organizing enums

    Members of an enum are not objects. For ex. I have IDs of syntax relations of words in a natural language (about 200 IDs). The numerical values of the enumeration members are not important to us, only their names matter. Therefore, there is no need to specify integer values for each member of an enum in your program. 1., 2., 3., 4. - it was the answer to the words of Wirth, which you quoted earlier. Enumerations were invented in order not to use ordinalities of its members directly. And so as not to (accidentally) add, subtract and divide them like numbers. This is Pascal where type safety matters. Headers can use enums as well. It depends on how the С-language headers are translated into Pascal code. With enumerations, you can reorder old values as you want. And nothing will break if the ordinalities are not directly used anywhere. Overcomplication, misuse of software entities.
  24. Kryvich

    Compiler: Endless loop

    Interesting... Perhaps you got cyclic unit relations? You can check it with Unit Dependency Analyzer for ex.
  25. Kryvich

    Organizing enums

    When I need to add a new member to the enum, I ... just insert the new member into the enum. If I had a set of named constants, I would have to renumber all the constants starting from the insertion position. So what about extensibility?
×