Hi,
Now this is a bug - and I think I've fixed it (been committed - also added
WaitMessage function). I'm not 100% sure I've considered all possible
situations - for those interested the fixed code is below.
Comments anyone?
Cheers,
jez.
--------------------------------------
GUI.xs
###########################################################################
# (@)METHOD:EnumMyWindows()
# Returns a list of window handles created by your application.
#
# Usage: @windows = Win32::GUI::EnumMyWindows();
#
void
EnumMyWindows()
PREINIT:
AV* ary;
int i;
PPCODE:
ary = newAV();
EnumWindows( (WNDENUMPROC) EnumMyWindowsProc, (LPARAM) ary);
for(i=0; i<av_len(ary)+1; i++) {
//printf("XS(EnumMyWindows): ary[%d] = %ld\n", i,
SvIV(*(av_fetch(ary, i, 0))));
XST_mIV(i, SvIV(*(av_fetch(ary, i, 0))));
}
SvREFCNT_dec((SV*)ary);
XSRETURN(i);
GUI_Helpers.cpp
/*
##########################################################################
# (@)INTERNAL:EnumMyWindowsProc(hwnd, lparam)
*/
BOOL CALLBACK EnumMyWindowsProc(HWND hwnd, LPARAM lparam) {
dTHX; /* fetch context */
AV* ary;
DWORD pid;
DWORD style;
// PERL_OBJECT_FROM_WINDOW(hwnd);
ary = (AV*) lparam;
GetWindowThreadProcessId(hwnd, &pid);
if(pid == GetCurrentProcessId()) {
//style = (DWORD) GetWindowLong(hwnd, GWL_STYLE);
//if(!(style & GW_CHILD)) {
av_push(ary, newSViv((long)hwnd));
//}
}
return TRUE;
}
----- Original Message -----
From: "Robert May" <[EMAIL PROTECTED]>
To: <perl-win32-gui-users@lists.sourceforge.net>
Sent: Wednesday, March 16, 2005 8:55 PM
Subject: [perl-win32-gui-users] BUG REPORT: [ 1164783 ] EnumMyWindows() does
not work
I have submitted a bug report whose text I reproduce below.
http://sourceforge.net/tracker/index.php?func=detail&aid=1164783&group_id=16572&atid=116572
Regards,
Rob.
[ 1164783 ] EnumMyWindows() does not work
-------------------------------------------------------
Win32::GUI::EnumMyWindows() should return a list of top-level
window created by the calling process.
It returns an empty list. This is because the callback performs
a test of the windows style against GW_CHILD, when it should
be testing against WS_CHILD.
The callback (EnumMyWindowsProc in GUI_helpers.cpp) does
not need to perform this test at all, as EnumWindows() only
performs the callback for top level windows
(without WS_CHILD), according to MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/enumwindows.asp
Additionally there is an uncommented debug printf in
Win32::GUI::EnumMyWindows() at
GUI.xs (v1.29, line 3908) that should be commented out, or
otherwise removed.
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users