I noticed app sometimes hanging during window resize in the wxpython.py example. It occurs during the EVT_SIZE event when calling WindowUtils.OnSize. That function does not handle things properly and it should only be called when handling WM_SIZE message, as it makes calls to DefWindowProc.
The solution will be to expose Browser.SetBounds on Windows which will be a wrapper for SetWindowPos WIN32 API.
All examples should be updated to use the new Browser.SetBounds method.
In v49 release for WinXP/Vista there is WindowUtils.UpdateBrowserSize, so it needs to be added to Migration Guide doc that it is require to call Browser.SetBounds now..
Related issue: #345 ("Crash when resizing browser using WindowUtils.OnSize with multi-threaded message loop set to True").
window_utils_win.pyx
@staticmethod
def OnSize(WindowHandle windowHandle, long msg, long wparam, long lparam):
cdef PyBrowser pyBrowser = GetBrowserByWindowHandle(windowHandle)
if not pyBrowser:
return DefWindowProc(<HWND>windowHandle, msg, wparam, lparam)
cdef HWND innerHwnd = <HWND>pyBrowser.GetWindowHandle()
if not innerHwnd:
return DefWindowProc(<HWND>windowHandle, msg, wparam, lparam)
cdef RECT rect2
cdef BOOL result = GetClientRect(<HWND>windowHandle, &rect2)
cdef HDWP hdwp
if result != 0:
hdwp = BeginDeferWindowPos(1)
if hdwp:
hdwp = DeferWindowPos(hdwp, innerHwnd, NULL,
rect2.left, rect2.top,
rect2.right - rect2.left,
rect2.bottom - rect2.top,
SWP_NOZORDER)
if hdwp:
EndDeferWindowPos(hdwp)
return DefWindowProc(<HWND>windowHandle, msg, wparam, lparam)
@staticmethod
def UpdateBrowserSize(WindowHandle parent_window_handle,
PyBrowser browser,
py_bool redraw=True):
cdef HWND innerHwnd = <HWND>browser.GetWindowHandle()
if not innerHwnd:
return
cdef RECT rect2
cdef BOOL result = GetClientRect(<HWND>parent_window_handle, &rect2)
cdef UINT flags = SWP_NOZORDER
if not redraw:
flags = SWP_NOZORDER | SWP_NOREDRAW
if result != 0:
SetWindowPos(innerHwnd, NULL,
rect2.left, rect2.top,
rect2.right - rect2.left,
rect2.bottom - rect2.top,
flags)
wxpython.py
WindowUtils.UpdateBrowserSize,(self.browser_panel.GetHandle(), self.browser)
I noticed app sometimes hanging during window resize in the wxpython.py example. It occurs during the EVT_SIZE event when calling
WindowUtils.OnSize. That function does not handle things properly and it should only be called when handling WM_SIZE message, as it makes calls toDefWindowProc.The solution will be to expose
Browser.SetBoundson Windows which will be a wrapper forSetWindowPosWIN32 API.All examples should be updated to use the new
Browser.SetBoundsmethod.In v49 release for WinXP/Vista there is
WindowUtils.UpdateBrowserSize, so it needs to be added to Migration Guide doc that it is require to callBrowser.SetBoundsnow..Related issue: #345 ("Crash when resizing browser using WindowUtils.OnSize with multi-threaded message loop set to True").
window_utils_win.pyx
wxpython.py