Jump to content

Anders Melander

Members
  • Content Count

    2946
  • Joined

  • Last visited

  • Days Won

    166

Everything posted by Anders Melander

  1. Anders Melander

    String literals more then 255 chars

    What docs?
  2. Anders Melander

    String literals more then 255 chars

    Nice! And about bloody time too! But surely there's more to the CoffeeScript-like syntax than this: Like, how does one differentiate between preserve or trim leading white space and preserve or ignore newline?
  3. https://github.com/CloudDelphi/RTC-Portal-VCL
  4. Anders Melander

    Addictive software??

    You might want to link to the source when you copy/paste some text verbatim: http://hunspell.github.io/ In addition to the Hunspell library itself, the Hunspell dictionary format is also supported by many proprietary 3rd party spell check libraries such as the DevExpress spell checker. See also:
  5. Anders Melander

    User Drawing of Lines and Curves

  6. Anders Melander

    Win32, Win64, WinRT and now... WinARM ?????

    Yikes. Nobody touches my screen! Not even myself. Besides touch screens add cost and complexity.
  7. Anders Melander

    User Drawing of Lines and Curves

    It's a bug in FMX. Probably related to this one: https://quality.embarcadero.com/browse/RSP-39520 It's visible for Stroke.Thickness>1
  8. Anders Melander

    Call for Delphi 12 Support in OpenSource projects.

    As far as I remember it had something to do with some pre-Delphi 6 version attempting to parse the {$if ...} even though it was protected by a {$ifdef CONDITIONALEXPRESSIONS}. It could also just have been the fact that {$if CompilerVersion...} doesn't work above the first uses clause... Anyway, it doesn't really matter anymore. It just struck me that there was a reason why the feature didn't gain more use - from me at least.
  9. Anders Melander

    Call for Delphi 12 Support in OpenSource projects.

    So, can anyone remember which version of Delphi broke that scheme? It's not broken now, but I'm certain that there was a version after Delphi 6 that somehow broke {$IF} so it couldn't be used if backward and forward compatibility was needed.
  10. Anders Melander

    Call for Delphi 12 Support in OpenSource projects.

    For the same reason they have ridiculous NDAs and don't have public betas; They are so stuck in the 90s that they think anyone still gives a damn.n They never understood how to build a community.
  11. Anders Melander

    Call for Delphi 12 Support in OpenSource projects.

    Please stop using VERxxx. It's been possible to do {$if CompilerVersion >= XX} since Delphi 6 or 7. It's so annoying having to edit the .inc files of various 3rd party libraries with each new version of Delphi because they're designed as if the latest version = the last version. Graphics.32 uses {$LIBSUFFIX AUTO} for the D11+ packages. The earlier packages are manually maintained by using a diff tool to keep them synchronized with a master. The master usually comes from the latest supported Delphi version. There's no way I'm wasting disk space on old versions of Delphi just to maintain the package files. I have the latest version, and the few versions required by my job, and that's it.
  12. Strange... It's like there's an echo in here.
  13. Naming the constructor "Create" is just a convention. You can name it anything you like. Thus naming the constructor "From" will not make a difference. Here's your problem: Pascal isn't case sensitive so that code does nothing. Prefix your parameter names with "A" (i.e. name them AItem and AColor in this case) to avoid problems like that. FWIW, if you want to avoid memory allocation (i.e. allocate your object on the stack instead of the heap), make it a record instead.
  14. Anders Melander

    Windows 11 (22H2) 8bit bitmap problem

    There is no default 256 color palette. Old version of Windows "reserved" 16 fixed colors while new versions reserve 20 fixed colors. https://en.wikipedia.org/wiki/List_of_software_palettes#Microsoft_Windows_default_20-color_palette Changing the pixelformat to pf8bit forces the bitmap to use a color palette. I.e. instead of each pixel explicitly specifying the RGB color values, the pixels will contain an index into a palette of 256 colors. The colors in a palette generated by Windows will partially depend on the system palette which again depends on the Windows theme. https://learn.microsoft.com/en-us/windows/win32/gdi/system-palette-and-static-colors https://learn.microsoft.com/en-us/windows/win32/gdi/default-palette If you want a predictable result then you need to generate the palette using a predictable method: Either use a static palette or generate one using color quantization. There are methods in the GifImg unit for both solutions. https://docwiki.embarcadero.com/Libraries/Sydney/en/Vcl.Imaging.GIFImg.ReduceColors
  15. Anders Melander

    Remote Delphi developer position

    Not necessarily. An emphasis on a specific library is most likely caused by existing use and thus an investment in that library. Regardless of "bestness".
  16. Anders Melander

    Remote Delphi developer position

    Why is that interesting?
  17. Anders Melander

    Ann: Celebrating 20 Years of NexusDB: Get 50% Off!

    Support for FireDAC, one could hope
  18. Anders Melander

    Better Translator Manager - Custom component

    I can confirm that it doesn't work in NCSA Mosaic 2.0 I also tried Netscape Navigator 3.0
  19. Anders Melander

    VCL Styles and WM_SETCURSOR problem with scrollbars

    "Irrelevant" is the word you're looking for 🙂 If it works for you with 11.x then there is no problem.
  20. Anders Melander

    Better Translator Manager - Custom component

    Then it's probably a problem with your browser. [Ctrl]+F5 to do a forced reload or use another browser.
  21. Anders Melander

    VCL Styles and WM_SETCURSOR problem with scrollbars

    You need to have someone compile and run your project with 10.4.2 in order to conclude that. Right now you only know that your exe reproduces the problem and that an exe produced by one other person doesn't.
  22. Anders Melander

    Where is the link to register to the forum?

    To be "Musked" I believe it's called
  23. Anders Melander

    Better Translator Manager - Custom component

    Strange. The URL seems correct so it's probably just a temporary hiccup with the redirection. 2: You translate the application using the component. If you use the component in multiple projects then you will have to do the translation for each project. That's unfortunately just the way Delphi localization is designed. You can save the translations to the Translation Memory and share that between projects, but it's an almost completely manual process. All the translations are contained in the translation project file (the xlat file). A translator will need amTranslationManager.exe and the .xlat file. I would recommend that you also create a portable-mode configuration file so the translator doesn't need to install anything. I think the docs mention that. Once you receive an updated xlat file from the translator you will have to merge that into your local xlat file using some sort of text merge tool. I suggest placing the file under version control and then use that to do the merge. There is no functionality in BTM to merge two translation project files, although that would be a handy feature. It's still there: https://bitbucket.org/anders_melander/better-translation-manager/src/master/#markdown-header-deploying-a-localized-application The hello_world demo contains an example of how to allow the user to choose the language. As far as I remember there are some other methods buried in the announcement thread: If your text is written as a string (or stringlist) property, then it can be translated. Yes. Individual properties on individual components are individually translated. BTM will help you with the translation of identical texts, but it will not do it automatically since that might not be what you want. Often context matters. For example, if you translate "Cancel"->"Fortryd" then it will prompt you to translate all other occurrences of "Cancel" using the same translation. It will even offer to translate texts that "almost" match such as "cancel", "&Cancel", "Cancel!", etc. Use resourcestrings just like you would use a string constant. The only thing to be aware of is that the resourcestring name needs to be unique within the unit. Resourcestrings are a language feature and as such it is processed by the compiler and the linker (with help from the RTL at runtime). FormCreate is a run-time thing so that doesn't matter; Use them where ever you want. Some prefer to keep all resourcestrings in a separate unit, some prefer to have them at the top of the unit and some to have them declared locally where they are used. I usually declare them with the most restrictive scope I can get away with: unit Foo; implementation procedure DoFoo; resourcestring sFooPublic = 'This is a public, global resourcestring'; // Usable by all that use unit Foo interface resourcestring sFooPrivate = 'This is a private, global resourcestring'; // Usable within unit Foo procedure DoFoo; resourcestring sFoo = 'This is a local resourcestring'; // Usable within DoFoo begin ShowMessage(sFoo); end; end. Note though that FreePascal doesn't support local resourcestrings. In FPC they must be declared globally (i.e. outside the methods/functions).
  24. Anders Melander

    User Drawing of Lines and Curves

    One needs to take into account that we're not dealing with lines but line segments. Lines have infinite length, while line segments have finite length. We don't want to detect a hit beyond the end of the line segment: I think the following one does the trick. I use it in a bitmap editor for scanline conversion of lines (the above image was made with it). (* Distance from point to line segment. Let A=(xa,ya), B=(xb,yb), X=(x,y) Now, the line between A and B is given parametrically by V(k) = (1-k)A + kB = A + k(B - A) and adding the constraint 0 <= k <= 1 makes V(k) the line segment from A to B. Now, the line through X perpendicular to V(k) intersects V(k) when k equals (B - A) . (X - A) k = ------------------- | B - A |^2 So if k <= 0, X is closest to A, if k >= 1, X is closest to B, and if 0 < k < kp, X is closest to V(k). *) function DistanceToLine(X,Y, XA,YA, XB,YB: integer; var RunLength: Single): Single; function VectorLength(X1,Y1, X2,Y2: Single): Single; inline; begin Result := Hypot(X1-X2, Y1-Y2); // = Sqrt(Sqr(X1-X2) + Sqr(Y1-Y2)) end; var k: Single; dx, dy: integer; begin dx := XB-XA; dy := YB-YA; if (dx <> 0) or (dy <> 0) then begin k := (dx*(X-XA) + dy*(Y-YA)) / (Sqr(dx)+Sqr(dy)); if (k <= 0) then // Point before or at start of line segment Result := VectorLength(XA,YA, X,Y) else if (k >= 1) then // Point after or at end of line segment Result := VectorLength(XB,YB, X,Y) else // Point within line segment Result := VectorLength(X,Y, XA+k*dx, YA+k*dy); // = VectorLength(X,Y, (1-kp)*XA+kp*XB, (1-kp)*YA+kp*YB); RunLength := k; end else // Degenerate line begin RunLength := 0; Result := VectorLength(XA,YA,X,Y); end; end; The result is the distance, the RunLength parameter can be used to determine where the projection of the point onto the line lies: before, on, or after the line segment. A small optimization can be done since we're doing hit-testing and don't really need the actual, precise distance value. The VectorLength function uses Hypot (i.e. Pythagoras) to calculate the distance. Hypot internally does a Sqrt, which is an expensive operation. The Sqrt can be eliminated so we return the squared distance instead and then we just need to compare that value against the squared hit limit instead. I.e. if your hit limit was 4 then compare the squared distance against 4*4 = 16 instead.
×