Ae Alisson,
   
  Eu tenho aq rotinas q fazem esse desenho de retângulo ao mover o mouse, mas 
isso é feito sobre um TImage. Não sei se surte o msm efeito sobre um TForm. Mas 
ve se ajuda vc ae...
   
  Declare duas variáveis globais do tipo TPoint, e uma booleana:
   
  var
  PDown, PActually: TPoint;
  MouseIsDown: boolean;
   
  Nos eventos do TImage (MouseDown, MouseMove, MouseUP) faça o seguinte:
   
  procedure TForm.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Image1.Picture := nil;
  Image1.Transparent := true;
  Image1.Canvas.Pen.Color := clLime;
  Image1.Canvas.Pen.Width := 1;
  Image1.Canvas.Rectangle(Rect(x,y,x,y));
  MouseIsDown := true;
  PDown := Point(x,y);
  PActually := Point(x,y);
end;

  procedure TForm.Image1LayerMouseMove(Sender: TObject; Shift: TShiftState;
  X, Y: Integer);
begin
  if MouseIsDown then
  begin
    Image1.Picture := nil;
    Image1.Canvas.Pen.Color := clLime;
    Image1.Canvas.Pen.Width := 1;
    if X > Image1.Width then
      X := Image1.Width
    else
      if X < 0 then
        X := 0;
    if Y > Image1.Height then
      Y := Image1.Height
    else
      if Y < 0 then
        Y := 0;
    if (PDown.X <= PActually.X) and (PDown.Y <= PActually.Y) then
    begin
      Image1.Canvas.Rectangle(Rect(PDown.X,PDown.Y,PActually.X,PActually.Y));
      PActually := Point(x,y);
      Image1.Canvas.Rectangle(Rect(PDown.X,PDown.Y,x,y));
    end
    else
    begin
      if (PDown.X >= PActually.X) and (Pdown.Y >= PActually.Y) then
      begin
        Image1.Canvas.Rectangle(Rect(PActually.X,PActually.Y,PDown.X,PDown.Y));
        PActually := Point(x,y);
        Image1.Canvas.Rectangle(Rect(x,y,PDown.X,PDown.Y));
      end
      else
      begin
        if (PDown.X >= PActually.X) and (PDown.Y <= PActually.Y) then
        begin
          
Image1.Canvas.Rectangle(Rect(PActually.X,PDown.Y,PDown.X,PActually.Y));
          PActually := Point(x,y);
          Image1.Canvas.Rectangle(Rect(x,PDown.Y,PDown.X,y));
        end
        else
        begin
          if (PDown.X <= PActually.X) and (PDown.Y >= PActually.Y) then
          begin
            
Image1.Canvas.Rectangle(Rect(PDown.X,PActually.Y,Pactually.X,PDown.Y));
            PActually := Point(x,y);
            Image1.Canvas.Rectangle(Rect(PDown.X,y,x,PDown.Y));
          end;
        end;
      end;
    end;
  end;
end;
   
  procedure TForm.Image1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Image1.Canvas.Rectangle(Rect(PDown.X,PDown.Y,PActually.X,PActually.Y));
  Image1.Canvas.Rectangle(Rect(PDown.X,PDown.Y,x,y));
  MouseIsDown := false;
end;

  Nesse caso vai ser desenhado um retângulo na cor Lime. É só mudar os 
parâmetros para fazer um retângulo ao seu gosto.
   
  []'s!!
   
  Daniel Ozawa
  Londrina-PR
   
  
Alisson Yahoo <[EMAIL PROTECTED]> escreveu:
  Pessoal,

Gostaria que em uma tela do meu programa fosse desenhado um retângulo com
linha pontilhada quando se arrastasse o mouse com o botão pressionado, e os
componentes que estivessem dentro desse retângulo mudassem de cor. Seria
algo igual ao recurso do Delphi de selecionar vários componentes arrastando
o mouse. Alguém pode me ajudar?

Alisson


[As partes desta mensagem que não continham texto foram removidas]




 

 __________________________________________________
Fale com seus amigos  de graça com o novo Yahoo! Messenger 
http://br.messenger.yahoo.com/ 

[As partes desta mensagem que não continham texto foram removidas]



-- 
<<<<< FAVOR REMOVER ESTA PARTE AO RESPONDER ESTA MENSAGEM >>>>>

<*> Para ver as mensagens antigas, acesse:
    http://br.groups.yahoo.com/group/delphi-br/messages

<*> Para falar com o moderador, envie um e-mail para:
    [EMAIL PROTECTED]
 
Links do Yahoo! Grupos

<*> Para visitar o site do seu grupo na web, acesse:
    http://br.groups.yahoo.com/group/delphi-br/

<*> Para sair deste grupo, envie um e-mail para:
    [EMAIL PROTECTED]

<*> O uso que você faz do Yahoo! Grupos está sujeito aos:
    http://br.yahoo.com/info/utos.html

 



Responder a