EnumWindows????

I use EnumWindows with a callback function, when I check the returned HWND(s) with ISWindow? I get false!!!!!!
Can you tell me why I hear no Beep here?

function CallBackFun(H:LongWord; A:Integer):Boolean;
begin
   Form1.Memo1.Lines.Add(IntToStr(H));
   If IsWindow(H) then Beep;
   Result:=True
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
   Form1.Memo1.Lines.Add('-----------------------');
   EnumWindows ( @CallBackFun, 0);
end;

barzangyAsked:
Who is Participating?
 
DrDelphiConnect With a Mentor Commented:
You neglected the calling convention in the callback function:

function EnumWindowsCallBack(HWND: hwnd;LPARAM : lParam):bool stdcall

an example is on my webpage and I just tonight got done writing a component for window tasks... check in tommorow if you like to try it out.


Good luck!!


0
 
rwilson032697Commented:
Well that's strange. The code works, but says none of the handles are windows (even redeclared H as HWND with no success).

Unless its got something to do with the windows only being top-level windows, but thats a bit far fecthed...

Cheers,

Raymond.
0
 
barzangyAuthor Commented:
but what do you mean with top-level windows?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
bryan7Commented:
listenning
0
 
rwilson032697Commented:
Top level windows are windows with no parents. Like the main application window. A window like that for an edit control is a child window.

Cheers,

Raymond.
0
 
intheCommented:
to add to the confusion:

procedure TForm1.Button1Click(Sender: TObject);
var
 wnd: HWND;
begin
 wnd := FindWindow('notepad', nil);
 if IsWindow(wnd) then
 beep;
end;
0
 
craig_capelCommented:
Delphi... Wheres your web page :)
0
 
DrDelphiCommented:
www.drdelphi.com

I have not uploaded the component yet due to a small problem with the server. I can email it to you if you like, though.
0
 
craig_capelCommented:
oh no... just want to nosey at your web page :)
0
 
craig_capelCommented:
oooh no... thats your weather reading 3c / 38f... oh i feel sorry for you... its nice and warm here 32c / about 90f  in the Canary Islands Tenerife.....
0
 
DrDelphiCommented:
Show off!!

0
 
barzangyAuthor Commented:
Ok, just give me sometime to test it!
0
 
craig_capelCommented:
i just tried out the code... and it returns the same number how ever many it is.... no compiler errors nothing...
13487
13487
13487
13487
13487
13487
  and it goes on and on.....


And No Beep here... is it because it goes that fast, the wave doesent get a chance to play?

beep by itself works ok
0
 
craig_capelCommented:
oh... stupid me... yeah i caught on to what you mean, your not questioning the beep.... LOL sorry all!!!!.... yeah ok

Yep, i put a breakpoint in and nothing on my machine either... really am not with it today :)

Craig C.
0
All Courses

From novice to tech pro — start learning today.