Ignore:
Timestamp:
Feb 11, 2022, 11:31:42 AM (3 years ago)
Author:
chronos
Message:
  • Fixed: Do not update interface in contact properties if the listview doesn't have handle yet.
  • Added: Synced update of full name and name parts in contact form.
  • Modified: Improved image loading code by image format.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormProperties.pas

    r104 r108  
    6565  private
    6666    FProperties: TContactProperties;
     67    FUpdateCount: Integer;
    6768    procedure FilterList(List: TFPGObjectList<TObject>);
    6869    procedure SetProperties(AValue: TContactProperties);
     70    procedure DoUpdateInterface;
    6971  public
    7072    property Properties: TContactProperties read FProperties write SetProperties;
    7173    procedure ReloadList;
     74    procedure BeginUpdate;
     75    procedure EndUpdate;
    7276    procedure UpdateInterface;
    7377  end;
     
    9397  STextFiles = 'Text files';
    9498  SValue = 'Value';
     99  SEndUpdateTooLow = 'Update counter error';
    95100
    96101const
     
    365370end;
    366371
    367 procedure TFormProperties.UpdateInterface;
     372procedure TFormProperties.BeginUpdate;
     373begin
     374  Inc(FUpdateCount);
     375end;
     376
     377procedure TFormProperties.EndUpdate;
     378begin
     379  if FUpdateCount <= 0 then raise Exception(SEndUpdateTooLow);
     380  Dec(FUpdateCount);
     381  if FUpdateCount = 0 then DoUpdateInterface;
     382end;
     383
     384procedure TFormProperties.DoUpdateInterface;
    368385var
    369386  Text: string;
     
    371388  Selected: Boolean;
    372389begin
     390  if not ListView1.HandleAllocated then Exit;
     391
    373392  Selected := Assigned(ListView1.Selected);
    374393  AAdd.Enabled := Assigned(Properties);
     
    392411end;
    393412
     413procedure TFormProperties.UpdateInterface;
     414begin
     415  if FUpdateCount = 0 then DoUpdateInterface;
     416end;
     417
    394418end.
    395419
Note: See TracChangeset for help on using the changeset viewer.