-
Content Count
1977 -
Joined
-
Last visited
-
Days Won
26
Everything posted by Attila Kovacs
-
@dummzeuch The idea is good, but I'm afraid it's too late. Plugins go first. Have to check.
-
How to pass an unknown record to a function as argument
Attila Kovacs replied to John Kouraklis's topic in RTL and Delphi Object Pascal
@Rudy Velthuis Yup. -
@David Hoyle I was thinking about the same, but, this is a plugin dll for Parnassus Bookmark and I'm not sure that I want to hook it from there... I didn't even look how could I access the main form.
-
@David Hoyle Thx, I was looking everywhere for this notifier! For now I've switched to TOTAFileNotification, and I'm silent between ofnProjectDesktopSave/ofnActiveProjectChanged and the ofnFileClosing with the filename ending with '.dproj'. Yeah, ugly botching, but I have no other choice at the moment...
-
@Stéphane Wierzbicki In Berlin everything ok, except I had to use Right-Clicks (the other left :) insted of Left-Clicks 🙂
-
HTML Library & Fast Report
Attila Kovacs replied to Alexander Sviridenkov's topic in Delphi Third-Party
@Alexander Sviridenkov Cool. I did the same last year with my report generator, html+html report generator in the normal report generator. It's freakin' awesome. -
@David Hoyle I'm also getting this event every time I'm closing a file with ctrl-F4. Berlin U2.
-
@Dave Nottage I want to suppress some editor related dialogs in my plugon on closing the IDE, but I think I've found a way: TOTAFileNotification yields "projectname.$$$" file is going to be closed at first. Not sure what it is, temp file or what, but it seems always to be the first file to close. It's the .groupproj file instead. Also fine I think.
-
How to pass an unknown record to a function as argument
Attila Kovacs replied to John Kouraklis's topic in RTL and Delphi Object Pascal
TRttiContext.Free does already something. It kills the RTTI cache which I'm trying to avoid. But go ahead and create/free it every single time if you wish. -
ANN: Parnassus Bookmarks and Navigator will be included in the next release of RAD Studio
Attila Kovacs replied to Dave Millington (personal)'s topic in Delphi Third-Party
I'm still wondering why the plugin API became so lean. Add/Delete/Some events and a readonly Items. To rename a bookmark I have to delete and add a new one which is triggering a bunch of events, mostly arriving too late for being able to flag the internal processing. I suppose this will never change. You had no time and this won't change with the acquire. Too bad. -
How to pass an unknown record to a function as argument
Attila Kovacs replied to John Kouraklis's topic in RTL and Delphi Object Pascal
Like me. It's "created" once at startup to generate the rtti cache and stored in a global variable and never "created" again or "free"'d. Single threaded app. -
Pitfalls of Anonymous methods and capture
Attila Kovacs replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
On the other side, I'm really happy that I had to download the sources to see what he has, and so I have seen a really great trick and the thread became not just a 42424th variable/value capturing rant. However one thing is still not clear for me Lars, if your actual code takes care of freeing the TFoo and TBar instances, how comes that you instantiate them into a local variable in a loop? -
Pitfalls of Anonymous methods and capture
Attila Kovacs replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
I don't want to hijack this thread but this is such a cool example, there is something I can't understand. I have completed it with the corresponding destructors and free's, and it still leaks. Is this an expected leak? Are TFoo and TBar instances stucked? Edit: Okay, this could be also a deficit of the SCCE. Maybe he is managing them in his actual code. Anyway, the trick using an abstract class to passing its method as an anon proc is really great. -
Pitfalls of Anonymous methods and capture
Attila Kovacs replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
Mhm, So avoid variables and everything should be ok in anon procs? Like that? case hType of foo: //Handler := TFoo.Create; Broker.AddHandler(TFoo.Create.OnHandle); bar: //Handler := TBar.Create; Broker.AddHandler(TBar.Create.OnHandle); end; -
Guessing the decimal separator
Attila Kovacs replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
@Rudy Velthuis I could not tell whether you agree or arguing with me. If he is running GuessDecimalseparator() on strings, and the file contains only "0" 's, it will be still treated as float 0, isn't it? Otherwise he would run GuessIntegerOrFloatOrNoneOfThem() first and then WhatNow(). -
Pitfalls of Anonymous methods and capture
Attila Kovacs replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
Hi Lars, Ahm, where is Anonymous method in yor example? And I'm not sure about that for in over an enum. I'm AFK but I would test it in first place. -
I can't blame you. I have the same problem with GExperts.
-
Can't you just define defaults for those fields in the db?
-
I won't go into a conversation about good practices because I would not do anything anymore without ORM, and you would not rewrite your app from the scratch. But this could help you eventually: var CurrentConnection: TFDConnenction; CurrentConnection := LiveConnection / TestConnenction CurrentConnection.ExecSQL('whatever'); btw, what is FDCExecSQL?
-
Thanks @mael and @M.Joos. This is actually very simple with the RegisterSelectionEditor. Here is the prototype I made, I don't really have any time to make it to a "product" nor to enhance it more. First you will need a simple wizard skeleton like http://www.tempest-sw.com/opentools/simple.html Then merge this code into it. Let me know if anything is missing. TCustomPropeFilter = class(TSelectionEditor, ISelectionpropertyFilter) private // I've no clue who is managing the instance so everything static class var FFilterPane: TPanel; class var FFilterBox: TButtonedEdit; class var FFilterCombo: TComboBox; class var FFilterList: TStringList; class var FPatternList: TStringList; class var FPropertyInspector: TForm; class var FOldPropertyInspectorActivate: TNotifyEvent; class procedure OnFilterComboCloseUp(Sender: TObject); class procedure RefreshSelection; class procedure OnFilterComboKeyPress(Sender: TObject; var Key: Char); class procedure OnPropertyInspectorActivate(Sender: TObject); protected { ISelectionPropertyFilter } procedure FilterProperties(const ASelection: IDesignerSelections; const ASelectionproperties: IInterfaceList); end; constructor TSimpleWizard.Create; begin // how to unregister? RegisterSelectionEditor(TControl, TCustomPropeFilter); TCustomPropeFilter.FPropertyInspector := TForm(Application.FindComponent('PropertyInspector')); if TCustomPropeFilter.FPropertyInspector <> nil then begin TCustomPropeFilter.FOldPropertyInspectorActivate := TCustomPropeFilter.FPropertyInspector.OnActivate; TCustomPropeFilter.FPropertyInspector.OnActivate := TCustomPropeFilter.OnPropertyInspectorActivate; TCustomPropeFilter.FFilterPane := TPanel(TCustomPropeFilter.FPropertyInspector.FindComponent('FilterPane')); if TCustomPropeFilter.FFilterPane <> nil then begin TCustomPropeFilter.FFilterBox := TButtonedEdit(TCustomPropeFilter.FPropertyInspector.FindComponent('FilterBox')); // I don't like the default search box. Do you? if TCustomPropeFilter.FFilterBox <> nil then TCustomPropeFilter.FFilterBox.Visible := False; TCustomPropeFilter.FFilterCombo := TComboBox.Create(TCustomPropeFilter.FFilterPane); TCustomPropeFilter.FFilterCombo.Name := 'FilterCombo'; TCustomPropeFilter.FFilterCombo.Text := ''; TCustomPropeFilter.FFilterCombo.Margins.Left := 0; TCustomPropeFilter.FFilterCombo.Margins.Top := 3; TCustomPropeFilter.FFilterCombo.Margins.Right := 0; TCustomPropeFilter.FFilterCombo.Margins.Bottom := 0; TCustomPropeFilter.FFilterCombo.AlignWithMargins := True; // TCustomPropeFilter.FFilterCombo.Top := 100; // needed only if default search-box is visible TCustomPropeFilter.FFilterCombo.Align := alTop; TCustomPropeFilter.FFilterPane.InsertControl(TCustomPropeFilter.FFilterCombo); TCustomPropeFilter.FFilterCombo.Items.Add('Pos & Size'); TCustomPropeFilter.FFilterCombo.Items.Add('Display'); TCustomPropeFilter.FFilterCombo.Items.Add('Name'); TCustomPropeFilter.FFilterCombo.Items.Add('NewForm'); TCustomPropeFilter.FFilterCombo.OnCloseUp := TCustomPropeFilter.OnFilterComboCloseUp; TCustomPropeFilter.FFilterCombo.OnKeyPress := TCustomPropeFilter.OnFilterComboKeyPress; TCustomPropeFilter.FFilterList := TStringList.Create; TCustomPropeFilter.FPatternList := TStringList.Create; end; end; end; { TCustomPropeFilter } class procedure TCustomPropeFilter.OnFilterComboCloseUp(Sender: TObject); begin RefreshSelection; end; class procedure TCustomPropeFilter.RefreshSelection; var AList: IDesignerSelections; Designer: IDesigner; begin Designer := ActiveRoot as IDesigner; if Designer = nil then Exit; AList := CreateSelectionList; Designer.GetSelections(AList); // If the selection contains only the current form. (No controls) if (AList.Count = 1) and (AList[0] = Designer.Root) then Designer.NoSelection else Designer.ClearSelection; Designer.SetSelections(AList); end; class procedure TCustomPropeFilter.OnFilterComboKeyPress(Sender: TObject; var Key: Char); begin case Key of #13: begin RefreshSelection; Key := #0; end; #27: begin if TCustomPropeFilter.FFilterCombo.Text <> '' then begin TCustomPropeFilter.FFilterCombo.ItemIndex := -1; TCustomPropeFilter.FFilterCombo.Text := ''; RefreshSelection; end; Key := #0; end; end; end; class procedure TCustomPropeFilter.OnPropertyInspectorActivate(Sender: TObject); var CursorPos: TPoint; c: TControl; begin // This is insane but I've no better idea to avoid stealing the focus by Property Editor's OnActivate event GetCursorPos(CursorPos); c := FFilterPane.ControlAtPos(FFilterPane.ScreenToClient(CursorPos), True, True, True); if (c <> nil) and (c.Name = 'FilterCombo') then Exit; if Assigned(FOldPropertyInspectorActivate) then FOldPropertyInspectorActivate(Sender); end; procedure TCustomPropeFilter.FilterProperties(const ASelection: IDesignerSelections; const ASelectionproperties: IInterfaceList); var i, j: Integer; LSelectedItem: TPersistent; LProperty: IProperty; LPropertyName: String; MethodProperty: IMethodProperty; function PatternMatch(AList: TStringList; APropName: String): Boolean; var k: Integer; begin for k := 0 to AList.Count - 1 do if Pos(AList[k], APropName) > 0 then Exit(True); Result := False; end; begin if TCustomPropeFilter.FFilterCombo <> nil then begin // todo load the list from file or registry case TCustomPropeFilter.FFilterCombo.ItemIndex of - 1: begin if TCustomPropeFilter.FFilterCombo.Text <> '' then begin TCustomPropeFilter.FPatternList.Clear; TCustomPropeFilter.FFilterList.Text := StringReplace(TCustomPropeFilter.FFilterCombo.Text, ',', #13#10, [rfReplaceAll]); for i := TCustomPropeFilter.FFilterList.Count - 1 to 0 do if Copy(TCustomPropeFilter.FFilterList[i], 1, 1) = '*' then begin TCustomPropeFilter.FPatternList.Add(Copy(TCustomPropeFilter.FFilterList[i].ToLower, 2)); TCustomPropeFilter.FFilterList.Delete(i); end; end else Exit; end; // everything hardcoded because I'm a lazy dog 0: begin TCustomPropeFilter.FFilterList.Clear; TCustomPropeFilter.FFilterList.Add('Top'); TCustomPropeFilter.FFilterList.Add('Left'); TCustomPropeFilter.FFilterList.Add('Width'); TCustomPropeFilter.FFilterList.Add('Height'); TCustomPropeFilter.FFilterList.Add('ClientWidth'); TCustomPropeFilter.FFilterList.Add('ClientHeight'); TCustomPropeFilter.FFilterList.Add('TabOrder'); TCustomPropeFilter.FFilterList.Add('Align'); TCustomPropeFilter.FFilterList.Add('AlignWithMargins'); TCustomPropeFilter.FFilterList.Add('Margins'); end; 1: begin TCustomPropeFilter.FFilterList.Clear; TCustomPropeFilter.FFilterList.Add('Caption'); TCustomPropeFilter.FFilterList.Add('Text'); TCustomPropeFilter.FFilterList.Add('Datasource'); TCustomPropeFilter.FFilterList.Add('DataField'); end; 2: begin TCustomPropeFilter.FFilterList.Text := 'Name'; end; 3: begin TCustomPropeFilter.FFilterList.Clear; TCustomPropeFilter.FFilterList.Add('ActiveControl'); TCustomPropeFilter.FFilterList.Add('BorderIcons'); TCustomPropeFilter.FFilterList.Add('BorderStyle'); TCustomPropeFilter.FFilterList.Add('Caption'); TCustomPropeFilter.FFilterList.Add('ClientHeight'); TCustomPropeFilter.FFilterList.Add('ClientWidth'); TCustomPropeFilter.FFilterList.Add('Font'); TCustomPropeFilter.FFilterList.Add('Name'); TCustomPropeFilter.FFilterList.Add('Position'); end; end; // todo implement pattern search like in the original IDE search box for i := 0 to ASelection.Count - 1 do begin LSelectedItem := ASelection[i]; if (LSelectedItem is TControl) then for j := ASelectionproperties.Count - 1 downto 0 do begin if Supports(ASelectionproperties[j], IProperty, LProperty) then if not Supports(ASelectionproperties[j], IMethodProperty, MethodProperty) then begin LPropertyName := LProperty.GetName; if (TCustomPropeFilter.FFilterList.IndexOf(LPropertyName) = -1) and // (not PatternMatch(TCustomPropeFilter.FPatternList, LPropertyName.ToLower)) then ASelectionproperties.Delete(j); end; end; end; end; end;
-
How to "eat" the second OnMouseDown / OnMouseUp events after a DblClick?
Attila Kovacs replied to Steve Maughan's topic in VCL
We just had a similar discussion the other day. Take a look at my solution (on the bottom of the thread) and try to adopt it. Use it only on the form you really need it, but if you are going to show a modal form from the dobule-click handler there is no guarantee that the following messages are captured by your map's form but by the newly created/shown modal form. You can also try to just to call ReleaseCapture before showing the modal window. -
Guessing the decimal separator
Attila Kovacs replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
Why would you search decimal separator on integers? What formula do you think would be feasible to tell what 1.000 is? Check the first X rows, if still not obvious check another X, if still not and EOF, panic. -
Guessing the decimal separator
Attila Kovacs replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
the first one from the right -
function x(const input: string; var output: string): boolean; How to defuse? Omit const? Performance penalty.
-
Object destroyed too soon?
Attila Kovacs replied to Primož Gabrijelčič's topic in RTL and Delphi Object Pascal
@Primož Gabrijelčič Yes, this was the original problem which I've used to solved with the wrapper. Rather more code/resource than record pointers. I like to sleep well.