Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2005 May : Checking form existence
| Subject: | Checking form existence |
| Posted by: | "Herry B." (hbou..@gmail.dot.com) |
| Date: | Sun, 22 May 2005 02:10:47 |
Hi All,
I think this is an easy and silly question, but i'm stuck right now.
I am developing an application contains several forms on it. The main form
has 2 panels, one panel has the 'links' where user can click a label that
will open a form parented to the second panel. I do this with code like :
Application.CreateForm(TFormName,FormName);
with FormName do
begin
Parent := PanelData;
Align := alClient;
BorderStyle := bsNone;
OnClose := ThisFormClose; // here I put "caFree" to release the form
Show;
end;
How do I know a certain form had been parented to the PanelData? So if it
was, no need to call the above function again.
I used FindWindow, and a function like this without success :
function WindowExists(ClassName, WindowName: string): Boolean;
var
PClassName, PWindowName: PChar;
AClassName, AWindowName: array[0..63] of char;
begin
if ClassName='' then PClassName:=nil
else PClassName:=StrPCopy(@AClassName[0], ClassName);
if WindowName='' then PWindowName:=nil
else PWindowName:=StrPCopy(@AWindowName[0], WindowName);
if FindWindow(PClassName, PWindowName)<>0 then Result:=True
else Result:=False;
end;
TIA,
Herry B.