parameters: (hdesk, desktop_name)
docstring: Runs as a thread on each desktop to create a new tray icon and handle its messages
docstring_summary: Runs as a thread on each desktop to create a new tray icon and handle its messages
docstring_tokens: Runs as a thread on each desktop to create a new tray icon and handle its messages
function: def new_icon(hdesk, desktop_name):
      """Runs as a thread on each desktop to create a new tray icon and handle its messages"""
      global id
      id = id + 1
      hdesk.SetThreadDesktop()
      ## apparently the threads can't use same hinst, so each needs its own window class
      windowclassname = "PythonDesktopManager" + desktop_name
      wc = win32gui.WNDCLASS()
      wc.hInstance = win32api.GetModuleHandle(None)
      wc.lpszClassName = windowclassname
      wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW | win32con.CS_GLOBALCLASS
      wc.hCursor = win32gui.LoadCursor(0, win32con.IDC_ARROW)
      wc.hbrBackground = win32con.COLOR_WINDOW
      wc.lpfnWndProc = icon_wndproc
      windowclass = win32gui.RegisterClass(wc)
      style = win32con.WS_OVERLAPPED | win32con.WS_SYSMENU
      hwnd = win32gui.CreateWindow(
          windowclass,
          "dm_" + desktop_name,
          win32con.WS_SYSMENU,
          0,
          0,
          win32con.CW_USEDEFAULT,
          win32con.CW_USEDEFAULT,
          0,
          0,
          wc.hInstance,
          None,
      )
      win32gui.UpdateWindow(hwnd)
      flags = win32gui.NIF_ICON | win32gui.NIF_MESSAGE | win32gui.NIF_TIP
      notify_info = (
          hwnd,
          id,
          flags,
          win32con.WM_USER + 20,
          hicon,
          "Desktop Manager (%s)" % desktop_name,
      )
      window_info[hwnd] = notify_info
      ## wait for explorer to initialize system tray for new desktop
      tray_found = 0
      while not tray_found:
          try:
              tray_found = win32gui.FindWindow("Shell_TrayWnd", None)
          except win32gui.error:
              traceback.print_exc
              time.sleep(0.5)
      win32gui.Shell_NotifyIcon(win32gui.NIM_ADD, notify_info)
      win32gui.PumpMessages()
function_tokens: def new_icon ( hdesk , desktop_name ) : global id id = id + 1 hdesk . SetThreadDesktop ( ) ## apparently the threads can't use same hinst, so each needs its own window class windowclassname = "PythonDesktopManager" + desktop_name wc = win32gui . WNDCLASS ( ) wc . hInstance = win32api . GetModuleHandle ( None ) wc . lpszClassName = windowclassname wc . style = win32con . CS_VREDRAW | win32con . CS_HREDRAW | win32con . CS_GLOBALCLASS wc . hCursor = win32gui . LoadCursor ( 0 , win32con . IDC_ARROW ) wc . hbrBackground = win32con . COLOR_WINDOW wc . lpfnWndProc = icon_wndproc windowclass = win32gui . RegisterClass ( wc ) style = win32con . WS_OVERLAPPED | win32con . WS_SYSMENU hwnd = win32gui . CreateWindow ( windowclass , "dm_" + desktop_name , win32con . WS_SYSMENU , 0 , 0 , win32con . CW_USEDEFAULT , win32con . CW_USEDEFAULT , 0 , 0 , wc . hInstance , None , ) win32gui . UpdateWindow ( hwnd ) flags = win32gui . NIF_ICON | win32gui . NIF_MESSAGE | win32gui . NIF_TIP notify_info = ( hwnd , id , flags , win32con . WM_USER + 20 , hicon , "Desktop Manager (%s)" % desktop_name , ) window_info [ hwnd ] = notify_info ## wait for explorer to initialize system tray for new desktop tray_found = 0 while not tray_found : try : tray_found = win32gui . FindWindow ( "Shell_TrayWnd" , None ) except win32gui . error : traceback . print_exc time . sleep ( 0.5 ) win32gui . Shell_NotifyIcon ( win32gui . NIM_ADD , notify_info ) win32gui . PumpMessages ( )