1
TDBGrid에서 레코드를 두 번 클릭했지만 눈금에서 클릭 한 위치에 관계없이 OnDblClick 이벤트가 발생하는 경우를 알고 싶습니다.TDBGrid의 제목에 두 번 클릭했는지 확인합니다.
델파이에서는 TDBGrid 더블 클릭이 제목에 있었는지를 결정하는 좋은 방법이 있습니까?
TDBGrid에서 레코드를 두 번 클릭했지만 눈금에서 클릭 한 위치에 관계없이 OnDblClick 이벤트가 발생하는 경우를 알고 싶습니다.TDBGrid의 제목에 두 번 클릭했는지 확인합니다.
델파이에서는 TDBGrid 더블 클릭이 제목에 있었는지를 결정하는 좋은 방법이 있습니까?
이것은 단지 위치가 제목과 일치하는 경우 계산, 나는 그것을 할 방법은 다음과 같습니다
function GridClickIsOnTitle(Grid: TDbGrid): Boolean;
var
Pt: TPoint;
begin
Pt := Grid.ScreenToClient(SmallPointToPoint(types.SmallPoint(GetMessagePos)));
Result := (Grid.MouseCoord(Pt.X, Pt.Y).Y = 0) and (dgTitles in Grid.Options);
end;
나는 OnDblClick
핸들러에서 호출.
// in the class declaration
type
THackDBGrid=Class(TDBGrid);
// function to check if click is on the title
function isClickOnTitle(const dbGrid: TDbGrid; const rowTitleHeight : integer): Boolean;
var
mousePoint : TPoint;
mouseInGrid : TPoint;
begin
mousePoint := Mouse.CursorPos;
mouseInGrid := dbGrid.ScreenToClient(mousePoint);
result := mouseInGrid.Y <= rowTitleHeight;
end;
// grid double click event
procedure TForm.dbGridDblClick(Sender: TObject);
var
rowTitleHeight : integer;
begin
inherited;
// trick to get the title row height
rowTitleHeight := THackDBGrid(gdTestGrid).RowHeights[0];
if not isClickOnTitle(gdTestGrid, rowTitleHeight) then begin
bbOk.click;
end;
end;