當前位置: 首頁>>代碼示例>>Python>>正文


Python win32gui.GetDC方法代碼示例

本文整理匯總了Python中win32gui.GetDC方法的典型用法代碼示例。如果您正苦於以下問題:Python win32gui.GetDC方法的具體用法?Python win32gui.GetDC怎麽用?Python win32gui.GetDC使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在win32gui的用法示例。


在下文中一共展示了win32gui.GetDC方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: prep_menu_icon

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import GetDC [as 別名]
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 
開發者ID:samclane,項目名稱:LIFX-Control-Panel,代碼行數:24,代碼來源:SysTrayIcon.py

示例2: prep_menu_icon

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import GetDC [as 別名]
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 
開發者ID:eavatar,項目名稱:eavatar-me,代碼行數:26,代碼來源:shell.py

示例3: prep_menu_icon

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import GetDC [as 別名]
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 
開發者ID:beville,項目名稱:ComicStreamer,代碼行數:24,代碼來源:gui_win.py

示例4: get_image_size

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import GetDC [as 別名]
def get_image_size(image):
    """Return the size of an image in pixels as (width, height)."""
    # Get the size of the input image in pixels (Excel sizes are in points,
    # or 1/72th of an inch.
    xl = xl_app()
    dc = win32gui.GetDC(xl.Hwnd)
    pixels_per_inch_x = win32ui.GetDeviceCaps(dc, win32con.LOGPIXELSX)
    pixels_per_inch_y = win32ui.GetDeviceCaps(dc, win32con.LOGPIXELSY)
    size_x = int(image.Width * pixels_per_inch_x / 72)
    size_y = int(image.Height * pixels_per_inch_y / 72)

    return size_x, size_y 
開發者ID:pyxll,項目名稱:pyxll-examples,代碼行數:14,代碼來源:pytorch_abstract_art.py


注:本文中的win32gui.GetDC方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。