noreply at rubyforge.org
2008-Dec-31 10:15 UTC
[Win32utils-devel] [ win32utils-Support Requests-23395 ] EnumChildWindows and EnumWindowsProc with win32-api-1.2.2
Support Requests item #23395, was opened at 2008-12-31 05:15
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=412&aid=23395&group_id=85
Category: win32-api
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Nobody (None)
Assigned to: Nobody (None)
Summary: EnumChildWindows and EnumWindowsProc with win32-api-1.2.2
Initial Comment:
My program doesn''t work normally with win32-api-1.2.2.
There was no problem with win32-api-1.2.0.
At EnumChildWindows.call(), lparam in EnumWindowsProc is not correct.
# my program
require ''win32/api''
class SimpleWindow
GetWindowText = Win32::API.new(''GetWindowText'',
''LPI'', ''I'', ''user32'')
GetClassName = Win32::API.new(''GetClassName'',
''LPI'', ''I'', ''user32'')
EnumWindows = Win32::API.new(''EnumWindows'',
''KL'', ''L'', ''user32'')
EnumChildWindows = Win32::API.new(''EnumChildWindows'',
''LKL'', ''L'', ''user32'')
EnumWindowsProc = Win32::API::Callback.new(''LL'',
''I'') {|hwnd, lparam|
begin
block = ObjectSpace._id2ref(lparam)
if block.respond_to? :call
block.call(SimpleWindow.new(hwnd)) == :break ? 0 : 1
else
0
end
rescue
warn $!
0
end
}
TMP = ("\0" * 256).freeze
def self.each(&block)
EnumWindows.call(EnumWindowsProc, block.__id__)
end
def initialize(hwnd)
@hwnd = hwnd
end
def each(&block)
EnumChildWindows.call(@hwnd, EnumWindowsProc, block.__id__)
end
def caption
tmp = TMP.dup
GetWindowText.call(@hwnd, tmp, tmp.size-1)
tmp.rstrip
end
def class_name
tmp = TMP.dup
len = GetClassName.call(@hwnd, tmp, tmp.size-1)
tmp.rstrip
end
end
p Win32::API::VERSION
SimpleWindow.each {|win|
if win.class_name == ''Shell_TrayWnd''
win.each {|cwin|
p [cwin.caption, cwin.class_name]
}
next :break
end
}
----------------------------------------------------------------------
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=412&aid=23395&group_id=85
Daniel Berger
2008-Dec-31 11:08 UTC
[Win32utils-devel] [ win32utils-Support Requests-23395 ] EnumChildWindows and EnumWindowsProc with win32-api-1.2.2
Hi,> My program doesn''t work normally with win32-api-1.2.2. > There was no problem with win32-api-1.2.0.<snip> Yep, he''s right. With 1.2.0 I get this: c:\Users\djberge\workspace\ruby-foo\win32>ruby api_test.rb "1.2.0" ["", "TrayNotifyWnd"] ["4:03 AM", "TrayClockWClass"] ["", "SysPager"] ["Notification Area", "ToolbarWindow32"] ["", "SysPager"] ["System Control Area", "ToolbarWindow32"] ["", "Button"] ["", "ReBarWindow32"] ["Quick Launch", "ToolbarWindow32"] ["Running Applications", "MSTaskSwWClass"] ["Running Applications", "ToolbarWindow32"] With 1.2.2 I get this: c:\Users\djberge\workspace\ruby-foo\win32>ruby api_test.rb "1.2.2" 0x1ca2b8 is not id value Any ideas? Regards, Dan
Park Heesob
2008-Dec-31 14:36 UTC
[Win32utils-devel] [ win32utils-Support Requests-23395 ] EnumChildWindows and EnumWindowsProc with win32-api-1.2.2
Hi, ----- Original Message ----- From: "Daniel Berger" <djberg96 at gmail.com> To: "Development and ideas for win32utils projects" <win32utils-devel at rubyforge.org> Sent: Wednesday, December 31, 2008 8:08 PM Subject: Re: [Win32utils-devel] [ win32utils-Support Requests-23395 ] EnumChildWindows and EnumWindowsProc with win32-api-1.2.2> Hi, > >> My program doesn''t work normally with win32-api-1.2.2. >> There was no problem with win32-api-1.2.0. > > <snip> > > Yep, he''s right. With 1.2.0 I get this: > > c:\Users\djberge\workspace\ruby-foo\win32>ruby api_test.rb > "1.2.0" > ["", "TrayNotifyWnd"] > ["4:03 AM", "TrayClockWClass"] > ["", "SysPager"] > ["Notification Area", "ToolbarWindow32"] > ["", "SysPager"] > ["System Control Area", "ToolbarWindow32"] > ["", "Button"] > ["", "ReBarWindow32"] > ["Quick Launch", "ToolbarWindow32"] > ["Running Applications", "MSTaskSwWClass"] > ["Running Applications", "ToolbarWindow32"] > > With 1.2.2 I get this: > > c:\Users\djberge\workspace\ruby-foo\win32>ruby api_test.rb > "1.2.2" > 0x1ca2b8 is not id value > > Any ideas? >Sorry. It is a bug due to my modification of callback support. Here is the patch for api.c =============================================@@ -671,6 +671,7 @@ Win32API* ptr; unsigned long return_value; int i = 0; + int len; struct{ unsigned long params[20]; @@ -695,8 +696,8 @@ ); } } - - for(i = 0; i < RARRAY(v_proto)->len; i++){ + len = RARRAY(v_proto)->len; + for(i = 0; i < len; i++){ v_arg = RARRAY(v_args)->ptr[i]; /* Convert nil to NULL. Otherwise convert as appropriate. */ ================================================= Happy New Year! Regards, Park Heesob
Berger, Daniel
2008-Dec-31 17:24 UTC
[Win32utils-devel] [ win32utils-Support Requests-23395] EnumChildWindows and EnumWindowsProc with win32-api-1.2.2
> -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Park Heesob > Sent: Wednesday, December 31, 2008 7:37 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] [ win32utils-Support > Requests-23395] EnumChildWindows and EnumWindowsProc with > win32-api-1.2.2 > > Hi, > ----- Original Message ----- > From: "Daniel Berger" <djberg96 at gmail.com> > To: "Development and ideas for win32utils projects" > <win32utils-devel at rubyforge.org> > Sent: Wednesday, December 31, 2008 8:08 PM > Subject: Re: [Win32utils-devel] [ win32utils-Support > Requests-23395 ] EnumChildWindows and EnumWindowsProc with > win32-api-1.2.2 > > > > Hi, > > > >> My program doesn''t work normally with win32-api-1.2.2. > >> There was no problem with win32-api-1.2.0. > > > > <snip> > > > > Yep, he''s right. With 1.2.0 I get this: > > > > c:\Users\djberge\workspace\ruby-foo\win32>ruby api_test.rb "1.2.0" > > ["", "TrayNotifyWnd"] > > ["4:03 AM", "TrayClockWClass"] > > ["", "SysPager"] > > ["Notification Area", "ToolbarWindow32"] ["", "SysPager"] ["System > > Control Area", "ToolbarWindow32"] ["", "Button"] ["", > "ReBarWindow32"] > > ["Quick Launch", "ToolbarWindow32"] ["Running Applications", > > "MSTaskSwWClass"] ["Running Applications", "ToolbarWindow32"] > > > > With 1.2.2 I get this: > > > > c:\Users\djberge\workspace\ruby-foo\win32>ruby api_test.rb "1.2.2" > > 0x1ca2b8 is not id value > > > > Any ideas? > > > Sorry. It is a bug due to my modification of callback support. > Here is the patch for api.c > =============================================> @@ -671,6 +671,7 @@ > Win32API* ptr; > unsigned long return_value; > int i = 0; > + int len; > > struct{ > unsigned long params[20]; > @@ -695,8 +696,8 @@ > ); > } > } > - > - for(i = 0; i < RARRAY(v_proto)->len; i++){ > + len = RARRAY(v_proto)->len; > + for(i = 0; i < len; i++){ > v_arg = RARRAY(v_args)->ptr[i]; > > /* Convert nil to NULL. Otherwise convert as > appropriate. */ =================================================> > Happy New Year!Yep, that worked, thanks. Committed to CVS. Happy New Year to you, too! Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.