Board index » delphi » TRect?

TRect?

In delphi 2.0:

I have a DrawGrid1 with 8 Cols, 1 row (no fixed)

|-----------------------------------------------|
|     |     |     |     |     |     |     |     |
|     |     |     |     |     |     |     |     |
|-----------------------------------------------|

in the mouseMove event, I want to draw focus rectangles around the
appropriate cell being pointed to by the mouse.  And as the mouse moves
left or right, update the movement (deleteing the previous focus rect).

Can anyone help me!

procedure TQueenForm.DrawGrid2MouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
var TSRect: TRect;
begin
 with DrawGrid2 do
  begin
   if Queens <> 8 then
    begin
     MouseToCell(X,Y,BCol,BRow);
     if TCol <> BCol then
      begin
       SRect:= CellRect(BCol,BRow);
       Canvas.DrawFocusRect(SRect);
       TCol:= BCol;
      end;
    TSrect:= CellRect(BCol,BRow);
  end;
 end;
 InValidateRect(Handle, @TSRect,True);
end;

Shane Holmes

 

Re:TRect?


Quote
In article <4pim98$...@mercury.IntNet.net> holme...@netsrq.com (Shane Holmes) writes:
>From: holme...@netsrq.com (Shane Holmes)
>Subject: TRect?
>Date: 11 Jun 1996 02:39:36 GMT
>In delphi 2.0:
>I have a DrawGrid1 with 8 Cols, 1 row (no fixed)
>|-----------------------------------------------|
>|     |     |     |     |     |     |     |     |
>|     |     |     |     |     |     |     |     |
>|-----------------------------------------------|
>in the mouseMove event, I want to draw focus rectangles around the
>appropriate cell being pointed to by the mouse.  And as the mouse moves
>left or right, update the movement (deleteing the previous focus rect).
>Can anyone help me!

snip

would it not be better handled in the onselectcell event ?

you could possibly use the ondrawcell vewent to draw over the previously
highlighted cell

hth
boris

Re:TRect?


Quote
Shane Holmes wrote:

> In delphi 2.0:

> I have a DrawGrid1 with 8 Cols, 1 row (no fixed)

> |-----------------------------------------------|
> |     |     |     |     |     |     |     |     |
> |     |     |     |     |     |     |     |     |
> |-----------------------------------------------|

> in the mouseMove event, I want to draw focus rectangles around the
> appropriate cell being pointed to by the mouse.  And as the mouse moves
> left or right, update the movement (deleteing the previous focus rect).

> Can anyone help me!

> procedure TQueenForm.DrawGrid2MouseMove(Sender: TObject;
>   Shift: TShiftState; X, Y: Integer);
> var TSRect: TRect;
> begin
>  with DrawGrid2 do
>   begin
>    if Queens <> 8 then
>     begin
>      MouseToCell(X,Y,BCol,BRow);
>      if TCol <> BCol then
>       begin
>        SRect:= CellRect(BCol,BRow);
>        Canvas.DrawFocusRect(SRect);
>        TCol:= BCol;
>       end;
>     TSrect:= CellRect(BCol,BRow);
>   end;
>  end;
>  InValidateRect(Handle, @TSRect,True);
> end;

        Can't be certain without knowing what more of this stuff means,
(or what's going wrong), but here's a guess: What happens when you omit
the InvalidateRect? Seems like that's going to cause a repaint, which will
erase the rectangle you just drew.

--
David Ullrich
Sig file accidentally deleted - sorry.

Other Threads