Python win32gui.DeleteDC() Examples
The following are 6
code examples of win32gui.DeleteDC().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
win32gui
, or try the search function
.
Example #1
Source File: gui_win.py From ComicStreamer with Apache License 2.0 | 7 votes |
def prep_menu_icon(self, icon): # First load the 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) hdcBitmap = win32gui.CreateCompatibleDC(0) hdcScreen = win32gui.GetDC(0) hbm = win32gui.CreateCompatibleBitmap(hdcScreen, ico_x, ico_y) hbmOld = win32gui.SelectObject(hdcBitmap, hbm) # Fill the background. brush = win32gui.GetSysColorBrush(win32con.COLOR_MENU) win32gui.FillRect(hdcBitmap, (0, 0, 16, 16), brush) # unclear if brush needs to be feed. Best clue I can find is: # "GetSysColorBrush returns a cached brush instead of allocating a new # one." - implies no DeleteObject # draw the icon win32gui.DrawIconEx(hdcBitmap, 0, 0, hicon, ico_x, ico_y, 0, 0, win32con.DI_NORMAL) win32gui.SelectObject(hdcBitmap, hbmOld) win32gui.DeleteDC(hdcBitmap) return hbm
Example #2
Source File: SysTrayIcon.py From LIFX-Control-Panel with MIT License | 6 votes |
def prep_menu_icon(self, icon): # First load the 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) hdcBitmap = win32gui.CreateCompatibleDC(0) hdcScreen = win32gui.GetDC(0) hbm = win32gui.CreateCompatibleBitmap(hdcScreen, ico_x, ico_y) hbmOld = win32gui.SelectObject(hdcBitmap, hbm) # Fill the background. brush = win32gui.GetSysColorBrush(win32con.COLOR_MENU) win32gui.FillRect(hdcBitmap, (0, 0, 16, 16), brush) # unclear if brush needs to be feed. Best clue I can find is: # "GetSysColorBrush returns a cached brush instead of allocating a new # one." - implies no DeleteObject # draw the icon win32gui.DrawIconEx(hdcBitmap, 0, 0, hicon, ico_x, ico_y, 0, 0, win32con.DI_NORMAL) win32gui.SelectObject(hdcBitmap, hbmOld) win32gui.DeleteDC(hdcBitmap) return hbm
Example #3
Source File: systray.py From OpenBazaar-Installer with MIT License | 6 votes |
def prep_menu_icon(self, icon): # First load the 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) hdcBitmap = win32gui.CreateCompatibleDC(0) hdcScreen = win32gui.GetDC(0) hbm = win32gui.CreateCompatibleBitmap(hdcScreen, ico_x, ico_y) hbmOld = win32gui.SelectObject(hdcBitmap, hbm) # Fill the background. brush = win32gui.GetSysColorBrush(win32con.COLOR_MENU) win32gui.FillRect(hdcBitmap, (0, 0, 16, 16), brush) # unclear if brush needs to be feed. Best clue I can find is: # "GetSysColorBrush returns a cached brush instead of allocating a new # one." - implies no DeleteObject # draw the icon win32gui.DrawIconEx(hdcBitmap, 0, 0, hicon, ico_x, ico_y, 0, 0, win32con.DI_NORMAL) win32gui.SelectObject(hdcBitmap, hbmOld) win32gui.DeleteDC(hdcBitmap) return hbm
Example #4
Source File: shell.py From eavatar-me with Apache License 2.0 | 6 votes |
def prep_menu_icon(self, icon): # First load the 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) hdcBitmap = win32gui.CreateCompatibleDC(0) hdcScreen = win32gui.GetDC(0) hbm = win32gui.CreateCompatibleBitmap(hdcScreen, ico_x, ico_y) hbmOld = win32gui.SelectObject(hdcBitmap, hbm) # Fill the background. brush = win32gui.GetSysColorBrush(win32con.COLOR_MENU) win32gui.FillRect(hdcBitmap, (0, 0, 16, 16), brush) # unclear if brush needs to be feed. Best clue I can find is: # "GetSysColorBrush returns a cached brush instead of allocating a new # one." - implies no DeleteObject # draw the icon win32gui.DrawIconEx(hdcBitmap, 0, 0, hicon, ico_x, ico_y, 0, 0, win32con.DI_NORMAL) win32gui.SelectObject(hdcBitmap, hbmOld) win32gui.DeleteDC(hdcBitmap) return hbm
Example #5
Source File: winapi.py From gui-o-matic with GNU Lesser General Public License v3.0 | 6 votes |
def __call__( self, window, hdc, paint_struct ): dirty = self.dirty( window ) if dirty: self.update( window, hdc ) rect = self.rect or window.get_client_region() roi = rect_intersect( rect, paint_struct[2] ) hdc_mem = win32gui.CreateCompatibleDC( hdc ) prior_bitmap = win32gui.SelectObject( hdc_mem, self.image.handle ) win32gui.BitBlt( hdc, roi[0], roi[1], roi[2] - roi[0], roi[3] - roi[1], hdc_mem, roi[0] - rect[0], roi[1] - rect[1], win32con.SRCCOPY ) win32gui.SelectObject( hdc_mem, prior_bitmap ) win32gui.DeleteDC( hdc_mem )
Example #6
Source File: winapi.py From gui-o-matic with GNU Lesser General Public License v3.0 | 6 votes |
def __call__( self, window, hdc, paint_struct ): src_roi = self.src_roi or (0, 0, self.bitmap.size[0], self.bitmap.size[1]) dst_roi = self.dst_roi or win32gui.GetClientRect( window.window_handle ) blend = self.blend or (win32con.AC_SRC_OVER, 0, 255, win32con.AC_SRC_ALPHA ) hdc_mem = win32gui.CreateCompatibleDC( hdc ) prior = win32gui.SelectObject( hdc_mem, self.bitmap.handle ) # Blit with alpha channel blending win32gui.AlphaBlend( hdc, dst_roi[ 0 ], dst_roi[ 1 ], dst_roi[ 2 ] - dst_roi[ 0 ], dst_roi[ 3 ] - dst_roi[ 1 ], hdc_mem, src_roi[ 0 ], src_roi[ 1 ], src_roi[ 2 ] - src_roi[ 0 ], src_roi[ 3 ] - src_roi[ 1 ], blend ) win32gui.SelectObject( hdc_mem, prior ) win32gui.DeleteDC( hdc_mem )