本文整理汇总了Python中win32con.DI_NORMAL属性的典型用法代码示例。如果您正苦于以下问题:Python win32con.DI_NORMAL属性的具体用法?Python win32con.DI_NORMAL怎么用?Python win32con.DI_NORMAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类win32con
的用法示例。
在下文中一共展示了win32con.DI_NORMAL属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prep_menu_icon
# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import DI_NORMAL [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
示例2: prep_menu_icon
# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import DI_NORMAL [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
示例3: prep_menu_icon
# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import DI_NORMAL [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
示例4: _set_icon_menu
# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import DI_NORMAL [as 别名]
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()
示例5: OnDrawItem
# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import DI_NORMAL [as 别名]
def OnDrawItem(self, hwnd, msg, wparam, lparam):
## lparam is a DRAWITEMSTRUCT
fmt = "5i2P4iP"
data = struct.unpack(fmt, PyGetMemory(lparam, struct.calcsize(fmt)))
ctlType, ctlID, itemID, itemAction, itemState, hwndItem, \
hDC, left, top, right, bot, itemData = data
rect = left, top, right, bot
hicon, text = self.menu_item_map[itemData]
if text is None:
# This means the menu-item had HBMMENU_CALLBACK - so all we
# draw is the icon. rect is the entire area we should use.
DrawIconEx(hDC, left, top, hicon, right-left, bot-top,
0, 0, win32con.DI_NORMAL)
else:
# If the user has selected the item, use the selected
# text and background colors to display the item.
selected = itemState & win32con.ODS_SELECTED
if selected:
crText = SetTextColor(hDC, GetSysColor(win32con.COLOR_HIGHLIGHTTEXT))
crBkgnd = SetBkColor(hDC, GetSysColor(win32con.COLOR_HIGHLIGHT))
each_pad = self.icon_x_pad // 2
x_icon = left + GetSystemMetrics(win32con.SM_CXMENUCHECK) + each_pad
x_text = x_icon + self.menu_icon_width + each_pad
# Draw text first, specifying a complete rect to fill - this sets
# up the background (but overwrites anything else already there!)
# Select the font, draw it, and restore the previous font.
hfontOld = SelectObject(hDC, self.font_menu)
ExtTextOut(hDC, x_text, top+2, win32con.ETO_OPAQUE, rect, text)
SelectObject(hDC, hfontOld)
# Icon image next. Icons are transparent - no need to handle
# selection specially.
DrawIconEx(hDC, x_icon, top+2, hicon,
self.menu_icon_width, self.menu_icon_height,
0, 0, win32con.DI_NORMAL)
# Return the text and background colors to their
# normal state (not selected).
if selected:
SetTextColor(hDC, crText)
SetBkColor(hDC, crBkgnd)