[Tutor] Python - resize ReBarWindow32 with SetWindowPos

Emilio C larry.united at t-online.de
Thu Oct 13 04:04:00 EDT 2022


I am trying to resize the ReBarWindow32 (the main part of the taskbar). In theory it works, as the new width and height get accepted, however it doesn't seem to translate visually, because the bar doesn't change in appearance.
This is the cropped out resizing part, unrelated code removed
import win32gui
import win32con

taskbar_shell = win32gui.FindWindow("Shell_TrayWnd",None)

print("SHELL: " , taskbar_shell)
place = win32gui.GetWindowPlacement(taskbar_shell)
print("SHELL place: " , place)

taskbar_rebar = win32gui.FindWindowEx(taskbar_shell, None, "ReBarWindow32", None)

print("ReBar: " , taskbar_rebar)
place = win32gui.GetWindowPlacement(taskbar_rebar)
print("ReBar place: " , place)

############## SETWINDOWPOS resize the bar ##################win32gui.MoveWindow(taskbar_rebar, 0, 0, 200, 22, True)##win32gui.SetWindowPos(taskbar_rebar, None, 0, 0, 200, 22, win32con.SWP_NOSENDCHANGING)
win32gui.SetWindowPos(taskbar_rebar, None, 0, 0, 200, 22, win32con.SWP_NOMOVE |
win32con.SWP_NOSENDCHANGING | win32con.SWP_NOREDRAW)

win32gui.ShowWindow(taskbar_rebar, win32con.SW_SHOW)
win32gui.UpdateWindow(taskbar_rebar)

place = win32gui.GetWindowPlacement(taskbar_rebar)
print("Rebar place after SetWindowPos: " , place)

###win32gui.RedrawWindow(taskbar_rebar, None, None, win32con.RDW_INVALIDATE |
win32con.RDW_INTERNALPAINT | win32con.CS_HREDRAW | win32con.CS_VREDRAW |
win32con.RDW_UPDATENOW)
print shows successfully altered w and h. But visually nothing changes in the taskbar. I tried so many different flags. The flags in place rn are just the last to have been tried by me

Do you guys happens to know what I’m doing wrong?

System: Windows 11, Python 3


More information about the Tutor mailing list