-
Content Count
1977 -
Joined
-
Last visited
-
Days Won
26
Everything posted by Attila Kovacs
-
Object destroyed too soon?
Attila Kovacs replied to Primož Gabrijelčič's topic in RTL and Delphi Object Pascal
@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. -
Object destroyed too soon?
Attila Kovacs replied to Primož Gabrijelčič's topic in RTL and Delphi Object Pascal
@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. -
Object destroyed too soon?
Attila Kovacs replied to Primož Gabrijelčič's topic in RTL and Delphi Object Pascal
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; -
Object destroyed too soon?
Attila Kovacs replied to Primož Gabrijelčič's topic in RTL and Delphi Object Pascal
I'd say thats why: property Result: TOmniValue read GetResult write SetResult; A Record property. -
Caching with class variables
Attila Kovacs replied to Primož Gabrijelčič's topic in Tips / Blogs / Tutorials / Videos
@Kryvich Would be an improvement yes, but still too few bits. -
Caching with class variables
Attila Kovacs replied to Primož Gabrijelčič's topic in Tips / Blogs / Tutorials / Videos
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. -
Caching with class variables
Attila Kovacs replied to Primož Gabrijelčič's topic in Tips / Blogs / Tutorials / Videos
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. -
When I perform the OnDblClick event (Form1) to open Form2, it fires the OnCellClick event of Form2, without having clicked on the form2 grid
Attila Kovacs replied to Luiz Felipe Heemann's topic in VCL
@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; -
Activity feed loads the whole posts, then it truncates them..
Attila Kovacs posted a topic in Community Management
..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. -
Activity feed loads the whole posts, then it truncates them..
Attila Kovacs replied to Attila Kovacs's topic in Community Management
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. -
When I perform the OnDblClick event (Form1) to open Form2, it fires the OnCellClick event of Form2, without having clicked on the form2 grid
Attila Kovacs replied to Luiz Felipe Heemann's topic in VCL
@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; -
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.
-
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.
-
Why is it important if it's a debug build? Debug information is big, which is linked to the executable.
-
Not that you couldn't write an own launcher.....
-
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. 😞
-
Runtime created forms/frames (without dfm template) are not scaling in Berlin. Fixed somewhere in Tokyo/Rio.
-
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.
-
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);
-
Maintaining For loop(s)
Attila Kovacs replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
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). -
@Ian Branch Are you holding some infos back? How is a colon in your UNC path? Linux server? Does samba supports colon in UNC?
-
Include unused class and its RTTI in the executable
Attila Kovacs replied to Attila Kovacs's topic in General Help
@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. -
Include unused class and its RTTI in the executable
Attila Kovacs replied to Attila Kovacs's topic in General Help
I've found {$STRONGLINKTYPES ON} and this: https://code.i-harness.com/en/q/281b33c Still curious if anyone has a different solution. -
Proportional scaling of fonts and components when a forms size is changed?
Attila Kovacs replied to Ian Branch's topic in General Help
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.- 5 replies
-
- delphi
- proportional
-
(and 1 more)
Tagged with:
-
You can still donate.