From 037ab8e23e82444db52e06571de11a70179ffe10 Mon Sep 17 00:00:00 2001 From: markm Date: Tue, 28 Mar 2006 15:30:25 +0000 Subject: [PATCH] Modified is_toplevel_window() so that it only call's style() once and does not call has_style() for optimization --- pywinauto/handleprops.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pywinauto/handleprops.py b/pywinauto/handleprops.py index af4ae46..f3f107a 100644 --- a/pywinauto/handleprops.py +++ b/pywinauto/handleprops.py @@ -210,13 +210,13 @@ def has_exstyle(handle, tocheck): def is_toplevel_window(handle): "Return whether the window is a top level window or not" - # I don't like this so I have commented it out - #if classname(handle) in ['tooltips_class32']: - # return False + # only request the style once - this is an optimization over calling + # (handle, style) for each style I wan to check! + style_ = style(handle) - if (has_style(handle, win32defines.WS_OVERLAPPED) or \ - has_style(handle, win32defines.WS_CAPTION)) and \ - not has_style(handle, win32defines.WS_CHILD): + if (style_ & win32defines.WS_OVERLAPPED == win32defines.WS_OVERLAPPED or \ + style_ & win32defines.WS_CAPTION == win32defines.WS_CAPTION) and \ + not (style_ & win32defines.WS_CHILD == win32defines.WS_CHILD): return True else: return False