Jump to content

Anders Melander

Members
  • Content Count

    2946
  • Joined

  • Last visited

  • Days Won

    166

Everything posted by Anders Melander

  1. Anders Melander

    Limit TAction shortcut to a particular control

    My guess would be that you could just disable the TListView actions when the control isn't focused.
  2. Anders Melander

    "Png to pixel-perfect svg conversion" (I didn't make this)

    Fair point. FWIW, I doubt that the method it uses can be improved much; Small color bitmaps often employ techniques such as unconscious inference, color psychology, and patterns to trick the brain into producing a better image than what would normally be possible given the available pixels. Larger bitmaps is another story.
  3. Anders Melander

    "Png to pixel-perfect svg conversion" (I didn't make this)

    What's the use case for this? I mean what problem does it solve? Given that it just converts pixels to vector rectangles I don't really see the point. The blurriness you get when upscaling a bitmap is by design. You can just use another resampling method if the blur is a problem. (Just thinking out loud, so to speak; I understood that you aren't the author)
  4. Anders Melander

    What is the best AI at Delphi

    Exactly.
  5. Anders Melander

    What is the best AI at Delphi

    That's a really stupid chart; It's displaying percentage of "marketshare". But what is the market here? It's the OS market - regardless of platform. So your server gets a vote, your fridge, your phone, your car, your nuclear submarine targeting control system, they all get a vote. Windows and the VCL primarily targets the Server or Desktop segment so those are the only that are relevant. It's pretty irrelevant that the majority of smartphones are running Android and the majority of embedded systems are running Linux, because those platforms are not targeted by Windows or the VCL. I believe Linux surpassed Windows in the server segment many years ago, but we can't see that from the chart.
  6. Anders Melander

    Calling routines overhead

    Profile it. The significance of the overhead really depends on what the routine is doing and how often it is called. For example if the call overhead is X but the routine itself takes 1000*X to execute then the overhead is insignificant. Apart from the overhead of the call itself there's the overhead of passing parameters. You need to learn how parameters are passed in order to optimize them. Not all parameter types can be passed in registers, Delphi doesn't use all available registers, 32-bit and 64-bit does things differently, etc. Also be aware that if you pass literal floating point numbers as parameters, the compiler might not consider the literal values to be the same type as the parameter which means that it will produce code to convert the values to the correct type. For example, if the parameter type is Single and you need to pass 0.5, then pass it as Single(0.5) - or declare a typed constant with the value and pass that. Set Code Inlining Control=Auto to have the compiler automatically inline small routines. With regard to writing stuff in assembler be aware that assembler routines can't be inlined so the call overhead becomes mandatory. For example, in my code one constant bottleneck is calls to Round and Trunc. I have assembler versions of these two functions which are much faster but unfortunately the call overhead completely eliminate the performance gain so they are basically useless. It's beyond me why Delphi doesn't implement these two as intrinsics. They are listed as such but they are implemented as regular functions. Not only that, but the Pascal version will provide a reference implementation to test and benchmark against and it will help documenting what the assembler versions does.
  7. Anders Melander

    LoadLibrary and FreeLibrary notification

    LdrRegisterDllNotification (Vista+) LdrInitShimEngineDynamic (undocumented, XP+ AFAIK)
  8. They are probably too busy Getting Real Help For Free With Code Reviews, Pull Requests, And Git Commits. 🤡
  9. No. You are wasting your time.
  10. QuickJS is a javascript engine while pas2js is a transpiler that emits javascript. Not even remotely the same thing.
  11. Anders Melander

    TeeBI free full sources released

    Needs more arrows!
  12. Anders Melander

    Profiling Tools for Delphi Apps?

    https://en.delphipraxis.net/search/?&q=profilers&search_and_or=or&sortby=relevancy https://www.google.com/search?q=delphi+profiling A few versions (around XE) had a limited version of AQTime bundled in. Apart from that it's hardly their area of expertise and it's been ages since they had resources to spare for anything but the core product. That will never happen. There's simply no benefit for them in open sourcing it, only expense, and it probably also contains code that can't be open sourced.
  13. Anders Melander

    THintWindow; exposing the WMLButtonDown event

    A window will only receive mouse messages if the mouse cursor is within its client area or it has captured the mouse. I don't think a hint window will satisfy either of those criteria. See also: https://learn.microsoft.com/en-us/windows/win32/inputdev/about-mouse-input
  14. Anders Melander

    Is it possible to implement floating/fully custom Dropdown Menus?

    It took me a good while to spot the difference between the two screenshots but I get your meaning. AFAIK it's possible to control DevExpress' skinning of standard VCL controls to some degree. See TdxSkinController.OnSkinControl The dependencies though 😕
  15. Anders Melander

    Is it possible to implement floating/fully custom Dropdown Menus?

    The easiest way is probably to just use a TForm as the poup. You need to: Display the form with ShowWindow(SW_SHOWNA). Handle WM_NCACTIVATE to avoid the form activating when clicked. In CreateParams: Set Params.WndParent to the parent form. Add WS_POPUP and WS_CLIPCHILDREN to Params.Style and exclude WS_CHILD. Add WS_EX_TOPMOST and WS_EX_TOOLWINDOW to Params.ExStyle. If you will be implementing the form shape with alpha blending then you also need to add WS_EX_LAYERED. Shape the form either with alpha blending (WS_EX_LAYERED and SetLayeredWindowAttributes) or with regions (I can't remember the APIs for that OTOH). I'm sure that if you search github for the above (with lang:pascal) that you can find some Delphi examples. See also: http://melander.dk/articles/alphasplash/ ...or you could just throw some $$$ at DevExpress and use their TdxCalloutPopup control:
  16. Oh - You meant what version of RAD Studio is installed on the local system. I think the InstalledUpdates registry key is the closest you can get. There's no guarantee that it's valid though since it's only informational.
  17. GetRTLVersion would be my guess. The actual values appears to be undocumented though - but here's an unofficial list to get you started: https://delphidabbler.com/notes/version-numbers
  18. Anders Melander

    Bitmaps to Video for Mediafoundation

    "Not thread-safe" in this case doesn't mean crash and burn. It just means that if one thread modifies the global FormatSettings then it will affect all other threads also using it. Hardly a problem - even if you did output floating point values in the exception message.
  19. Anders Melander

    Bitmaps to Video for Mediafoundation

    Likely because Renate is using a newer version of Delphi. As far as I can tell the faulty code was contributed by someone else.
  20. Anders Melander

    Bitmaps to Video for Mediafoundation

    🙂 No, of course that doesn't work A dynamic array is initialized to an empty array so there needs to be a SetLength first.
  21. Anders Melander

    Bitmaps to Video for Mediafoundation

    FWIW & FYI: Newer versions of Delphi have IntToHex overloads for NativeInt to match the size of a pointer. I think it got introduced in Delphi 10. TArray<T>, being a dynamic array, is a manages type and string too, so TArray<string> should be initialized automatically. Probably a compiler bug.
  22. Anders Melander

    Bitmaps to Video for Mediafoundation

    If only there was some magic key you could press in the editor to display help about various relevant topics... 🙂 I only ever use %s %d, %n and %x - and I use those a lot so that helps but I sometime need to consult that magic key when it comes to the precision or index specifiers.
  23. Anders Melander

    Bitmaps to Video for Mediafoundation

    There's not even a need for try..finally since there no resources to protect; Get rid of hr, assign the results to Result directly and just exit. Also, instead of: raise Exception.Create('Fail in call nr. ' + IntToStr(Count) + ' of ' + ProcName + ' with result $' + IntToHex(hr)); I would use: raise Exception.CreateFmt('Fail in call no. %d of %s with result %x', [Count, ProcName, hr]); for readability.
  24. Anders Melander

    Creating webp files with Skia fails

    I'm pretty sure Skia's BMP handling isn't bug-free but it's way more likely that this problem is caused by the Delphi side of things; The alpha handling in VCL's TBitmap is such a horrible mess that it should be deprecated and reimplemented from scratch. See also:
  25. Anders Melander

    Creating webp files with Skia fails

    FWIW, this is what it looks like in Firefox, so not totally broken:
×