Solved

FindVCLWindow 4 other applications' forms

Posted on 2000-02-14
5
368 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:Radler
ID: 2520549
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
ID: 2526319
Adjusted points to 50
0
 

Author Comment

by:Gurkan
ID: 2526320
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
ID: 2526772
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
ID: 2527330
Thx
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Suggested Courses
Course of the Month6 days, 7 hours left to enroll

634 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