Article View: pl.comp.lang.delphi
Article #346769Delphi 10.2 - DBGrid brak reakcji na prawy klawisz myszy jeśli są rekordy
From: kameleonsql
Date: Fri, 05 Oct 2018 13:42
Date: Fri, 05 Oct 2018 13:42
112 lines
4808 bytes
4808 bytes
Witam,
Skończyłem właśnie migrować te parę milionów linii kodu z Delphi 2010 do
10.2. Generalnie przez tydzień to się dało zrobić, (trochę komponentów innych firm, swoich i niespodzianek typu GotoBookmark(TArray<Byte>(pointer(DBGridView.SelectedRows.Items[i]) i zabawy z Unitami, ale kod jest już przeniesiony i działa).
Być może jestem już zmęczony, ale pozostała jeszcze jedna zagwozdka (pamiętam ten problem chyba w D7 był, ale w D2010 to działało dobrze). Potrzebuje zdarzenie OnMouseDown i detekcję prawego klawisza myszy w DBGrid, działa tylko jeśli mysz zostanie użyta na obszarze DBGrid bez rekordów. Ktoś to już przerabiał ?
Pozdrawiam
---
Roman
Ps.
Znalazłem coś takiego (wykopalisko z 2002), ale chyba nie muszę ruszać źródeł w 10.2 ?
procedure TCustomDBGrid.MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
var
Cell: TGridCoord;
OldCol,OldRow: Integer;
MasterCol: TColumn;
begin
if not AcquireFocus then Exit;
if (ssDouble in Shift) and (Button = mbLeft) then
begin
DblClick;
Exit;
end;
if Sizing(X, Y) then
begin
FDatalink.UpdateData;
inherited MouseDown(Button, Shift, X, Y);
Exit;
end;
Cell := MouseCoord(X, Y);
if (Cell.X < 0) and (Cell.Y < 0) then
begin
inherited MouseDown(Button, Shift, X, Y);
Exit;
end;
if (DragKind = dkDock) and (Cell.X < FIndicatorOffset) and
(Cell.Y < FTitleOffset) and (not (csDesigning in ComponentState)) then
begin
BeginDrag(false);
Exit;
end;
if PtInExpandButton(X,Y, MasterCol) then
begin
MasterCol.Expanded := not MasterCol.Expanded;
ReleaseCapture;
UpdateDesigner;
Exit;
end;
if ((csDesigning in ComponentState) or (dgColumnResize in Options)) and
(Cell.Y < FTitleOffset) then
begin
FDataLink.UpdateData;
inherited MouseDown(Button, Shift, X, Y);
Exit;
end;
if FDatalink.Active then
with Cell do
begin
BeginUpdate; { eliminates highlight flicker when selection moves }
try
FDatalink.UpdateData; // validate before moving
HideEditor;
OldCol := Col;
OldRow := Row;
if (Y >= FTitleOffset) and (Y - Row <> 0) then
FDatalink.MoveBy(Y - Row);
if X >= FIndicatorOffset then
MoveCol(X, 0);
if (Button = mbLeft) and (dgMultiSelect in Options) and
FDatalink.Active then
with FBookmarks do
begin
FSelecting := False;
if ssCtrl in Shift then
CurrentRowSelected := not CurrentRowSelected
else
begin
Clear;
CurrentRowSelected := True;
end;
end;
if (Button = mbLeft) and
(((X = OldCol) and (Y = OldRow)) or (dgAlwaysShowEditor in Options))
then
begin // Added by K.S.
ShowEditor; { put grid in edit mode }
if CanEditShow then Exit; // The condition added now by K.S.
end // Added by K.S.
else
InvalidateEditor; { draw editor, if needed }
finally
EndUpdate;
end;
end;
if Assigned(OnMouseDown) then // Added by K.S.
OnMouseDown(Self, Button, Shift, X, Y); // Added by K.S.
end;
Compile this unit and place the newly created DBGrids.dcu(which should be
again in the Source\Vcl directory) in the Delphi 6\Lib directory. Now open
your project and rebuild it and it should work if you have done all that
right.
The original code is by Krzysztof Szyszka.
Technical Details
Message-ID:
<6e524648-29f0-4af2-bdbe-9fd914a30fa3@googlegroups.com>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!wsisiz.edu.pl!goblin3!goblin1!goblin.stu.neva.ru!z5-v6no67454ite.0!news-out.google.com!l70-v6ni73itb.0!nntp.google.com!x98-v6no68423ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Received: by 2002:a24:ee43:: with SMTP id b64-v6mr12225138iti.3.1538746963800; Fri, 05 Oct 2018 06:42:43 -0700 (PDT) X-Received: by 2002:aca:ab8b:: with SMTP id u133-v6mr202903oie.6.1538746963581; Fri, 05 Oct 2018 06:42:43 -0700 (PDT) Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!wsisiz.edu.pl!goblin3!goblin1!goblin.stu.neva.ru!z5-v6no67454ite.0!news-out.google.com!l70-v6ni73itb.0!nntp.google.com!x98-v6no68423ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: pl.comp.lang.delphi Date: Fri, 5 Oct 2018 06:42:43 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=91.234.102.48; posting-account=lJNmiQoAAAAcuwZEAibFvFBE7IgRs9bN NNTP-Posting-Host: 91.234.102.48 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <6e524648-29f0-4af2-bdbe-9fd914a30fa3@googlegroups.com> Subject: Delphi 10.2 - DBGrid brak reakcji na prawy klawisz myszy jeśli są rekordy From: kameleonsql@gmail.com Injection-Date: Fri, 05 Oct 2018 13:42:43 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit