What is wrong with this code?

contains all delphi packages mentioned below
Post Reply
shamers
Posts: 7
Joined: Wed Jun 07, 2006 6:46 pm

What is wrong with this code?

Post by shamers »

function CheckItOut:boolean;
begin
Result := true;
if FindWindow('ExampleName', nil) = 0 then exit;
if not FindWindow('ExampleName', nil) = 0 then
begin
Result := True;
showmessage('true');
end;
end;

Can anyone tell me what I'm doing wrong here?

Sorry but I'm a newby...

Grtz
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Perhaps if you tell us which problem you have exactly with this code, we might have a better chance to help you.
shamers
Posts: 7
Joined: Wed Jun 07, 2006 6:46 pm

Post by shamers »

When a window with the windowname "ExampleName" is visible. The function doesn't show the message "true"

I want to make a function(boolean) so that I can check if a Windo exists or not.

Regards, S
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Maybe you're looking for the window title? Your code looks for the window class name. Check out the documentation of FindWindow. Probably you need to swap the parameters.
shamers
Posts: 7
Joined: Wed Jun 07, 2006 6:46 pm

Post by shamers »

Thanx Madshi! You were right. It works.
Post Reply