Jump to content

Attila Kovacs

Members
  • Content Count

    1977
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by Attila Kovacs

  1. Attila Kovacs

    Object destroyed too soon?

    @Primož Gabrijelčič Nice. I like that the wrapper/forwarder is now a common thing, even if this solution has the same amount of copyrecords plus some IF handling.
  2. Attila Kovacs

    Object destroyed too soon?

    @Primož Gabrijelčič Yup. Still, let me know if you find an other way, I'm also interested. Especially if you can avoid the extra copyrecord's and still have the original syntax.
  3. Attila Kovacs

    Object destroyed too soon?

    Of course. Question is, how do you like it and how does it interfere with the existing lib. I've no clue of this lib, but this should give you some ideas wrapping the record into something. TWorkItem = class; TOmniValue = record private FOwner: TWorkItem; // <------- FOwnedObject: IAutoDestroyObject; function GetAsOwnedObject: TObject; procedure SetAsOwnedObject(const Value: TObject); public property AsOwnedObject: TObject read GetAsOwnedObject write SetAsOwnedObject; end; TWorkItem = class(TInterfacedObject, IWorkItem) strict private FResult: TOmniValue; strict protected function GetResult: TOmniValue; protected // <------------ procedure SetResult(const Value: TOmniValue); public destructor Destroy; override; property Result: TOmniValue read GetResult write SetResult; end; function TWorkItem.GetResult: TOmniValue; begin Result := FResult; Result.FOwner := Self; // <------------ end; procedure TOmniValue.SetAsOwnedObject(const Value: TObject); begin FOwnedObject := TAutoDestroyObject.Create(Value); FOwner.SetResult(Self); // <------------------- end;
  4. Attila Kovacs

    Object destroyed too soon?

    I'd say thats why: property Result: TOmniValue read GetResult write SetResult; A Record property.
  5. Attila Kovacs

    Caching with class variables

    @Kryvich Would be an improvement yes, but still too few bits.
  6. Attila Kovacs

    Caching with class variables

    Actually at 32 will already fail, because he uses integer instead of cardinal. But indeed, an "if typeData.MaxValue > 30 then raise.." would make this approach safer.
  7. Attila Kovacs

    Caching with class variables

    I've lost the thread after this line "As it turns out, we can fix both problems simply by using class variables, properties, and methods functionality of the Delphi language:" The same code follows as already above the paragraph was., instead of the declaration of "TypeInfoCache" I think.
  8. @Schokohase I see. Yes its windows. I don't know why does it fire MouseUp after DblClick... Your version could be also strange if someone does not releases the button after the second click. I'd still go with something like this, if there are no other side effects: (Well, actually a modal window overtakes the message loop, so no effect beyond modal forms.) var WasDblClick: boolean; procedure TForm1.MyOnMessage(var Msg: TMsg; var Handled: boolean); begin case Msg.Message of WM_LBUTTONDBLCLK: WasDblClick := True; WM_LBUTTONUP: if WasDblClick then begin // v0.2 Msg.Message := WM_CANCELMODE; WasDblClick := False; { // v0.1 PostMessage(Msg.hwnd, WM_CANCELMODE, 0, 0); WasDblClick := False; Handled := True; } end; end; end; procedure TForm1.FormCreate(Sender: TObject); begin Application.OnMessage := MyOnMessage; end;
  9. ..with a js script. Then, the whole html contains 7 lines. One of them right now is 1 million 173 thousand 457 characters long. Must be a dream for the browser to parse it.
  10. There is no actual problem, I just wanted to contribute to a better user experience 🙂 It's indeed can be a bit slow if I'm loading more than 1 page of activity and there are huge comments in it. With just 3-4 clicks this one html line grows to 2-3MB.
  11. @Luiz Felipe Heemann As @Dany Marmur said, create a custom message and handler: const CM_OPEN_FORM2 = WM_APP + 1337; TForm1 = class(TForm) . private procedure CM_OPEN_FORM2_HANDLER(var Message: TMessage); message CM_OPEN_FORM2; .. procedure TForm1.CM_OPEN_FORM2_HANDLER(var Message: TMessage); begin TForm2.Create(Self).ShowModal; end; procedure TForm1.Panel1DblClick(Sender: TObject); begin Postmessage(Self.Handle, CM_OPEN_FORM2, 0,0); end;
  12. Attila Kovacs

    How to create common CreateForm method?

    I prefer caFree action in onClose so I don't have to deal with references at all and doesn't really care if it's shown modal or not. Of course this means the forms are always (re)-created.
  13. Attila Kovacs

    Abnormal file size..

    Analyze your executable. It could have more debug info, more rtti, more resources, more anything.. different linking options, compiler directives, who knows, we can't see those apps.
  14. Attila Kovacs

    Abnormal file size..

    Why is it important if it's a debug build? Debug information is big, which is linked to the executable.
  15. Attila Kovacs

    Single Instance of Dephi IDE?

    Not that you couldn't write an own launcher.....
  16. Attila Kovacs

    Issues with Fontscaling for HDPI in Delphi Berlin

    Ah, I see. Never encounter problems on parenting a form, but for sure, HDPI is still very buggy so I'm not wondering. Just go with your workaround. 😞
  17. Attila Kovacs

    Issues with Fontscaling for HDPI in Delphi Berlin

    Runtime created forms/frames (without dfm template) are not scaling in Berlin. Fixed somewhere in Tokyo/Rio.
  18. What is the simplest way to make the compiler/linker include a class and its RTTI into the executable when I have no references to the class in the code? ATM I have an "if" with a variable in the expression which always evaluates to false and in the begin-end block a "TxyClass.Create;". I don't really like this solution.
  19. Attila Kovacs

    TFDParam.Size - best practice?

    I would try this: Make the varchar(max) parameter to a type of ftMemo and load it from a stringstream: ss := TStringStream.Create(log); p.LoadFromStream(ss, ftMemo);
  20. Attila Kovacs

    Maintaining For loop(s)

    I would serialize the whole filtering, one by one, always returning with the matches and do the next filter (for loop) on the result. (If not already empty).
  21. Attila Kovacs

    FileExists(xxxxx) in a network?

    @Ian Branch Are you holding some infos back? How is a colon in your UNC path? Linux server? Does samba supports colon in UNC?
  22. Attila Kovacs

    Include unused class and its RTTI in the executable

    @Fritzew Good point, thank you. ClassInfo not, but for example ClassParent does the trick. This one is the simplest for now. And ClassParent() is also very tiny.
  23. Attila Kovacs

    Include unused class and its RTTI in the executable

    I've found {$STRONGLINKTYPES ON} and this: https://code.i-harness.com/en/q/281b33c Still curious if anyone has a different solution.
  24. Paramw := (DPI shl 16) + DPI; Form.Perform(WM_DPICHANGED, Paramw, @NewRect); Calculate the new pos and size for the window into NewRect. I've bound this to ctrl-mousewheel like browsers/excel zoom, with limited DPI possibilities (to still fit the form into the display). Step is 24 DPI. Works fine.
  25. Attila Kovacs

    IDE Fix pack for Rio

    You can still donate.
×