Jump to content

Anders Melander

Members
  • Content Count

    2561
  • Joined

  • Last visited

  • Days Won

    133

Everything posted by Anders Melander

  1. Anders Melander

    Using memory table or else

    TFDTable should be able to do all this on its own. You don't need a separate memory dataset. See TFDDataSet.Offline
  2. Anders Melander

    Window message sent to a component

    If you're using ProcessWindowMessage as the WndProc you declared with AllocateHwnd then it's no surprise that ProcessWindowMessage are seeing all messages. The message directive is used to build a message dispatch table but that table is only used if the messages are process via the Dispatch method. You could call Dispatch within your WndProc and have the message routed via the dispatch table (to another method) but there's really no reason for that extra indirection in this case. Just filter directly within ProcessWindowMessage.
  3. Anders Melander

    A book about Object Pascal Style Guide

    A wiki wouldn't require a coordinator once it's set up but it would still need somebody to rule in case of conflicts and since people doesn't agree on style (which is why a style guide is needed in the first place) I don't see a happy outcome of that.
  4. Anders Melander

    A book about Object Pascal Style Guide

    Why put a CC BY-SA license on it then? I don't care either way but as far as I can see that troll is out of the box.
  5. Anders Melander

    A book about Object Pascal Style Guide

    I knew it! https://www.imdb.com/video/vi2049426201
  6. Anders Melander

    A book about Object Pascal Style Guide

    That would be a pity. I found it well written with excellent and relevant content. Unfortunately my own experience is that those that need a style guide the most are also those that are the least likely to read something like it. In my current position one of my responsibilities is to be the source code gatekeeper; I review each and every check-in for code style, bad patterns and obvious weaknesses. We need this because many of our developers are fresh out of school and inexperienced or mainly has C# experience. On top of that much of our code were written by amateurs loooong time ago and is simply horrible. On our required reading list is a very thorough style guide which I repeatedly have to refer to when people, including our lead developer, produce code that plainly demonstrates that they haven't read it. Apparently they simply haven't understood the benefits of adherence to a common code style in a large code base.
  7. Anders Melander

    DPI Awareness, tForm.CurrentPPI and PixelsPerInch not always identical !!???

    I only started getting CAPTCHAs last month. Before that nothing. Maybe they only have a limited number of them so there's not enough for everyone to get them?... 🤔
  8. Anders Melander

    A book about Object Pascal Style Guide

    What? No comment on the pointless use of FreeAndNil? Ah. There it was 🙂 which ironically is preceded by this statement: Color me insecure then.
  9. Anders Melander

    DPI Awareness, tForm.CurrentPPI and PixelsPerInch not always identical !!???

    And there's even an easy fix. By the way, am I the only one that has problems with the CAPTCHA at quality.embarcadero.com ? I always have to answer the challenge 3 times before it accepts my answer.
  10. Anders Melander

    Debugging Issues in D11 64Bit with Packages

    This applies even to 32-bit DLLs/packages in my experience.
  11. You could do that but then you would have to use a ring buffer or something like it. It's much easier if you: Producer (probably main thread): Allocate a buffer and place it in a pool (just a list of buffers). Grab a buffer from the pool. Goto 1 if the pool is empty. Read data, process it and write to the buffer. Place the buffer into a FIFO queue. Goto 2. Consumer (a dedicated thread): Fetch a buffer from the FIFO queue. Write buffer to disk. Place buffer in buffer pool. Goto 1 You will need some synchronization primitives to control access to the FIFO queue and to signal the writer thread when there's data in the queue. It's common to use a semaphore for this. We can't make the disk faster but we can do something useful while we're waiting for the disk.
  12. Yes, I know 🙂 Looking at your numbers, since WriteFile dwarfs all the string related operations, it seems that you might be able to eliminate the need to optimize the string handling just by moving your file write operations to a background thread. For example with overlapped I/O.
  13. What? There's a manual? 😉
  14. Anders Melander

    DPI Awareness, tForm.CurrentPPI and PixelsPerInch not always identical !!???

    Nice catch! 👌
  15. It's a tool you should have in your tool chest so consider it an investment. A profiler is the only way to make sure you aren't doing premature optimization. The VTune profiler is free and with map2pdb you can use it with Delphi.
  16. No need for that. Just run it in a profiler and you will know exactly which statements you should concentrate your efforts on.
  17. Shouldn't that be "that can be consumed and used in a tool instantly"...? or do you know of something other than ANTLR that consumes the ANTLR grammar?
  18. Exactly - and you don't need to be an expert to come to that conclusion.
  19. No. It's regular BNF. You can tell by the use of <> brackets and :== Here's a comparison: https://en.wikipedia.org/wiki/Syntax_diagram#Example
  20. Anders Melander

    Updated Community Edition

    Me too . Bought at 6, sold half at 12 and then got out as it passed 8 on the way down. It never recovered after that. Although I did make a bit of money on it that was soured by the fact that they burned the company and its reputation to the ground.
  21. Anders Melander

    UnPinnable App

    Okay. "var pps: pointer" matches the documented API (so it's correct) but if you want to use an out parameter instead then the correct declaration would be: function SHGetPropertyStoreForWindow(hwnd: HWND; const riid: TGUID; out ppv): HResult; stdcall; because ppv is documented as: which means that it can return another interface if you request that. Note the untyped out parameter, like QueryInterface. Because the parameter is untyped it is your responsibility to pass a var declared as the interface you're requesting. The compiler will not stop you passing in something that doesn't make sense: var Nonsense: IMomsSpaghetti; begin SHGetPropertyStoreForWindow(Handle, IPropertyStore, Nonsense); Nonsense.Vomit; // Boom! end; What is the actual problem you're experiencing, by the way?
  22. Anders Melander

    UnPinnable App

    I'm not sure I fully understand your explanation. Anyway, now that I think of it you should get rid of both the _AddRef and _Release. The interface being returned by SHGetPropertyStoreForWindow will have a ref count of 1. Your pointer() hard cast ensures that it stays at 1 even though you are storing the reference in a Delphi interface var. When this reference goes out of scope the reference count should become 0. I'm not sure what change you're referencing here. I don't know what the Pascal declaration of SHGetPropertyStoreForWindow looks like but in this case it doesn't really make a difference if ppv is declared as a pointer pointer, an interface or pointer var or out parameter. The semantics are different but the result is the same. I believe the semantics of out best describe what's actually going on here (return of a value with disregard for the current value of the passed var). Look at the declaration (and implementation) of QueryInterface in classes.pas for another way to declare an out parameter returning an arbitrary interface.
  23. Didn't you read the wikipedia link on Backus-Naur format? There are a few online tools that generates railroad diagrams from EBNF (https://www.bottlecaps.de/rr/ui is probably the best known) but I know of none that operate on BNF. I actually don't think the original BNF is much used outside old textbooks.
  24. Anders Melander

    UnPinnable App

    Get rid of the _Release. It's already called implicitly when the interface reference goes out of scope.
  25. Because TThread is a lot older than TTask. TThread is just a semi-thin low level wrapper around a windows thread. TTask has a much higher abstraction level and uses TThread internally (via the thread pool). You have the source code for both so go ahead and have a peek.
×