On your previous advice I have been looking at the GetWindow and
EnumChildWindows API calls but am getting some od results.
The application I was trying to get window handles to does not report any
child windows using the EnumChildWindows call or GetWindow with the
GW_CHILD command set.
However, other applications do return their child windows through these API
calls.
I cannot find any consistency in this behaviour with some applications it
works others it doesn't.
When I run WinID by Dennis A Babkin and hover the mouse over those
applications which seemingly don't report their child handles through the
API this picks up the structure correctly and confirms the relationship of
control to the application. What am I missing,
Here is a simple program which should pick up the Main window and list its
top level children.
Function GetOtherWindow (const sCaption : String) : WideString;
var
hWindow : Hwnd;
hChild : Hwnd;
aTemp : array[0..5000] of Char;
sClassName : String;
begin
Result := '';
hWindow := 0;
if sCaption > '' then
hWindow := FindWindow(Nil,PChar(sCaption));
if hWindow = 0 then
begin
Result := 'Could not find Application ' + sCaption;
Exit;
end;
if GetClassName(hWindow, aTemp, SizeOf(aTemp)) > 0 then
begin
sClassName := StrPAS(aTemp);
Result := 'Application Name = ' + Form1.Edit1.Text + #13 + 'ClassName ='
+ sClassName;
end;
hChild := GetWindow(hWindow, GW_CHILD);
while hChild <> 0 do Begin
if GetClassName(hChild, aTemp, SizeOf(aTemp)) > 0 then begin
sClassName := StrPAS(aTemp);
Result := Result + #13 + 'Child ClassName = ' + sClassName;
end;
hChild := GetWindow(hChild, GW_HWNDNEXT);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ListBox1.Items.Text := GetOtherWindow (edit1.Text);//
end;
Thanks
_______________________________________________
Delphi mailing list
[email protected]
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi