Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

FindVCLWindow 4 other applications' forms

Posted on 2000-02-14
5
Medium Priority
?
375 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 200 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

Industry Leaders: 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…
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

722 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