if  (components[i].Left =99) and (components[i].left =50) then不应该用“=”吧?

解决方案 »

  1.   

    procedure TForm1.Timer1Timer(Sender: TObject);
    var
      vPoint: TPoint;
      vHandle: THandle;
      I: Integer;
    begin
      GetCursorPos(vPoint);
      //vPoint.X := ?
      //vPoint.Y := ?
      vHandle := WindowFromPoint(vPoint);
      for I := 0 to Pred(ComponentCount) do
        if (Components[I] is TWinControl) and
          (TWinControl(Components[I]).Handle = vHandle) then
        begin
          Caption := TWinControl(Components[I]).Name;
        end;
    end;
      

  2.   

      GetCursorPos(vPoint); //返回当前鼠标的位置
      vHandle := WindowFromPoint(vPoint);  //获取指定位置,窗体的句柄
      

  3.   

    请问那如果是要得到非WINCOMTROL的名字了?
    比如说是IMAGE类,因为它没有句柄。
    谢谢!
      

  4.   

    把Image等放到上TWinComtrol就ok了  object Panel1: TPanel
        Left = 24
        Top = 40
        Width = 185
        Height = 41
        BevelOuter = bvNone
        Caption = 'Panel1'
        TabOrder = 1
        object Image1: TImage
          Left = 0
          Top = 0
          Width = 185
          Height = 41
          Align = alClient
          Picture.Data = {
           ..........
          }  
        end
      end
      

  5.   

      for I := 0 to Pred(ComponentCount) do
        if (Components[I] is TWinControl) and
          (TWinControl(Components[I]).Handle = vHandle) then
        begin
          Caption := TWinControl(Components[I]).Name;      Break; //加
        end;
      

  6.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
    p:tpoint;
    begin
    GetCursorPos(p);
    if FindVCLWindow(p)<>nil then
      showmessage('Found!');
    end;
      

  7.   

    for i:=0 to ComponentCount-1  do
    if  (components[i].Left =99) and (components[i].left =50) then
        begin
              ..................
        end;改正for i:=0 to ComponentCount-1  do
    if  (components[i].Left =99) and (components[i].top =50) then
        begin
              ..................
        end;