(self, icon)
return iconBitmap.GetHandle()
Load icons into the tray items.
        
        Got from https://stackoverflow.com/a/45890829.
Load icons into the tray items.
        
        Got from https://stackoverflow.com/a/45890829.
Load icons into the tray items . Got from https : // stackoverflow . com / a / 45890829 .
def _set_icon_menu(self, icon):
        """Load icons into the tray items.
        
        Got from https://stackoverflow.com/a/45890829.
        """
        ico_x = win32api.GetSystemMetrics(win32con.SM_CXSMICON)
        ico_y = win32api.GetSystemMetrics(win32con.SM_CYSMICON)
        hIcon = win32gui.LoadImage(0, icon, win32con.IMAGE_ICON, ico_x, ico_y, win32con.LR_LOADFROMFILE)

        hwndDC = win32gui.GetWindowDC(self.hwnd)
        dc = win32ui.CreateDCFromHandle(hwndDC)
        memDC = dc.CreateCompatibleDC()
        iconBitmap = win32ui.CreateBitmap()
        iconBitmap.CreateCompatibleBitmap(dc, ico_x, ico_y)
        oldBmp = memDC.SelectObject(iconBitmap)
        brush = win32gui.GetSysColorBrush(win32con.COLOR_MENU)

        win32gui.FillRect(memDC.GetSafeHdc(), (0, 0, ico_x, ico_y), brush)
        win32gui.DrawIconEx(memDC.GetSafeHdc(), 0, 0, hIcon, ico_x, ico_y, 0, 0, win32con.DI_NORMAL)

        memDC.SelectObject(oldBmp)
        memDC.DeleteDC()
        win32gui.ReleaseDC(self.hwnd, hwndDC)

        self.logger.debug('Set menu icon.')

        return iconBitmap.GetHandle()
def _set_icon_menu ( self , icon ) : ico_x = win32api . GetSystemMetrics ( win32con . SM_CXSMICON ) ico_y = win32api . GetSystemMetrics ( win32con . SM_CYSMICON ) hIcon = win32gui . LoadImage ( 0 , icon , win32con . IMAGE_ICON , ico_x , ico_y , win32con . LR_LOADFROMFILE ) hwndDC = win32gui . GetWindowDC ( self . hwnd ) dc = win32ui . CreateDCFromHandle ( hwndDC ) memDC = dc . CreateCompatibleDC ( ) iconBitmap = win32ui . CreateBitmap ( ) iconBitmap . CreateCompatibleBitmap ( dc , ico_x , ico_y ) oldBmp = memDC . SelectObject ( iconBitmap ) brush = win32gui . GetSysColorBrush ( win32con . COLOR_MENU ) win32gui . FillRect ( memDC . GetSafeHdc ( ) , ( 0 , 0 , ico_x , ico_y ) , brush ) win32gui . DrawIconEx ( memDC . GetSafeHdc ( ) , 0 , 0 , hIcon , ico_x , ico_y , 0 , 0 , win32con . DI_NORMAL ) memDC . SelectObject ( oldBmp ) memDC . DeleteDC ( ) win32gui . ReleaseDC ( self . hwnd , hwndDC ) self . logger . debug ( 'Set menu icon.' ) return iconBitmap . GetHandle ( )