Jump to content

Anders Melander

Members
  • Content Count

    2561
  • Joined

  • Last visited

  • Days Won

    133

Everything posted by Anders Melander

  1. Anders Melander

    how to respond on user drag of a column border in a listview

    The column headers of a listview is in fact a separate header control owned by the listview. The column resize notifications are only sent to the parent of the header control (i.e. the listview) so in order to get at them you need to hook into the WndProc of the listview and catch the HDN_BEGINTRACK and HDN_ENDTRACK messages. I'm guessing @Remy Lebeau has some code..?
  2. Anders Melander

    Create an animated gif from a set of bitmaps?

    Ah yes, TGraphic is a VCL class. I forgot that. I don't use FMX either and I knew FMX couldn't use TGIFImage for display (since that requires TPicture/TImage) but I would have thought one could still use the non-visual stuff such as load/save and GIF manipulation. I guess not.
  3. Anders Melander

    Create an animated gif from a set of bitmaps?

    Try this: procedure MakeGIF(Bitmap1, Bitmap2, Bitmap3: TBitmap); var GIF: TGIFImage; Frame: TGIFFrame; GCExt: TGIFGraphicControlExtension; LoopExt: TGIFAppExtNSLoop; begin GIF := TGIFImage.Create; try Frame := GIF.Add(Bitmap1); // Netscape Loop extension must be the first extension in the first frame! LoopExt := TGIFAppExtNSLoop.Create(Frame); LoopExt.Loops := 0; // Number of loops (0 = forever) // Add Graphic Control Extension GCExt := TGIFGraphicControlExtension.Create(Frame); GCExt.Delay := 30; // Animation delay (30 = 300 mS) Frame := GIF.Add(Bitmap2); GCExt := TGIFGraphicControlExtension.Create(Frame); GCExt.Delay := 30; Frame := GIF.Add(Bitmap3); GCExt := TGIFGraphicControlExtension.Create(Frame); GCExt.Delay := 30; GIF.OptimizeColorMap; GIF.Optimize([ooMerge, ooCrop], rmNone, dmNearest, 0); GIF.SaveToFile('foobar.gif'); finally GIF.Free; end; end; This is just from (my) memory so I'm not sure if it compiles. It's been a while since I wrote that thing. You should be able to find plenty of examples if you search for TGIFImage.
  4. Anders Melander

    Create an animated gif from a set of bitmaps?

    Doesn't TGIFImage (the non-visual part) work with FireMonkey?
  5. Anders Melander

    List of most popular UI components for VCL

    Makes sense then. The learning curve is ...um... spectacular 🙂
  6. Anders Melander

    List of most popular UI components for VCL

    So what do you use for grids, pivots, toolbars, etc?
  7. Yes. Unless you have a reason to specify an explicit owner, you should actually specify nil to make it clear (when reading the code) that there is no owner. No. You can specify that a "child form" should be centered on the owner form (Position=poOwnerFormCenter), but it's still safe to specify nil as the owner. You're mistaken. There must have been something else going on. It's the same for all classes derived from TComponent; When a component is free'd it will free all the components it owns. TComponent is a base class of TForm.
  8. Anders Melander

    Paste file from clipboard to blob field (Remote Desktop)

    This should get you started: https://github.com/landrix/The-Drag-and-Drop-Component-Suite-for-Delphi/tree/master/Demos/VirtualFileStream
  9. IMO that's a bug since the two interfaces are distinct. I don't have time to investigate if the problem exists in newer versions right now.
  10. Yes, exactly. I just wanted to be sure that you were aware of this. Many people misunderstand what interface inheritance is. I still can't follow your example but from your description it does sound like there's a bug. Since you're not doing any hard type casts the compiler should see the problem (whatever it is) and not produce code that leads to an AV.
  11. I can't really follow your example but I noticed that you haven't assigned IFooBroker a GUID. Is that by design? Also, are you aware that inheriting one interface from another is just a convenience that copies the declaration from the base interface into the derived interface. There's no "interface polymorphism".
  12. Anders Melander

    Delphi 11, migrate or wait

    You do know that you don't speak for everyone, right?
  13. IMO you're bound to get into trouble with that design - it's very fragile. Firstly you're mixing object and interface references. If you stuck with interfaces, dropped [weak] and used some other mechanism to flag that the object was no longer valid (e.g. a lock protected flag on the object), then it would be fine. Secondly since you're using [weak] there are limits on what you can safely do with the interface reference. For example supports/queryinterface can't be used on it.
  14. Anders Melander

    UsesCleaner Issue...

    How would the pre-commit hook distinguish my manual changes from the automatic changes made by the IDE?
  15. Anders Melander

    UsesCleaner Issue...

    If you create the graph in code instead of placing it on the form then the IDE will not try to add those units to the uses list.
  16. Anders Melander

    UsesCleaner Issue...

    It would be stellar if we had a switch that could disable this behavior completely. I'm sick and tired of cleaning up the uses clause before commit, every time I have had a form open in the IDE during debug. Particularly since DevExpress keeps adding stupid dependencies between their units which causes the uses list to grow and grow for no good reason.
  17. Anders Melander

    Datamodule with ImageCollection of PNGs loading with packages

    That's not how you use coInitialize/coUninitialize. First of all check the return value of coInitialize and don't call coUnititialize unless the return status indicated that it succeeded. Read the documentation. And don't call coUninitialize until you are sure that everything using the thread apartment is done with it. Since you're doing this in the main thread and you don't know what else is using it you are best of doing it just before the final end. Normally this is something that would be done in the initialization and finalization sections of a unit. Finally, use coInitializeEx instead.
  18. Anders Melander

    DUnitX: How can I load HTML files within unit test?

    If the logic that does the HTTP request, extract the HTML and scrapes the HTML are all nicely separated then I don't see why you'd need a mock (personally I try to avoid them as they just become one more piece of code to maintain). For example if your scraper reads from a stream, then just have the unit test pass it a TFileStream and Bob's your uncle/aunt/non-binary auncle.
  19. Anders Melander

    UsesCleaner Issue...

    Or if earlier versions are to be supported: $IFDEF CONDITIONALEXPRESSIONS} {$IF CompilerVersion >= 14.0} Variants, {$IFEND} {$ENDIF} If not, then Variants might just as well be moved outside the conditional.
  20. Anders Melander

    Interesting way to copy dynamic arrays.

    It's in the documentation... So probably not 🙂
  21. Anders Melander

    Interesting way to copy dynamic arrays.

    There's DynArrayUnique but it's undocumented and not really fit for direct use: procedure DynArrayUnique(var A: Pointer; typeInfo: Pointer); begin if (A <> nil) and (PDynArrayRec(PByte(A) - SizeOf(TDynArrayRec))^.RefCnt > 1) then DynArrayCopy(A, A, typeInfo); end;
  22. Anders Melander

    Interesting way to copy dynamic arrays.

    A simple "yes" would have been enough 🙂
  23. Anders Melander

    Interesting way to copy dynamic arrays.

    Read what I wrote again.
  24. Anders Melander

    Interesting way to copy dynamic arrays.

    I still don't get it. Just start with the assignment and use B:= Copy(B) when you need it to be unique.... Ah, I think I get it now. You don't want to keep track of the arrays reference count. So it's like UniqueString for dynamic arrays? Does nothing if the reference count is already 1, otherwise makes a unique copy. Right?
×