152 |
|
FLastMouseButton: TMouseButton; |
153 |
|
FLastMouseShiftState: TShiftState; |
154 |
|
|
155 |
+ |
function ActiveControl: TControl; |
156 |
|
procedure EmptyGrid; |
157 |
|
function GetDataSource: TDataSource; |
158 |
|
function GetRecordCount: Integer; |
413 |
|
procedure TRowCache.ClearCache; |
414 |
|
begin |
415 |
|
FreeImages(true); |
416 |
+ |
SetLength(FList,0); |
417 |
|
end; |
418 |
|
|
419 |
|
function TRowCache.Add2Cache(RecNo: Longint; Control: TWinControl): TBitmap; |
524 |
|
|
525 |
|
{ TDBControlGrid } |
526 |
|
|
527 |
+ |
function TDBControlGrid.ActiveControl: TControl; |
528 |
+ |
var AParent: TWinControl; |
529 |
+ |
begin |
530 |
+ |
Result := nil; |
531 |
+ |
AParent := Parent; |
532 |
+ |
while (AParent <> nil) and not (AParent is TCustomForm) do |
533 |
+ |
AParent := AParent.Parent; |
534 |
+ |
if (AParent <> nil) and (AParent is TCustomForm)then |
535 |
+ |
Result := TCustomForm(AParent).ActiveControl; |
536 |
+ |
end; |
537 |
+ |
|
538 |
|
procedure TDBControlGrid.EmptyGrid; |
539 |
|
var |
540 |
|
OldFixedRows: Integer; |
541 |
|
begin |
542 |
|
OldFixedRows := FixedRows; |
543 |
|
Clear; |
544 |
+ |
FRowCache.ClearCache; |
545 |
|
RowCount := OldFixedRows + 1; |
546 |
|
if dgpIndicator in FOptions then |
547 |
|
ColWidths[0]:=12; |
622 |
|
aRow := integer(Data); |
623 |
|
FInCacheRefresh := true; |
624 |
|
if assigned(FDataLink.DataSet) then |
625 |
< |
FDatalink.DataSet.MoveBy(aRow - FDrawRow) |
625 |
> |
FDatalink.DataSet.MoveBy(aRow - FDrawRow); |
626 |
|
end; |
627 |
|
|
628 |
|
procedure TDBControlGrid.DoSetupDrawPanel(Data: PtrInt); |
658 |
|
procedure TDBControlGrid.KeyDownHandler(Sender: TObject; var Key: Word; |
659 |
|
Shift: TShiftState); |
660 |
|
var Done: boolean; |
661 |
+ |
AControl: TControl; |
662 |
|
begin |
663 |
|
if Visible and assigned(FDrawPanel) and FDrawPanel.Visible and FWeHaveFocus then |
664 |
|
begin |
665 |
+ |
AControl := ActiveControl; |
666 |
+ |
if (AControl <> nil) and (AControl is TCustomComboBox) |
667 |
+ |
and ((Key in [VK_UP,VK_DOWN]) or |
668 |
+ |
(TCustomComboBox(AControl).DroppedDown and (Key = VK_RETURN)) or |
669 |
+ |
((TCustomComboBox(AControl).Text <> '') and (Key = VK_ESCAPE))) then |
670 |
+ |
Exit; {ignore these keys if we are in a combobox} |
671 |
+ |
|
672 |
+ |
if (AControl <> nil) and (AControl is TCustomMemo) |
673 |
+ |
and (Key in [VK_RETURN,VK_UP,VK_DOWN]) then Exit; {Ignore Return in a CustomMemo} |
674 |
+ |
|
675 |
|
Done := false; |
676 |
|
if assigned(FOnKeyDownHander) then |
677 |
|
OnKeyDownHander(Sender,Key,Shift,Done); |
702 |
|
|
703 |
|
procedure TDBControlGrid.OnDataSetChanged(aDataSet: TDataSet); |
704 |
|
begin |
705 |
< |
if (aDataSet.State = dsBrowse) and (FLastRecordCount > GetRecordCount) then |
705 |
> |
if aDataSet.State = dsBrowse then |
706 |
|
begin |
707 |
< |
{must be delete} |
708 |
< |
FRowCache.MarkAsDeleted(FSelectedRecNo); |
709 |
< |
Dec(FSelectedRow); |
707 |
> |
if GetRecordCount = 0 then |
708 |
> |
begin |
709 |
> |
{Must be closed/reopened} |
710 |
> |
FRowCache.ClearCache; |
711 |
> |
FSelectedRow := 0; |
712 |
> |
end |
713 |
> |
else |
714 |
> |
if FLastRecordCount > GetRecordCount then |
715 |
> |
begin |
716 |
> |
{must be delete} |
717 |
> |
FRowCache.MarkAsDeleted(FSelectedRecNo); |
718 |
> |
Dec(FSelectedRow); |
719 |
> |
end; |
720 |
|
LayoutChanged; |
721 |
|
end; |
722 |
|
FLastRecordCount := GetRecordCount; |
1421 |
|
FInCacheRefresh := false; |
1422 |
|
FCacheRefreshQueued := false; |
1423 |
|
Row := FixedRows; |
1424 |
+ |
FDrawingActiveRecord := false; |
1425 |
+ |
FSelectedRecNo := 0; |
1426 |
+ |
FSelectedRow := 0; |
1427 |
+ |
FRequiredRecNo := 0; |
1428 |
|
end; |
1429 |
|
FRowCache.UseAlternateColors := AlternateColor <> Color; |
1430 |
|
FRowCache.AltColorStartNormal := AltColorStartNormal; |