def OnPaint_2(hwnd, msg, wp, lp): dc, ps = win32gui.BeginPaint(hwnd) win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED) l, t, r, b = win32gui.GetClientRect(hwnd) for x in range(25): vertices = ( {'x': int(random.random() * r), 'y': int(random.random() * b), 'Red': int(random.random() * 0xff00), 'Green': 0, 'Blue': 0, 'Alpha': 0}, {'x': int(random.random() * r), 'y': int(random.random() * b), 'Red': 0, 'Green': int(random.random() * 0xff00), 'Blue': 0, 'Alpha': 0}, {'x': int(random.random() * r), 'y': int(random.random() * b), 'Red': 0, 'Green': 0, 'Blue': int(random.random() * 0xff00), 'Alpha': 0}, ) mesh = ((0, 1, 2),) win32gui.GradientFill( dc, vertices, mesh, win32con.GRADIENT_FILL_TRIANGLE) win32gui.EndPaint(hwnd, ps) return 0
def WndProc(hwnd, msg, wParam, lParam): """ 视窗处理 :param hwnd: 句柄 :param msg: 消息 :param wParam: 参数1 :param lParam: 参数2 :return: 下一个消息处理器 """ if msg == WM_PAINT: hdc, ps = win32gui.BeginPaint(hwnd) rect = win32gui.GetClientRect(hwnd) _str = u'请把【项目经理:日报】文件拖拽到这!' win32gui.DrawText(hdc, _str, len(_str) * 2 - 4, rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER) win32gui.EndPaint(hwnd, ps) win32gui.DragAcceptFiles(hwnd, 1) elif msg == WM_DESTROY: win32gui.PostQuitMessage(0) elif msg == WM_DROPFILES: """文件拖拉消息 """ hDropInfo = wParam filescount = win32api.DragQueryFile(hDropInfo) for i in range(filescount): """获取文件名""" filename = win32api.DragQueryFile(hDropInfo, i) """处理文件""" fileHandler(hwnd, filename) win32api.DragFinish(hDropInfo) return win32gui.DefWindowProc(hwnd, msg, wParam, lParam)
def wndProc_edge(self, hWnd, message, wParam, lParam): if message == win32con.WM_PAINT: hdc, paintStruct = win32gui.BeginPaint(hWnd) dpiScale = win32ui.GetDeviceCaps(hdc, win32con.LOGPIXELSX) / 60.0 fontSize = self.fontSize + 12 win32gui.SetTextColor(hdc, self.color_edge) # https://msdn.microsoft.com/en-us/library/windows/desktop/dd145037(v=vs.85).aspx lf = win32gui.LOGFONT() lf.lfFaceName = "微軟正黑體" lf.lfHeight = int(round(dpiScale * fontSize)) lf.lfWeight = 700 # Use nonantialiased to remove the white edges around the text. lf.lfQuality = win32con.NONANTIALIASED_QUALITY hf = win32gui.CreateFontIndirect(lf) win32gui.SelectObject(hdc, hf) rect = win32gui.GetClientRect(hWnd) # https://msdn.microsoft.com/en-us/library/windows/desktop/dd162498(v=vs.85).aspx win32gui.DrawTextW( hdc, self.text, -1, rect, win32con.DT_CENTER | win32con.DT_NOCLIP | win32con.DT_SINGLELINE | win32con.DT_VCENTER) win32gui.EndPaint(hWnd, paintStruct) return 0 elif message == win32con.WM_DESTROY: # print('Closing the window.') win32gui.PostQuitMessage(0) return 0 else: return win32gui.DefWindowProc(hWnd, message, wParam, lParam)
def WndProc(hwnd, msg, wParam, lParam): if msg == WM_PAINT: hdc, ps = win32gui.BeginPaint(hwnd) rect = win32gui.GetClientRect(hwnd) _str = u'请把【星任务】文件拖拽到这!' win32gui.DrawText(hdc, _str, len(_str) * 2, rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER) win32gui.EndPaint(hwnd, ps) win32gui.DragAcceptFiles(hwnd, 1) elif msg == WM_DESTROY: win32gui.PostQuitMessage(0) elif msg == WM_DROPFILES: hDropInfo = wParam filescount = win32api.DragQueryFile(hDropInfo) for i in range(filescount): filename = win32api.DragQueryFile(hDropInfo, i) if os.path.isdir(filename): _files = scan_files(filename) else: _files = [filename] if len(_files) > 0: for _f in _files: fileHandler(_f) win32api.DragFinish(hDropInfo) return win32gui.DefWindowProc(hwnd, msg, wParam, lParam)
def _win_message(self, hWnd, message, wParam, lParam): if message == win32_contants.WM_PAINT: device_context_handle, paintStruct = win32gui.BeginPaint(hWnd) dpiScale = ctypes.windll.gdi32.GetDeviceCaps( device_context_handle, win32_contants.LOGPIXELSX) / 60.0 fontSize = 14 # http://msdn.microsoft.com/en-us/library/windows/desktop/dd145037(v=vs.85).aspx lf = win32gui.LOGFONT() lf.lfFaceName = "Times New Roman" # lf.lfHeight = int(round(dpiScale * fontSize)) lf.lfHeight = 20 lf.lfWeight = 0 # Use nonantialiased to remove the white edges around the text. lf.lfQuality = win32con.NONANTIALIASED_QUALITY hf = win32gui.CreateFontIndirect(lf) win32gui.SetTextColor(device_context_handle, win32_color(self.font_color)) win32gui.SelectObject(device_context_handle, hf) self._draw(device_context_handle) win32gui.EndPaint(hWnd, paintStruct) return 0 elif message == win32_contants.WM_DESTROY: win32gui.PostQuitMessage(0) return 0 else: return ctypes.windll.user32.DefWindowProcW(hWnd, message, wParam, lParam)
def BGWndProc(self,hwnd,msg,wParam,lParam): if msg == win32con.WM_PAINT: #print('BG painting...%d...'%wParam) hdc,ps = win32gui.BeginPaint(hwnd) rect = win32gui.GetClientRect(hwnd) # win32gui.Rectangle(hdc,min(xc),min(yc),max(xc),max(yc)) # win32gui.Ellipse(hdc,300+wParam,550,400+wParam,650) DFW.OnChange(mode='RandomMove') #self.hdcbuffer = win32gui.CreateCompatibleDC(hdc) #hBitMap = win32gui.CreateCompatibleBitmap(hdc, 1920, 1080) ###win32gui.ReleaseDC(hwnd, hdc) #win32gui.SelectObject(self.hdcbuffer, hBitMap) #win32gui.PatBlt(self.hdcbuffer, 0, 0, 1920, 1080, win32con.WHITENESS) #win32gui.SetBkMode(hdc,win32con.TRANSPARENT) for index in range(len(DFW.Words)): rect = (int(DFW.Coors[index][0]),int(DFW.Coors[index][1]),1920,1080) win32gui.DrawText(hdc,'%s,%d'%(DFW.Words[index],wParam), len('%s'%(DFW.Words[index])),rect,win32con.DT_SINGLELINE|win32con.DT_TOP|win32con.DT_LEFT) #win32gui.BitBlt(hdc, 0, 0, 1920, 1080, self.hdcbuffer, 0, 0, win32con.SRCCOPY ) win32gui.EndPaint(hwnd,ps) elif msg == win32con.WM_DESTROY: win32gui.PostQuitMessage(0) elif msg == win32con.WM_TIMER: #print("BG TIMER TRIGGERED",wParam) win32gui.InvalidateRect(hwnd,None,True) win32gui.UpdateWindow(hwnd) else: pass #print('BG:其他信息:',msg) return win32gui.DefWindowProc(hwnd,msg,wParam,lParam)
def WndProc(hwnd, msg, wParam, lParam): if msg == WM_PAINT: hdc, ps = win32gui.BeginPaint(hwnd) rect = win32gui.GetClientRect(hwnd) _str = u'请把【工作日志】目录拖拽到这!' win32gui.DrawText(hdc, _str, len(_str) * 2, rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER) win32gui.EndPaint(hwnd, ps) win32gui.DragAcceptFiles(hwnd, 1) elif msg == WM_DESTROY: win32gui.PostQuitMessage(0) elif msg == WM_DROPFILES: hDropInfo = wParam filescount = win32api.DragQueryFile(hDropInfo) for i in range(filescount): filename = win32api.DragQueryFile(hDropInfo, i) files = get_files_list(filename) for _f in files: if not isSpecialDir(_f): fileHandler(_f) win32api.DragFinish(hDropInfo) return win32gui.DefWindowProc(hwnd, msg, wParam, lParam)
def wndProc(hWnd, message, wParam, lParam): if message == win32con.WM_PAINT: hDC, paintStruct = win32gui.BeginPaint(hWnd) rect = win32gui.GetClientRect(hWnd) win32gui.DrawText( hDC, 'Hello send by Python via Win32!', -1, rect, win32con.DT_SINGLELINE | win32con.DT_CENTER | win32con.DT_VCENTER) win32gui.EndPaint(hWnd, paintStruct) return 0 elif message == win32con.WM_DESTROY: print('Being destroyed') win32gui.PostQuitMessage(0) return 0 elif message == FullGenMessage: print("Founded new message from FullGen") print(wParam) print(lParam) return 0 else: return win32gui.DefWindowProc(hWnd, message, wParam, lParam)
def OnPaint_1(hwnd, msg, wp, lp): dc, ps = win32gui.BeginPaint(hwnd) win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED) br = win32gui.CreateSolidBrush(win32api.RGB(255, 0, 0)) win32gui.SelectObject(dc, br) angle = win32gui.GetWindowLong(hwnd, win32con.GWL_USERDATA) win32gui.SetWindowLong(hwnd, win32con.GWL_USERDATA, angle + 2) r_angle = angle * (math.pi / 180) win32gui.SetWorldTransform( dc, { 'M11': math.cos(r_angle), 'M12': math.sin(r_angle), 'M21': math.sin(r_angle) * -1, 'M22': math.cos(r_angle), 'Dx': 250, 'Dy': 250 }) win32gui.MoveToEx(dc, 250, 250) win32gui.BeginPath(dc) win32gui.Pie(dc, 10, 70, 200, 200, 350, 350, 75, 10) win32gui.Chord(dc, 200, 200, 850, 0, 350, 350, 75, 10) win32gui.LineTo(dc, 300, 300) win32gui.LineTo(dc, 100, 20) win32gui.LineTo(dc, 20, 100) win32gui.LineTo(dc, 400, 0) win32gui.LineTo(dc, 0, 400) win32gui.EndPath(dc) win32gui.StrokeAndFillPath(dc) win32gui.EndPaint(hwnd, ps) return 0
def wndProc(hWnd, message, wParam, lParam): if message == win32con.WM_PAINT: hdc, paintStruct = win32gui.BeginPaint(hWnd) dpiScale = win32ui.GetDeviceCaps(hdc, win32con.LOGPIXELSX) / 60.0 fontSize = 18 lf = win32gui.LOGFONT() lf.lfFaceName = "Comic Sans" lf.lfHeight = int(round(dpiScale * fontSize)) hf = win32gui.CreateFontIndirect(lf) win32gui.SelectObject(hdc, hf) rect = win32gui.GetClientRect(hWnd) win32gui.DrawText( hdc, windowText, -1, rect, win32con.DT_LEFT | win32con.DT_BOTTOM | win32con.DT_SINGLELINE) win32gui.EndPaint(hWnd, paintStruct) return 0 elif message == win32con.WM_DESTROY: print('Being destroyed') win32gui.PostQuitMessage(0) return 0 else: return win32gui.DefWindowProc(hWnd, message, wParam, lParam) calrect = win32gui.DrawText(hdc, text, -1, rect, textformat | win32con.DT_CALCRECT) rect.top = rect.bottom - calcrect.bottom win32gui.DrawText(hDC, text, -1, rect, textformat)
def OnPaint(hwnd, msg, wp, lp): global dx font = win32gui.LOGFONT() font.lfFaceName = "Consolas" font.lfHeight = 48 # font.lfWidth=font.lfHeight # font.lfWeight=150 # font.lfItalic=1 # font.lfUnderline=1 hfont = win32gui.CreateFontIndirect(font) dc, ps = win32gui.BeginPaint(hwnd) win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED) l, t, r, b = win32gui.GetClientRect(hwnd) br = win32gui.CreateSolidBrush(win32api.RGB(0, 0, 255)) bitmap = win32gui.CreateBitmap(20, 5, 4, 1, None) win32gui.SelectObject(dc, bitmap) win32gui.SelectObject(dc, br) win32gui.SelectObject(dc, hfont) win32gui.SetTextColor( dc, win32api.RGB(randint(1, 255), randint(1, 255), randint(1, 255))) win32gui.DrawText(dc, 'hello', -1, (100, 100, 300, 300), 0) win32gui.FillRect(dc, (200 + dx, 200 + dx, 100 + dx, 100 + dx), br) dx = (dx + 10) % 100 win32gui.EndPaint(hwnd, ps) return 0
def wndProc(self, hwnd, msg, wParam, lParam): """ 消息处理 :param hwnd: :param msg: :param wParam: :param lParam: :return: """ if msg == win32con.WM_PAINT: hdc, ps = win32gui.BeginPaint(hwnd) rect = win32gui.GetClientRect(hwnd) win32gui.DrawText( hdc, 'GUI Python', len('GUI Python'), rect, win32con.DT_SINGLELINE | win32con.DT_CENTER | win32con.DT_VCENTER) win32gui.EndPaint(hwnd, ps) if msg == win32con.WM_CREATE: print('message: WM_CREATE') if msg == win32con.WM_SIZE: print('message: WM_SIZE') if msg == win32con.WM_PAINT: print('message: WM_PAINT') if msg == 1280: print("message: 1280") if msg == win32con.WM_CLOSE: print('message: WM_CLOSE') if msg == win32con.WM_DESTROY: print('message: WM_DESTROY') win32gui.PostQuitMessage(0) return win32gui.DefWindowProc(hwnd, msg, wParam, lParam)
def wndProc(hWnd, message, wParam, lParam): if not hasattr(wndProc, 'cxClient'): wndProc.cxClient = 0 wndProc.cyClient = 0 if message == win32con.WM_SIZE: wndProc.cxClient = win32gui.LOWORD(lParam) # 附加参数的低位字保存窗口的宽度 wndProc.cyClient = win32gui.HIWORD(lParam) # 附加参数的高位字保存窗口的高度 if message == win32con.WM_PAINT: hdc, paintStruct = win32gui.BeginPaint(hWnd) # 获取窗口的dc和窗口客户区所需要的信息的结构 win32gui.MoveToEx(hdc, 0, int(wndProc.cyClient / 2)) # 移动到直线的起始点,这里比win32 API少了最后一个参数 win32gui.LineTo(hdc, wndProc.cxClient, int(wndProc.cyClient / 2)) # 画出直线 vertices = list() # 定义一个列表用来存储点,形式为[x,y]的形式 point = list() # 定义一个列表用来存储一系列作图的点 for i in range(NUM): vertices = [] vertices.append(int(i * wndProc.cxClient / NUM)) # 计算出x坐标 vertices.append( int(wndProc.cyClient / 2 * (1 - math.sin(2 * math.pi * i / NUM)))) # 计算出y坐标 point.append(tuple(vertices)) # 将点添加到列表当中 win32gui.Polyline(hdc, point) # 画出正弦图像 win32gui.EndPaint(hWnd, paintStruct) # 关闭dc return 0 if message == win32con.WM_DESTROY: win32gui.PostQuitMessage(0) # 发送消息,退出窗口的进程 return 0 else: return win32gui.DefWindowProc(hWnd, message, wParam, lParam) # 其他消息路由给操作系统处理
def OnPaint(self, hwnd, msg, wp, lp): dc, ps = win32gui.BeginPaint(hwnd) wndrect = win32gui.GetClientRect(hwnd) wndwidth = wndrect[2] - wndrect[0] wndheight = wndrect[3] - wndrect[1] win32clipboard.OpenClipboard() try: try: hbitmap = win32clipboard.GetClipboardData( win32clipboard.CF_BITMAP) except TypeError: font = win32gui.LOGFONT() font.lfHeight = 15 #int(wndheight/20) font.lfWidth = 15 #font.lfHeight # font.lfWeight=150 hf = win32gui.CreateFontIndirect(font) win32gui.SelectObject(dc, hf) win32gui.SetBkMode(dc, win32con.TRANSPARENT) win32gui.SetTextColor(dc, win32api.RGB(0, 0, 0)) win32gui.DrawText( dc, 'No bitmaps are in the clipboard\n(try pressing the PrtScn button)', -1, (0, 0, wndwidth, wndheight), win32con.DT_CENTER) else: bminfo = win32gui.GetObject(hbitmap) dcDC = win32gui.CreateCompatibleDC(None) win32gui.SelectObject(dcDC, hbitmap) win32gui.StretchBlt(dc, 0, 0, wndwidth, wndheight, dcDC, 0, 0, bminfo.bmWidth, bminfo.bmHeight, win32con.SRCCOPY) win32gui.DeleteDC(dcDC) win32gui.EndPaint(hwnd, ps) finally: win32clipboard.CloseClipboard() return 0
def onPaint(hwnd, msg, wp, lp): hDc, ps = win32gui.BeginPaint(hwnd) win32gui.SetGraphicsMode(hDc, win32con.GM_ADVANCED) codghostdrawing.drawSoldiers(hDc, container, globalLock) win32gui.EndPaint(hwnd, ps) return 0
def WndProc(hwnd, msg, wParam, lParam): if msg == WM_PAINT: hdc, ps = win32gui.BeginPaint(hwnd) rect = win32gui.GetClientRect(hwnd) win32gui.DrawText(hdc, 'GUI Python', len('GUI Python'), rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER) win32gui.EndPaint(hwnd, ps) if msg == WM_DESTROY: win32gui.PostQuitMessage(0) return win32gui.DefWindowProc(hwnd, msg, wParam, lParam)
def wndProc(hWnd, message, wParam, lParam): global data if message == win32con.WM_PAINT: hdc, paintStruct = win32gui.BeginPaint(hWnd) dpiScale = win32ui.GetDeviceCaps(hdc, win32con.LOGPIXELSX) / 60.0 fontSize = 80 # http://msdn.microsoft.com/en-us/library/windows/desktop/dd145037(v=vs.85).aspx lf = win32gui.LOGFONT() lf.lfFaceName = "Times New Roman" lf.lfHeight = int(round(dpiScale * fontSize)) #lf.lfWeight = 150 # Use nonantialiased to remove the white edges around the text. # lf.lfQuality = win32con.NONANTIALIASED_QUALITY hf = win32gui.CreateFontIndirect(lf) win32gui.SelectObject(hdc, hf) rect = win32gui.GetClientRect(hWnd) # http://msdn.microsoft.com/en-us/library/windows/desktop/dd162498(v=vs.85).aspx if not loaded: win32gui.DrawText( hdc, 'Loading Neural Net...', -1, rect, win32con.DT_CENTER | win32con.DT_NOCLIP | win32con.DT_SINGLELINE | win32con.DT_VCENTER) color = win32api.RGB(0, 0, 255) color2 = win32api.RGB(255, 255, 0) brush = win32gui.CreateSolidBrush(color) fontSize = 12 lf = win32gui.LOGFONT() lf.lfFaceName = 'Times New Roman' lf.lfHeight = int(round(dpiScale * fontSize)) lf.lfQuality = win32con.NONANTIALIASED_QUALITY hf = win32gui.CreateFontIndirect(lf) win32gui.SelectObject(hdc, hf) win32gui.SetTextColor(hdc, color2) for minion in data: win32gui.DrawText( hdc, minion['class'] + ' ' + str(int(minion['score'] * 100)), -1, minion['location'], win32con.DT_BOTTOM | win32con.DT_SINGLELINE | win32con.DT_NOCLIP) win32gui.FrameRect(hdc, minion['location'], brush) win32gui.EndPaint(hWnd, paintStruct) return 0 elif message == win32con.WM_DESTROY: print('Closing the window.') win32gui.PostQuitMessage(0) return 0 else: return win32gui.DefWindowProc(hWnd, message, wParam, lParam)
def onPaint(hwnd, msg, wp, lp): hDc, ps = win32gui.BeginPaint(hwnd) win32gui.SetGraphicsMode(hDc, win32con.GM_ADVANCED) bf4drawing.setTextColor(hDc) bf4drawing.drawCrossHair(hDc, centerX, centerY, size=10) bf4drawing.drawSoldiers(hDc, dataContainer, globalLock, centerX, centerY) win32gui.EndPaint(hwnd, ps) return 0
def OnPaint(hwnd, msg, wp, lp): global dx dc, ps=win32gui.BeginPaint(hwnd) win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED) l,t,r,b=win32gui.GetClientRect(hwnd) br=win32gui.CreateSolidBrush(win32api.RGB(0,0,255)) win32gui.SelectObject(dc, br) win32gui.FillRect(dc,(200+dx,200+dx,100+dx,100+dx),br) dx=(dx+10)%100 win32gui.EndPaint(hwnd, ps) return 0
def Render(hWnd): hDC, paintStruct = win32gui.BeginPaint(hWnd) rect = win32gui.GetClientRect(hWnd) win32gui.DrawText( hDC, 'Hello send by Python via Win32!', -1, rect, win32con.DT_SINGLELINE | win32con.DT_CENTER | win32con.DT_VCENTER) win32gui.EndPaint(hWnd, paintStruct) pass
def on_paint(self, hwnd, message, wparam, lparam): """Draw current selection rectangle.""" hdc, paint = win32gui.BeginPaint(hwnd) # Selection not started yet if self._selection is None: win32gui.EndPaint(hwnd, paint) return 0 brush = win32gui.GetStockObject(win32con.NULL_BRUSH) pen = win32gui.CreatePen(win32con.PS_SOLID, self.REGION_WIDTH, self.REGION_COLOR) brush_default = win32gui.SelectObject(hdc, brush) pen_default = win32gui.SelectObject(hdc, pen) win32gui.Rectangle(hdc, *self._selection) win32gui.SelectObject(hdc, pen_default) win32gui.SelectObject(hdc, brush_default) win32gui.EndPaint(hwnd, paint) return 0
def wndProc(hWnd, message, wParam, lParam): global hdc if message == win32con.WM_PAINT: hdc, paintStruct = win32gui.BeginPaint(hWnd) debugRender(hWnd, hdc, paintStruct) win32gui.EndPaint(hWnd, paintStruct) return 0 elif message == win32con.WM_DESTROY: print('Closing the window.') win32gui.PostQuitMessage(0) return 0 else: return win32gui.DefWindowProc(hWnd, message, wParam, lParam)
def WndProc(self, hwnd, msg, wParam, lParam): if msg == win32con.WM_PAINT: print('WM_PAINT') hdc, ps = win32gui.BeginPaint(hwnd) rect = win32gui.GetClientRect(hwnd) win32gui.DrawText( hdc, 'GUI Python', len('GUI Python'), rect, win32con.DT_SINGLELINE | win32con.DT_CENTER | win32con.DT_VCENTER) win32gui.EndPaint(hwnd, ps) if msg == win32con.WM_DESTROY: print('WM_DESTROY') win32gui.PostQuitMessage(0) if msg == win32con.WM_DEVICECHANGE: print('WM_DEVICECHANGE') self.hotplugCallbackWin(hwnd, msg, wParam, lParam) return win32gui.DefWindowProc(hwnd, msg, wParam, lParam)
def OnPaint(self, hWnd, msg, wparam, lparam): dc, ps = win32gui.BeginPaint(hWnd) wndrect = win32gui.GetClientRect(hWnd) wndwidth = wndrect[2] - wndrect[0] wndheight = wndrect[3] - wndrect[1] if os.path.isfile(FILENAME): hBitmap = win32gui.LoadImage(0, FILENAME, win32con.IMAGE_BITMAP, 0, 0, win32con.LR_LOADFROMFILE) hdcBitmap = win32gui.CreateCompatibleDC(dc) hOldBitmap = win32gui.SelectObject(hdcBitmap, hBitmap) bminfo = win32gui.GetObject(hBitmap) win32gui.SetStretchBltMode(dc, win32con.COLORONCOLOR) win32gui.StretchBlt(dc, 0, 0, wndwidth, wndheight, hdcBitmap, 0, 0, bminfo.bmWidth, bminfo.bmHeight, win32con.SRCCOPY) win32gui.SelectObject(hdcBitmap, hOldBitmap) win32gui.EndPaint(hWnd, ps) return 0
def wndProc(hWnd, message, wParam, lParam): if message == win32con.WM_PAINT: hDC, paintStruct = win32gui.BeginPaint(hWnd) rect = win32gui.GetClientRect(hWnd) win32gui.DrawText( hDC, 'Hello send by Python via Win32!', -1, rect, win32con.DT_SINGLELINE | win32con.DT_CENTER | win32con.DT_VCENTER) win32gui.EndPaint(hWnd, paintStruct) return 0 elif message == win32con.WM_DESTROY: win32gui.PostQuitMessage(0) return 0 elif message == FullGenMessage: connection.set("wParam", str(wParam)) connection.set("lParam", str(lParam)) return 0 else: return win32gui.DefWindowProc(hWnd, message, wParam, lParam)
def OnPaint(hwnd, msg, wp, lp): """Windows needs repainting""" dc, ps = win32gui.BeginPaint(hwnd) #Draw red circle br = win32gui.CreateSolidBrush(win32api.RGB(255, 0, 0)) win32gui.SelectObject(dc, br) win32gui.Ellipse(dc, 20, 20, 120, 120) #Draw green rectangle br = win32gui.CreateSolidBrush(win32api.RGB(0, 255, 0)) win32gui.SelectObject(dc, br) win32gui.Rectangle(dc, 150, 20, 300, 120) #Draw blue triangle br = win32gui.CreateSolidBrush(win32api.RGB(0, 0, 255)) win32gui.SelectObject(dc, br) win32gui.Polygon(dc, [(400, 20), (350, 120), (450, 120)]) win32gui.EndPaint(hwnd, ps) return 0
def wndProc(hWnd, message, wParam, lParam): if message == win32con.WM_PAINT: hdc, paintStruct = win32gui.BeginPaint(hWnd) print 'windProc' dpiScale = win32ui.GetDeviceCaps(hdc, win32con.LOGPIXELSX) / 60.0 fontSize = 80 lf = win32gui.LOGFONT() lf.lfFaceName = "Times New Roman" lf.lfHeight = int(round(dpiScale * fontSize)) hf = win32gui.CreateFontIndirect(lf) win32gui.SelectObject(hdc, hf) rect = win32gui.GetClientRect(hWnd) win32gui.DrawText( hdc, 'O', -1, rect, win32con.DT_CENTER | win32con.DT_NOCLIP | win32con.DT_SINGLELINE | win32con.DT_VCENTER) win32gui.EndPaint(hWnd, paintStruct) return 0 elif message == win32con.WM_DESTROY: print 'Closing the window.' win32gui.PostQuitMessage(0) return 0 else: return win32gui.DefWindowProc(hWnd, message, wParam, lParam)
def _paint(self, window, message, w, l): """Draw the Labels on the Windows surface""" try: if not self.__init: return handle, paint = gui.BeginPaint(window) r = self.rectangle y, w, h = 0, r[2] - r[0], r[3] - r[1] for _, (text, image, color, font) in sorted(self._labels.copy().items(), key=lambda k: k[0]): x = 0 if image is not None: x = self._draw_image(handle, paint, (0, y, w, h - y), image) box = (x, y, w, h - y) _y, _ = self._draw_text(handle, box, text, color, font) y += _y gui.EndPaint(window, paint) return 0 except Exception as e: self._error = e return -1
def OnPaint_2(hwnd, msg, wp, lp): dc, ps = win32gui.BeginPaint(hwnd) win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED) l, t, r, b = win32gui.GetClientRect(hwnd) for x in range(25): vertices = ( { "x": int(random.random() * r), "y": int(random.random() * b), "Red": int(random.random() * 0xFF00), "Green": 0, "Blue": 0, "Alpha": 0, }, { "x": int(random.random() * r), "y": int(random.random() * b), "Red": 0, "Green": int(random.random() * 0xFF00), "Blue": 0, "Alpha": 0, }, { "x": int(random.random() * r), "y": int(random.random() * b), "Red": 0, "Green": 0, "Blue": int(random.random() * 0xFF00), "Alpha": 0, }, ) mesh = ((0, 1, 2), ) win32gui.GradientFill(dc, vertices, mesh, win32con.GRADIENT_FILL_TRIANGLE) win32gui.EndPaint(hwnd, ps) return 0
def wndProc(self, hWnd, message, wParam, lParam): if message == win32con.WM_PAINT: hDC, paintStruct = win32gui.BeginPaint(hWnd) folder_with_ico_file = 'share' if hasattr(sys, 'frozen') else 'windows' filename = os.path.join(os.path.dirname(sys.argv[0]), folder_with_ico_file, 'bleachbit.ico') flags = win32con.LR_LOADFROMFILE hIcon = win32gui.LoadImage(0, filename, win32con.IMAGE_ICON, 0, 0, flags) # Default icon size seems to be 32 pixels so we center the icon vertically. default_icon_size = 32 icon_top_margin = self._splash_screen_height - 2 * ( default_icon_size + 2) win32gui.DrawIcon(hDC, 0, icon_top_margin, hIcon) # win32gui.DrawIconEx(hDC, 0, 0, hIcon, 64, 64, 0, 0, win32con.DI_NORMAL) rect = win32gui.GetClientRect(hWnd) textmetrics = win32gui.GetTextMetrics(hDC) text_left_margin = 2 * default_icon_size text_rect = (text_left_margin, (rect[3] - textmetrics['Height']) // 2, rect[2], rect[3]) win32gui.DrawText(hDC, _("BleachBit is starting...\n"), -1, text_rect, win32con.DT_WORDBREAK) win32gui.EndPaint(hWnd, paintStruct) return 0 elif message == win32con.WM_DESTROY: win32gui.PostQuitMessage(0) return 0 else: return win32gui.DefWindowProc(hWnd, message, wParam, lParam)