?
Solved

Get the handle of a disabled item on another form.

Posted on 2005-03-07
4
Medium Priority
?
205 Views
Last Modified: 2010-04-05
Hi.

I have a code that get the handle of controls in another form when the mouse pass over them.

GetCursorPos(P);
Edit1.Text := IntToStr(WindowFromPoint(P));
GetClassName(StrToInt(Edit1.Text),Buff,255);
Edit2.Text := Buff;
Window Name :=GetWindowText(StrToInt(Edit1.Text),Buff,255);
If Buff <> '' then Edit3.Text := buff;
.......
.......
This code doesnt work for items that are disabled...
Is it possible to see those controls that are disabled?

Thanks in advance.
0
Comment
Question by:CodedK
  • 2
  • 2
4 Comments
 
LVL 26

Accepted Solution

by:
Russell Libby earned 1200 total points
ID: 13480879
You will need to use ChildWindowFromPoint to get those handles. An example function which will obtain the handle you are after:

function GetWindowAtCursor: HWND;
var  hwndChild:     HWND;
     ptScreen:      TPoint;
begin

  // Get cursor pos
  if GetCursorPos(ptScreen) then
  begin
     // Get window at point
     result:=WindowFromPoint(ptScreen);
     // Check result
     if (result <> 0) then
     begin
        // Convert point to child coords
        ScreenToClient(result, ptScreen);
        // Attempt to get the child window (enabled, disabled, hidden or otherwise)
        hwndChild:=ChildWindowFromPoint(result, ptScreen);
        // Check child handle
        if (hwndChild <> 0) then result:=hwndChild;
     end;
  end
  else
     result:=0

end;

Regards,
Russell
0
 
LVL 16

Author Comment

by:CodedK
ID: 13481023
Thanks very much ...
I'll give it a try tomorrow.
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 13481056
No problem, and no rush....

Russell
0
 
LVL 16

Author Comment

by:CodedK
ID: 13485018
Thank u very much Russell.
Works perfect... :)
I'll get back for the other question in a while..
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…

621 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