-
Content Count
2561 -
Joined
-
Last visited
-
Days Won
133
Everything posted by Anders Melander
-
TFDTable should be able to do all this on its own. You don't need a separate memory dataset. See TFDDataSet.Offline
-
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.
-
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.
-
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.
-
I knew it! https://www.imdb.com/video/vi2049426201
-
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.
-
DPI Awareness, tForm.CurrentPPI and PixelsPerInch not always identical !!???
Anders Melander replied to A.M. Hoornweg's topic in VCL
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?... 🤔 -
What? No comment on the pointless use of FreeAndNil? Ah. There it was 🙂 which ironically is preceded by this statement: Color me insecure then.
-
DPI Awareness, tForm.CurrentPPI and PixelsPerInch not always identical !!???
Anders Melander replied to A.M. Hoornweg's topic in VCL
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. -
Debugging Issues in D11 64Bit with Packages
Anders Melander replied to MathewV's topic in Delphi IDE and APIs
This applies even to 32-bit DLLs/packages in my experience. -
More efficient string handling
Anders Melander replied to parallax's topic in Algorithms, Data Structures and Class Design
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. -
More efficient string handling
Anders Melander replied to parallax's topic in Algorithms, Data Structures and Class Design
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. -
More efficient string handling
Anders Melander replied to parallax's topic in Algorithms, Data Structures and Class Design
What? There's a manual? 😉 -
DPI Awareness, tForm.CurrentPPI and PixelsPerInch not always identical !!???
Anders Melander replied to A.M. Hoornweg's topic in VCL
Nice catch! 👌 -
More efficient string handling
Anders Melander replied to parallax's topic in Algorithms, Data Structures and Class Design
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. -
More efficient string handling
Anders Melander replied to parallax's topic in Algorithms, Data Structures and Class Design
No need for that. Just run it in a profiler and you will know exactly which statements you should concentrate your efforts on. -
Project to create a language definition in BNF format started
Anders Melander replied to TurboMagic's topic in RTL and Delphi Object Pascal
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? -
Project to create a language definition in BNF format started
Anders Melander replied to TurboMagic's topic in RTL and Delphi Object Pascal
Exactly - and you don't need to be an expert to come to that conclusion. -
Project to create a language definition in BNF format started
Anders Melander replied to TurboMagic's topic in RTL and Delphi Object Pascal
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 -
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.
-
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?
-
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.
-
Project to create a language definition in BNF format started
Anders Melander replied to TurboMagic's topic in RTL and Delphi Object Pascal
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. -
Get rid of the _Release. It's already called implicitly when the interface reference goes out of scope.
-
TThread instances to run on separate CPU cores.
Anders Melander replied to DavidJr.'s topic in RTL and Delphi Object Pascal
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.