I am currently working on a game overlay in python (which draws a text on the screen). There for I create a invisible fullscreen window using pywin32. My problem is that I create the window and pump the messages in a new thread.
def run_overlay_thread():
thr = threading.Thread(target=game_overlay.main, args=())
thr.setDaemon(True)
#thr.setDaemon(False)
thr.start()
So when I call the RedrawWindow function like this:
win32gui.RedrawWindow(hWindow, None, None, win32con.RDW_INVALIDATE | win32con.RDW_ERASE)
nothing happens (No WM_PAINT message is fired).
def wndProc(hWnd, message, wParam, lParam):
print('called with message:{}'.format(message))
if message == win32con.WM_PAINT:
hdc, paintStruct = win32gui.BeginPaint(hWnd)
... more draw code ...
The WM_PAINT message is fired once while creating the window so I can see the text showing up but I can't update the text. I have to call PumpMessages in a new thread because I want to run init code of other parts of the app (for example the gui or "backend")
Does someone know how to fix this? Any help would be appreciated! Sorry for my bad english :)
Fixed the problem by using InvalidateRect instead of RedrawWindow. My new Code:
win32gui.InvalidateRect(hWindow, None, True);