Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Poss. to get a form's caption from HWnd ? 1

Status
Not open for further replies.

LucieLastic

Programmer
May 9, 2001
1,694
GB
hi All

I have a TList containing the Handles of all the Forms open. I add to the list like this:

WindowList.Add(pointer(ViewForm.handle));

I destroy the windows later, like this:

for idx := WindowList.Count -1 downto 0 do
begin
// <-- would like to get the caption of the form here
DestroyWindow(HWnd(WindowList.Items[idx]));
res := GetLastError;
if res = 0
then showmessage('Can not destroy window')
else WindowList.delete(idx);
end;

I occassionally get the 'Can not destroy' coming up but I don't know which window it is. Is it possible to get the caption of the form before destroying it, eg something like:-

WndName := TForm(HWnd(WindowList.Items[idx])).Caption;

I don;t know how to use the HWnd reference with TForm.

Many thanks for any help.

lou
 
Code:
var 
  ACaptionLength : Integer;
  ACaption       : pChar;
begin
  ACaptionLength := GetWindowTextLenght(AHwnd);
  GetWindowText(AHwnd, ACaption, ACaptionLength);
  ShowMessage(String(ACaption));
end;

--- markus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top