Solved

FindVCLWindow 4 other applications' forms

Posted on 2000-02-14
5
355 Views
Last Modified: 2010-04-04
I can get the name of the control by the following:
FindVCLWindow(Mouse.CursorPos).Name;
But it works only in my form(s) otherwise raises access violation error. What can I do 2 get it work in other windows.
0
Comment
Question by:Gurkan
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:Radler
Comment Utility
Hi Gurkan;

What you need has a limitation to VCL Controls see the sample.
If isn't this what you want, tell us. By the way more points will be necessary.
//###Code
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
      Pt : TPoint;
      Control : TWinControl;
      Hnd : THandle;
      Str : array[0..255] of char;
begin
      GetCursorPos( Pt );
      Control:=FindVCLWindow( Pt ); //To NonVCL Windows the return is nil
      if Assigned( Control ) then begin
            Self.Edit1.Text:=Control.Name;
      end else begin
            Hnd:=WindowFromPoint( Pt );
            if Hnd <> 0 then begin
                  GetWindowText( Hnd, Str, 255 );
                  Edit1.Text:=Str;
                  if Str = EmptyStr then begin
                        GetClassName( Hnd, Str, 255 );
                        Edit1.Text:=Str;
                  end;
            end else begin
                  Edit1.Text:='NONE';
            end;
      end;
end;

end.


//### The DFM
object Form1: TForm1
  Left = 196
  Top = 103
  Width = 711
  Height = 172
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Edit1: TEdit
    Left = 99
    Top = 32
    Width = 505
    Height = 21
    TabOrder = 0
    Text = 'Edit1'
  end
  object Button1: TButton
    Left = 336
    Top = 96
    Width = 75
    Height = 25
    Caption = 'Get it'
    TabOrder = 1
    OnClick = Button1Click
  end
end


T++, Radler.
0
 

Author Comment

by:Gurkan
Comment Utility
Adjusted points to 50
0
 

Author Comment

by:Gurkan
Comment Utility
In fact your answer is the answer for my question but I just noticed that the name is not enough for me. I want to control its properties how can I do that? (Points Adjusted)
0
 
LVL 4

Accepted Solution

by:
Radler earned 50 total points
Comment Utility
Gurkan,

If the results is a VCLWindow you can changes the properties easily, but if the results show a window from another app you can changes a limited set of properties using the API. See the functions SetWindow* and some messages WM_SETTEXT.
I put again like answer, please before reject give a comment, OK !

T++, Radler.
0
 

Author Comment

by:Gurkan
Comment Utility
Thx
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now